(Last Updated On: November 5, 2018)

In this guide, I’ll show you how to Install PrestaShop On Ubuntu 18.04 LTS with Nginx as a Web Server. PrestaShop is a  fully scalable open source e-commerce solution that helps you sell your products online by providing the best shopping cart experience for both merchants and customers.

PrestaShop is written in PHP to be highly customizable and to support all the major payment services. It comes with a plenty of templates and you can easily choose the right storefront that fits your brand.

Below are the standard steps of installing PrestaShop On Ubuntu 18.04 LTS With Nginx.

Step 1: Install Nginx and PHP

PrestaShop requires both PHP and a web server. Our web server of choice is Nginx but Apache can also be used.

sudo apt update
sudo apt -y install nginx php-cli php-intl php-fpm php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath

Both nginx and php-fpm services should be running:

$ systemctl status nginx php7.2-fpm.service 
* nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-11-04 12:13:11 PST; 21s ago
     Docs: man:nginx(8)
  Process: 23848 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 23837 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 23852 (nginx)
    Tasks: 3 (limit: 1111)
   CGroup: /system.slice/nginx.service
           |-23852 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           |-23853 nginx: worker process
           `-23854 nginx: worker process

Nov 04 12:13:11 ubuntu-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 04 12:13:11 ubuntu-01 systemd[1]: Started A high performance web server and a reverse proxy server.

* php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-11-04 05:57:11 PST; 6h ago
     Docs: man:php-fpm7.2(8)
 Main PID: 17354 (php-fpm7.2)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 1111)
   CGroup: /system.slice/php7.2-fpm.service
           |-17354 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
           |-17369 php-fpm: pool www
           `-17370 php-fpm: pool www

Nov 04 05:57:11 ubuntu-01 systemd[1]: Starting The PHP 7.2 FastCGI Process Manager...
Nov 04 05:57:11 ubuntu-01 systemd[1]: Started The PHP 7.2 FastCGI Process Manage

Step 2: Install and Configure MariaDB Database server

PrestaShop needs a database server for storing its data. MariaDB is a powerful open source relational database system. You can install MariaDB on your Ubuntu 18.04 server by following our guide below:

Install MariaDB 10.x on Ubuntu 18.04 and CentOS 7

If you would like to use MySQL instead, check:

How to Install MySQL 8.0 on Ubuntu 18.04 / 16.04

Login to the MariaDB shell:

$ mysql -u root -p

Create a database and user for PrestaShop:

CREATE USER 'prestashop'@'localhost' IDENTIFIED BY 'StrongPassword';
CREATE DATABASE prestashop;
GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashop'@'localhost';
FLUSH PRIVILEGES;
QUIT

Check if you can log in to Database shell as prestashop user:

$ mysql -u prestashop -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.3.34-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| prestashop         |
+--------------------+
2 rows in set (0.00 sec)

Step 3: Download Latest PrestaShop

Please check for the latest release of PrestaShop before downloading. Once you get the version, export it as a Variable.

export VER="1.7.4.3"

Download the latest version:

wget https://download.prestashop.com/download/releases/prestashop_${VER}.zip

Uncompress the archive file.

mkdir prestashop
unzip prestashop_${VER}.zip -d prestashop

Move prestashop to /srv/prestashop

sudo mv prestashop /srv

Set Proper permissions for /srv/prestashop

sudo chown -R www-data:www-data /srv/prestashop/
sudo chmod -R 755 /srv/prestashop/

Step 4: Configure Nginx

If you had not installed Nginx in the first step, ensure it is installed and running

sudo apt install nginx

Then create a Virtual Host file for PrestaShop

sudo vim /etc/nginx/conf.d/prestashop.conf

Populate below data to the file

server {
    listen 80;
    server_name  example.com;
    root /srv/prestashop;
    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$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.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;
}

The file syntax should be confirmed to be Ok before restarting nginx.

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart nginx service for the new file to be loaded

sudo systemctl restart nginx

Launch PrestaShop setup wizard to finish installation on http://example.com

1. Choose installation language and click “Next

2. Agree to software terms and conditions then click “Next

3. Confirm that PrestaShop compatibility verification is successful the click Next

4. Choose Shop name, main activity and create Your Account

5. Configure your database connection with credentials created earlier and click “Test your database connection now!“.

Wait for the installation to finish the login with user created in 4.

For security purposes, you must delete the “install” folder.

sudo rm -rf /srv/prestashop/install/

Choose whether to access the Back or the Front office.

You have successfully install PrestaShop on Ubuntu 18.04 LTS. Visit PrestaShop Documentation page to learn more on adding Products, customizing templates, setting Prices e.t.c.