HowtoForge

How to Install PrestaShop on AlmaLinux 9

PrestaShop is an open-source e-commerce platform that runs efficiently on AlmaLinux, providing a robust solution for building and managing online stores. Known for its flexibility and extensive range of features, PrestaShop allows users to easily create customizable online shops. The platform supports numerous payment gateways, shipping methods, and marketing tools, enhancing the shopping experience for both merchants and customers. On AlmaLinux, a stable and secure enterprise-grade Linux distribution, PrestaShop benefits from a reliable and high-performance environment. This combination makes it ideal for businesses of all sizes seeking to establish a professional and scalable online presence.

This guide will show you how to install PrestaShop on an AlmaLinux 9 server with the LAMP Stack (Apache/Htppd, MySQL/MariaDB, and PHP). You will also learn how to secure PrestaShop with SSL/TLS certificates from Letsencrypt.

Prerequisites

Before going further, make sure you have the following:

Installing LAMP Stack

First, you need to install package dependencies to run PrestaShop. In this guide, you will run PrestaShop with the LAMP Stack (Apache2/Httpd, MySQL/MariaDB, and PHP). For now, PrestaShop requires at least Apache 2.4, PHP 8.1, and MySQL 5.6.

In this step, you will install LAMP Stack with additional PHP extensions that PrestaShop requires.

Before that, run the command below to enable EPEL and Remi repository for AlmaLinux.

sudo dnf install epel-release dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm

Now run the command below to enable PHP 8.1 via the Remi repository.

sudo dnf module reset php
sudo dnf module enable php:remi-8.2

Install the LAMP Stack package to your AlmaLinux 9 server with the command below.

sudo dnf install httpd mariadb-server php php-curl php-soap php-intl php-zip php-cli php-mysqlnd php-common php-opcache php-memcached php-bcmath php-gd php-mbstring php-xml php-gmp php-imagick

Type y to proceed with the installation.

Also, type y to accept the GPG key for the Remi repository.

After installation is finished, start and enable both Apache and MariaDB services on your system.

Execute the following command to start and enable the httpd service.

sudo systemctl enable httpd
sudo systemctl start httpd

Then, verify the httpd service to ensure it's running.

sudo systemctl status httpd

As shown in the picture below, the httpd service is running.

Next, start and enable the MariaDB service with the command below.

sudo systemctl enable mariadb
sudo systemctl start mariadb

Once MariaDB is running, verify the mariadb service using the following command.

sudo systemctl status mariadb

You can see the MariaDB service running on your AlmaLinux server.

Lastly, run the following command to verify the PHP version and list of enabled extensions. Be sure that you have installed PHP 8.1 for PrestaShop installation.

php -v
php -m

Setting Up Firewalld

After installing LAMP Stack, you must open both HTTP and HTTPS services via firewalld. This allows clients to access your PrestaShop installation.

Open the HTTP and HTTPS services on firewalld using the following command.

sudo firewall-cmd --add-service={http,https} --permanent

Now reload firewalld to take effect of your changes.

sudo firewall-cmd --reload

Lastly, verify the list of enabled services and ports in firewalld. Ensure both HTTP and HTTPS services is added to firewalld.

sudo firewall-cmd --list-all

Setting Up PHP

In this section, you will set up your PHP installation by editing the default php.ini file. PrestaShop required at least 256 MB memory_limit, and also required the allow_url_fopen to be enabled. So you must modify your php.ini configuration file.

Open the PHP configuration file /etc/php.ini using the following nano editor.

sudo nano /etc/php.ini

Change the default PHP configuration with the following. Be sure to adjust the timezone and memory_limit with your current environment.

date.timezone = Europe/Paris
max_execution_time = 130
memory_limit = 256M
allow_url_fopen = On
allow_url_include = Off
post_max_size = 128M
upload_max_filesize = 128M
max_input_vars = 5000

Save the file and exit the editor when you're done.

Now run the systemctl command below to restart the httpd service and apply your PHP configuration.

sudo systemctl restart httpd

Setting Up MariaDB Server

Now with PHP configured, move on to the MariaDB server configuration. You will secure your MariaDB server installation, then create a new database and user for PrestaShop.

To secure your MariaDB server installation, execute the command below.

sudo mariadb-secure-installation

When the process starts, you will be asked with some of MariaDB configuration - Input Y to apply the suggested configuration, or type N to reject it:

After configuring the MariaDB server, you will create a new database and user for PrestaShop.

Log in to the MariaDB server with the command below. Enter your MariaDB root password when prompted.

sudo mariadb -u root -p

Once logged in, execute the following queries to create a new database prestashopdb with user prestashop and password psp4ssw0rd.

CREATE DATABASE prestashopdb;
GRANT ALL PRIVILEGES ON prestashopdb.* TO 'prestashop'@'localhost' IDENTIFIED BY 'psp4ssw0rd';
FLUSH PRIVILEGES;

Now run the following query to verify privileges for user prestashop. Be sure that user prestashop has privileges to access the database prestashopdb.

SHOW GRANTS FOR prestashop@localhost;

lastly, type quit to exit from the MariaDB server.

Checking Environment for PrestaShop Installation

