In this tutorial, we will show you how to install PrestaShop on a CentOS 8 VPS.
PrestaShop is one of the most well-known eCommerce platforms in the world. It’s free, open-source, and is built on top of PHP, while using a MySQL database to store the data. It helps small to large businesses to create and run a successful online store.
PrestaShop is simple, easy-to-use, easy to install, and is versatile – it provides a great platform for people around the world to create their online stores. Let’s begin with the installation.
Table of Contents
Prerequisites
- A CentOS 8 VPS with root access enabled or a user with sudo privileges. We include root access on all of our VPSes.
- A minimum of 2GB of RAM and 2 CPU cores. For this, we’ll be using our SSD 2 VPS plan.
- A LEMP stack needs to be set up on the server. We’ll show you how to do this as well.
Step 1: Getting Started
First, you will need to log in to your CentOS 8 VPS via SSH as the root user:
ssh root@IP_ADDRESS -p PORT_NUMBER
Next, run the following commands to upgrade all installed packages on your VPS:
dnf update -y
By default, SELinux is enabled on a default CentOS 8 system. We recommend to disable SELinux on your system to prevent any security conflicts.
You can disable SELinux by editing the /etc/selinux/config
file:
nano /etc/selinux/config
Find the following line:
SELINUX=enforcing
And, replace it with the following line:
SELINUX=permissive
Save and close the file. Then, restart your system to apply the changes.
Step 2: Install Nginx, MariaDB and PHP
In order for PrestaShop to function correctly, you will need to install the Nginx web server, MariaDB database server, PHP, as well as some required PHP extensions on your server. You can install all of them using this simple command:
dnf install nginx mariadb-server php php-cli php-bcmath php-xmlrpc php-intl php-mysqli php-gd php-pdo php-posix php-json php-curl php-zip php-fpm unzip -y
Once all the packages are installed, edit the php.ini
file and tweak some settings:
nano /etc/php.ini
Change the following settings:
max_input_vars = 5000
post_max_size = 128M
upload_max_filesize = 128M
max_execution_time = 18000
memory_limit = 256M
date.timezone = UTC
Save and close the file when you are finished. Then, start the Nginx and MariaDB services and enable them to start at reboot with the following commands:
systemctl start nginx
systemctl start mariadb
systemctl enable nginx
systemctl enable mariadb
Step 3: Configure PHP-FPM
By default, PHP-FPM is configured to run with an Apache user and group. In this tutorial, we will use the Nginx webserver. This is why you’ll need to configure PHP-FPM to run as an Nginx user and group.
To do so, edit the PHP-FPM configuration file:
nano /etc/php-fpm.d/www.conf
Change the user and group value from apache
to nginx
, as shown below:
user = nginx
group = nginx
Save and close the file when you are finished. Then, set the proper permission and ownership of the /var/lib/php/session
directory so that it belongs to Nginx:
chown -R nginx:nginx /var/lib/php/session
chmod -R 775 /var/lib/php/session
Next, start the PHP-FPM service and enable it to start at reboot with the following command:
systemctl start php-fpm
systemctl enable php-fpm
Step 4: Create a Database for PrestaShop
First, secure the MariaDB installation and set the MariaDB root password using the following command:
mysql_secure_installation
Answer all the questions as shown below:
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Once our MariaDB instance is secured, log in to MariaDB with the following command:
mysql -u root -p
Provide your MariaDB root password when prompted, then create a database and user for PrestaShop with the following commands:
MariaDB [(none)]> CREATE DATABASE prestashop; MariaDB [(none)]> CREATE USER 'prestashop'@'localhost' IDENTIFIED BY 'password';
Please make sure to set your own password to something strong for the prestashop
user.
Next, grant all the privileges to the PrestaShop database with the following command:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashop. * TO 'prestashop'@'localhost';
Finally, flush the privileges and exit from the MariaDB shell with the following commands:
MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> EXIT;
Step 5: Install PrestaShop
At the time of writing this tutorial, the latest version of PrestaShop is 1.7.6.5. You can download it from its official download page using the following command:
wget https://download.prestashop.com/download/releases/prestashop_1.7.6.5.zip
Once downloaded, unzip the downloaded file to the Nginx web root directory with the following command:
unzip prestashop_1.7.6.5.zip -d /var/www/html/prestashop
Next, give proper ownership and permissions to the prestashop
directory so that they belong to Nginx:
chown -R nginx:nginx /var/www/html/prestashop
chmod -R 775 /var/www/html/prestashop
Once you are finished, you can proceed to the next step.
Step 6: Configure Nginx for PrestaShop
Next, create an Nginx virtual host configuration file to serve PrestaShop.
nano /etc/nginx/conf.d/prestashop.conf
Add the following lines:
server { listen 80; server_name prestashop.example.com; root /var/www/html/presatshop; index index.php index.html; location / { rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2.jpg last; rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.jpg last; rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last; rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last; rewrite ^/c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1.jpg last; rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last; try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } gzip on; gzip_comp_level 1; gzip_buffers 16 8k; gzip_types application/json text/css application/javascript; }
Make sure that you replace example.com
with your registered domain name.
Save and close the file when you are finished. Then, check with Nginx for any syntax errors by using the following command:
nginx -t
Finally, restart the Nginx service to implement all of the changes we made:
systemctl restart nginx
Step 7: Access the PrestaShop Web Inerface
Now, open your web browser and type the URL http://prestashop.example.com
. You will be redirected to the PrestaShop installation page:
Select your language and click on the Next button. You should see the PrestaShop License agreement page:
Accept the License agreement and click on the Next button. You should see the system compatibility page:
Click on the Next button. You should see the store information page:
Provide all details and click on the Next button. You should see the system configuration page:
Provide your database details and click on the Next button to start the installation. Once the installation has been completed, you should see the following page:
For security reasons, you’ll need to delete the installation directory. To do so, go back to the terminal and run the following rm
command:
rm -rf /var/www/html/prestashop/install
Next, click on the Back Office. You should see the PrestaShop admin page:
Provide your admin email address and admin password and click on the LOG IN button. You should see the PrestaShop administration interface:
Congratulations! you have successfully installed PrestaShop with Nginx on CentOS 8.
If you carefully followed the steps in this tutorial, you should have a working PrestaShop instance on your CentOS 8 VPS. For more details about PrestaShop configuration and usage, please check PrestaShop’s official documentation.
Having an online store is great for boosting your online presence and getting increased sales, however managing and maintaining your server can be a hassle and a frustrating process. With our managed PrestaShop hosting however, we can handle all of the complicated tasks for you. Just send us a ticket or start a live chat, and we can do anything from maintaining your server to installing software or copying files.
Feel free to leave a comment if you have any suggestions or questions about our PrestaShop tutorial. We’d also appreciate you sharing this on social media by using our share shortcuts if this tutorial was helpful to you.