Now that you have configured LAMP Stack, the next step is verifying your PrestaShop environment.

Move to the /var/www/html directory and download the PrestaShop checker using the wget command below. Be sure to grab the latest version of the PrestaShop checker.

cd /var/www/html/
wget https://github.com/PrestaShop/php-ps-info/archive/refs/tags/v1.1.tar.gz

Once downloaded, extract the PrestaShop check source code and rename the extracted directory to check-ps.

tar -xzvf v1.1.tar.gz
mv php-ps-info-1.1 check-ps

Lastly, open your web browser and visit your server IP address followed by the path of PrestaShop checker, such as http://192.168.5.50/check-ps/phppsinfo.php.

Input the default user and password 'prestashop'.

From the PrestaShop checker page, ensure that every dependency and system configuration is met with the PrestaShop requirements.

Downloading PrestaShop

In this section, you will download the PrestaShop source code to your AlmaLinux server. You will also set up proper permission and ownership for the PrestaShop source code.

Move to the /var/www directory and download the latest version of PrestaShop using the wget command below. Be sure to check the PrestaShop GitHub page to get the latest stable version of PrestaShop.

cd /var/www/
wget https://github.com/PrestaShop/PrestaShop/releases/download/8.1.3/prestashop_8.1.3.zip

Once downloaded, extract the PrestaShop source code to the /var/www/prestashop directory using unzip command below. This will be used as the document root directory for PrestaShop.

unzip prestashop_8.1.3.zip -d /var/www/prestashop

Now change the ownership and permission of the /var/www/prestashop directory to user apache.

sudo chown -R apache:apache /var/www/prestashop
sudo chmod u+rw /var/www/prestashop

Setting Up Httpd Virtual Host

After downloading PrestaShop, you need to create a new httpd virtual host configuration that will be used to run PrestaShop. So be sure that you have your domain name ready before configuring the virtual host.

Create a new httpd virtual host configuration /etc/httpd/conf.d/prestashop.conf using the following nano editor command.

sudo nano /etc/httpd/conf.d/prestashop.conf

Add the configuration below to the file and be sure to change the domain name with your domain.

<VirtualHost *:80>
ServerName howtoforge.local
ServerAdmin admin@howtoforge.local
DocumentRoot /var/www/prestashop

<Directory /var/www/prestashop>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/prestashop_error.log
CustomLog /var/log/httpd/prestashop_access.log combined
</VirtualHost>

Save and exit the file when you're done.

Now execute the following command to verify your httpd configuration. If you have proper httpd syntax, you will get an output Syntax OK.

sudo apachectl configtest

Lastly, run the command below to restart the httpd service and implement your new virtual host configuration. Your PrestaShop installation should now be accessible.

sudo systemctl restart httpd

Setting Up Certbot

Before you start the PrestaShop installation, make sure to generate SSL/TLS certificates, especially for production. This you do easily via Certbot.

Install the certbot and Certbot Apache plugin to your AlmaLinux server with the following command.

sudo dnf install -y certbot python3-certbot-apache -y

Once the installation is complete, generate SSL/TLS certificates for your PrestaShop domain name with the command below. Be sure to change the details domain name and email address in the following command.

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email alice@howtoforge.local -d howtoforge.local

With this, your SSL/TLS certificates will be generated to the /etc/letsencrypt/live/domain.com directory. Also, your PrestaShop installation will be automatically configured with HTTPS via the Certbot Apache plugin.

Installation of PrestaShop

Open your web browser and visit your PrestaShop domain name, which is https://howtoforge.local/. If your installation is successful, you will get the PrestaShop installation page.

First, select the default language to English, then click Next.

Now select Agree to accept the license agreement for PrestaShop and click Next.

Input your Shop name, admin user, password, and email address that will be used as the administrator for your PrestaShop installation. Then, click Next to continue.

For store configuration, you can install demo data and click Next.

Next, input details of your MariaDB database name, user, and password. Then click Next again.

After the installation completes, you will get the configuration like this - You can also see an additional instruction for deleting the PrestaShop install directory:

PrestaShop homepage.

Back to your terminal and execute the command below to delete the PrestaShop install directory.

rm -rf /var/www/prestashop/install

Lastly, execute the following command to allow reading and writing for PrestaShop directories.

chmod u+rw /var/www/prestashop/var/cache
chmod u+rw /var/www/prestashop/var/logs
chmod u+rw /var/www/prestashop/img
chmod u+rw /var/www/prestashop/mails
chmod u+rw /var/www/prestashop/modules
chmod u+rw /var/www/prestashop/translations
chmod u+rw /var/www/prestashop/upload
chmod u+rw /var/www/prestashop/download
chmod u+rw /var/www/prestashop/app/config
chmod u+rw /var/www/prestashop/app/Resources/translations

Conclusion

Congratulations! You have completed the installation of PrestaShop on the AlmaLinux 9 server. You have installed PrestaShop with the LAMP Stack (Apache/Httpd, MySQL/MariaDB, and PHP) and secured PrestaShop with SSL/TLS certificates from Letsencrypt. Now, you can upload your themes and add your products to sell.

How to Install PrestaShop on AlmaLinux 9