This brief tutorial shows students and new users how to install the PrestaShop eCommerce platform on Ubuntu 20.04 | 18.04 with Nginx HTTP server and Let’s encrypt wildcard SSL certificates.
PrestaShop provides an efficient and innovative e-commerce solution that suits anyone looking for an easy platform to manage and sell their inventory online.
It enables you to create a complete online store, including inventory management, product catalogs, shipping, invoicing, and many more.
You can use PrestaShop to run your online stores and build amazing digital experiences with little effort.
For more about PrestaShop, please check their Homepage
To get started with installing PrestaShop, follow the steps below:
Install Nginx HTTP Server
PrestaShop requires a web server to function, and Nginx is one of the most popular open-source web servers available today.
To install Nginx on Ubuntu, run the commands below:
sudo apt update sudo apt install nginx
After installing Nginx, the commands below can be used to stop, start and enable the Nginx service to always start up with the server boots.
sudo systemctl stop nginx.service sudo systemctl start nginx.service sudo systemctl enable nginx.service
To test whether Nginx is installed and functioning, open your web browser and browse to the server’s IP address or hostname.
http://localhost

If you see the above page in your browser, then Nginx is working as expected.
Install MariaDB Database Server
You’ll also need a database server to run PrestaShop. A database server is where PrestaShop content gets stored.
A truly open-source database server that you can use with PrestaShop is the MariaDB database server. It is fast, secure and the default server for almost all Linux servers.
To install MariaDB, run the commands below:
sudo apt-get install MariaDB-server MariaDB-client
After installing MariaDB, the commands below can be used to stop, start and enable the MariaDB service always to start up when the server boots.
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation.
sudo mysql_secure_installation
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat 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
To verify and validate that MariaDB is installed and working, log in to the database console using the commands below:
sudo mysql -u root -p
type the root password when prompted.

If you see a similar screen as shown above, then the server was successfully installed.
Install PHP 7.4 and Related Modules
PrestaShop is a PHP-based application, and PHP is required to run it. Since some versions of Ubuntu don’t have the latest version of PHP, you can add a third-party PPA repository to install PHP from there.
The command below will add a third-party PPA to Ubuntu.
sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php
Then update and upgrade to PHP 7.4
sudo apt update
Next, run the commands below to install PHP 7.4 and related modules.
sudo apt install php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip
After installing PHP 7.4, go and configure some basic settings that may be required for PrestaShop to function properly.
Run the commands below to open the PHP
sudo nano /etc/php/7.4/fpm/php.ini
Below are good settings to configure for most PrestaShop websites.
file_uploads = On allow_url_fopen = On short_open_tag = On memory_limit = 256M cgi.fix_pathinfo = 0 upload_max_filesize = 100M max_execution_time = 360 date.timezone = America/Chicago
That should get PHP 7.4 installed with some basic settings to allow PrestaShop to function.
Create PrestaShop Database
When all the servers are installed above, it’s now time to begin setting up the PrestaShop environment. First, run the steps below to create a blank database for PrestaShop to use.
Login to the MariaDB database console using the commands below:
sudo mysql -u root -p
Then create a database called Prestashop
CREATE DATABASE prestashop;
Next, create a database user called prestashopuser and set a password
CREATE USER 'prestashopuser'@'localhost' IDENTIFIED BY 'new_password_here';
Then grant the user full access to the database.
GRANT ALL ON prestashop.* TO 'prestashopuser'@'localhost' WITH GRANT OPTION;
Finally, save your changes and exit.
FLUSH PRIVILEGES; EXIT;
Download PrestaShop
At this point, PrestaShop is ready to be downloaded and installed. Use the commands below to download the latest version of PrestaShop.
https://www.prestashop.com/en/download
At the time of this writing, the current version is 1.7.6.5.
Run the commands below to download it.
cd /tmp
wget https://download.prestashop.com/download/releases/prestashop_1.7.6.5.zip
unzip prestashop_*.zip
Then run the commands below to create a PrestaShop directory and extract the downloaded content there.
sudo mkdir -p /var/www/prestashop sudo unzip prestashop.zip -d /var/www/prestashop
After that, run the commands below to set the correct permissions for PrestaShop to function.
Then run the command below to allow the www-data user to own the PrestaShop directory.
sudo chown -R www-data:www-data /var/www/prestashop/ sudo chmod -R 755 /var/www/prestashop/
Configure Nginx
Below is where you configure the Nginx VirtualHost file for the PrestaShop site you’re creating. This file defines how client requests are handled and processed.
Run the commands below to create a new VirtualHost file called Prestashop in the /etc/Nginx/sites-available/ directory.
sudo nano /etc/nginx/sites-available/prestashop
A very good configuration setting for most PrestaShop sites on the Nginx server is below. This configuration should work great.
Copy the content below and save it into the file created above.
server {
listen 80;
listen [::]:80;
root /var/www/prestashop;
index index.php index.html index.htm;
server_name example.com www.example.com;
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;
}
# AlphaImageLoader for IE and fancybox
rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;
# Web service API
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
# Installation sandbox
rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
#Change this block to your admin folder
location /admin_CHANGE_ME {
if (!-e $request_filename) {
rewrite ^/.*$ /admin_CHANGE_ME/index.php last;
}
}
# Source code directories
location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor|var)/ {
deny all;
}
# Prevent exposing other sensitive files
location ~ \.(yml|log|tpl|twig|sass)$ {
deny all;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Save the file and exit.
After saving the file above, run the commands below to enable the new site, then restart the Nginx server.
sudo ln -s /etc/nginx/sites-available/prestashop /etc/nginx/sites-enabled/ sudo systemctl restart nginx.service
At this stage, PrestaShop is ready and can be launched by going to the server’s IP or hostname.
https://example.com
However, if you want to enable SSL or accept web traffic over HTTPS, then you can continue below to install and configure Let’s Encrypt free SSL certificates.
Install Let’s Encrypt Wildcard Certificates
At step 6, PrestaShop is ready to use without SSL. However, if you want to serve web traffic over HTTPS, then installing and configuring Let’s Encrypt SSL certificate or other public certificates is a must.
To install Let’s Encrypt, run the commands below.
sudo apt update sudo apt-get install letsencrypt
The commands above will install the certbot tool and all dependencies that will be allowed to make the tool function.
Let’s Encrypt provides many ways to challenge you to validate that you own the domain you want to provide SSL certificates for. You will not be able to generate certificates if you can’t prove that you own the domain you want to secure.
For wildcard certificates, the only challenge method Let’s Encrypt accepts is the DNS challenge, which we can invoke via the preferred-challenges=dns flag.
So, to generate a wildcard cert for domain *.example.com, you run the commands below:
sudo certbot certonly --manual --preferred-challenges=dns --email admin@example.com --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -d example.com -d *.example.com
The command options above are explained below:
- certonly: Obtain or renew a certificate, but do not install
- –manual: Obtain certificates interactively
- –preferred-challenges=dns: Use dns to authenticate domain ownership
- –server: Specify the endpoint to use to generate
- –agree-tos: Agree to the ACME server’s subscriber terms
- -d: Domain name to provide certificates for
After executing the command above, Let’s Encrypt will provide a text string to add a text record to your DNS entry.
Example:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator manual, Installer None ------------------------------------------------------------------------------- Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about EFF and our work to encrypt the web, protect its users and defend digital rights. ------------------------------------------------------------------------------- (Y)es/(N)o: y Obtaining a new certificate Performing the following challenges: dns-01 challenge for example.com ------------------------------------------------------------------------------- NOTE: The IP of this machine will be publicly logged as having requested this certificate. If you're running certbot in manual mode on a machine that is not your server, please ensure you're okay with that. Are you OK with your IP being logged? ------------------------------------------------------------------------------- (Y)es/(N)o: y ------------------------------------------------------------------------------- Please deploy a DNS TXT record under the name _acme-challenge.example.com with the following value: x4MrZ6y-JqFJQRmq_lGi9ReRQHPa1aTC9J2O7wDKzq8 Before continuing, verify the record is deployed.
Go to your DNS provider portal and add a text record for the string above and save.
Wait a few mins before continuing from the prompt.
Some DNS providers take a wile to propagate changes so it may depend on your provider’s platform.
After the changes above and Let’s Encrypt can validate that you own the domain, you should see a successful message as below:
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/example.com/privkey.pem Your cert will expire on 2020-01-09. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew"
The wildcard certificate is now generated and ready to be used.
To verify that the certificate is ready, run the commands below:
sudo certbot certificates
That should display a similar screen as below:
Found the following certs: Certificate Name: example.com Domains: *.example.com Expiry Date: 2020-01-05 07:48:04+00:00 (VALID: 85 days) Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
Now, Let’s Encrypt’s certificates are valid for 90 days. You’ll want to set up a cron job to automate the renewal process. To do that, open crontab and add the entry below:
sudo crontab -e
Then add the line below and save.
0 1 * * * /usr/bin/certbot renew >> /var/log/letsencrypt/renew.log
Save and you’re done!
With Let’s Encrypt installed, reopen the Nginx VirtualHost file created above and add Let’s Encrypt configurations to secure your website.
Run the commands below and open the file.
sudo nano /etc/nginx/sites-available/prestashop
server { listen 80; listen [::]:80; server_name *.example.com; return 301 https://$host$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; root /var/www/prestashop; index index.php index.html index.htm; server_name example.com www.example.com; if ($host != "example.com") { return 301 https://example.com$request_uri; } ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers 'TLS13+AESGCM+AES128:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:50m; ssl_session_timeout 1d; ssl_session_tickets off; ssl_ecdh_curve X25519:sect571r1:secp521r1:secp384r1; 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; } # AlphaImageLoader for IE and fancybox rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last; # Web service API rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; # Installation sandbox rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last; #Change this block to your admin folder location /admin_CHANGE_ME { if (!-e $request_filename) { rewrite ^/.*$ /admin_CHANGE_ME/index.php last; } } # Source code directories location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor|var)/ { deny all; } # Prevent exposing other sensitive files location ~ \.(yml|log|tpl|twig|sass)$ { deny all; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
Then add the highlighted lines to the VirtualHost file as shown below:
After the above, restart Nginx and PHP 7.4-FPM
sudo systemctl reload nginx sudo systemctl reload php7.4-fpm
Next, open your browser and browse the server domain name. You should see the PrestaShop setup wizard complete. Please follow the wizard carefully.
https://example.com/
The Prestashop installer should begin the setup wizard. Choose the installation language and continue.

Accept the licensing terms, validate that all requirements are met, then continue.

Next, type in the database name, username, and password created above and continue.

After that, your store should be ready.

Delete the install folder.
sudo rm -rf /var/www/html/example.com/install
That’s it!

Conclusion:
Congratulation! You have successfully installed PrestaShop on Ubuntu 18.04 | 20.04. If you find any error above, please use the comment form below to report it.
Thanks,
You may also like the post below:
Hi, I followed your tutorial here to install Prestashop 1.7.6.5 on Ubuntu server 20.04. Everything well fine until the completion of installation. After deleting “install” folder, I got “404 error” on back office (some plain texts are there, but no photos, an error message “The page you are looking for was not found. Sorry for the inconvenience.” shown under Home). At front office, from Chrome I got “This page isn’t workingpresta.wetestweb.site redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS”.
Is there something wrong with nginx conf or https? Thank you guys
It is a prestashop configuration issue. Just run this sql in database.
update ps_configuration set value = 1 where name in (‘PS_SSL_ENABLED’, ‘PS_SSL_ENABLED_EVERYWHERE’);
Hi,
after my experiences Presta 1.7.6.5 is not working with PHP 7.3 or 7.4
There are countless errors in the backend.
Frontend seems to work quite well.
Hi guys,
Kine has a point, Presta 1.7 does not support PHP 7.4 in the PHP compatibility chart they only support until 7.3
https://devdocs.prestashop.com/1.7/basics/installation/system-requirements/#php-compatibility-chart
Another bug on this version is PS_COOKIE_CHECKIP, some functionalities in the back office will redirect you to the login page, you will need to disable this in the database
update ps_configuration set value=0 where name=’PS_COOKIE_CHECKIP’;
Best Regards
Great guide!
As has been said above, the UI apparently doesn’t work with php 7.4. I had to downgrade to 7.3 and everything went fine.
Hi.
I followed this tutorial and the site and backoffice are working fine.
The only issue I get is that when I try to open these pages:
Desing/Theme Catalog
Modules/Modules Catalog/Module Selections
I get a message in the UI: “It looks like we have trouble connecting to Addons. Please refresh the page or check your firewall configuration.”
Enabling debug I get this:
503 Service Unavailable
route name: admin_mbo_catalog_module_selection
and: admin_mbo_catalog_theme
I think is something with the configuration, because in another prestashop installation, it’s working.
Is there something I can check?
Thanks.
In this part, do we must to provide the path of the admin folder in our installation? for example replace this block:
#Change this block to your admin folder
location /admin_CHANGE_ME {
if (!-e $request_filename) {
rewrite ^/.*$ /admin_CHANGE_ME/index.php last;
}
}
by:
#Change this block to your admin folder
location /var/www/prestashop/admin {
if (!-e $request_filename) {
rewrite ^/.*$ /var/www/prestashop/admin/index.php last;
}
}
is this correct? Can anyone provide an example?
I followed all steps one bye one, but for any unknown reason, when I access to myexample.com the web page tells me the certificate is not installed even when the let’s encrypt section was I got no errors
funcionando bien
lo hice con php7.2
y ultima version y no e tenido problemas
It is a good tutorial. The only issue is Prestashop currently doesn’t support php7.4. Therefore, I suggest to change the php version to 7.3.
Great tutorial, thank you.
I ran into a timeout error during the PrestaShop install process. Increasing the max_execution_time of PHP is not enough. The timeout of NGINX needs also adjustment. I added these two in /etc/nginx/nginx.conf (http section)
fastcgi_read_timeout 300;
proxy_read_timeout 300;
What am I doing wrong? Everything installs, I’m able to do the DNS challenge, on the server, nginx was giving errors until I realized I had to tell it where the SSL certs where. Once I did that, it loads fine, but I can’t reach it through HTTPS. I always get errors like:
“ERR_SSL_VERSION_OR_CIPHER_MISMATCH”
“SSL_ERROR_NO_CYPHER_OVERLAP”
I just copied the config files like the instructions said to, I made sure the directory paths were correct, I don’t understand anything about SSL ciphers, so I didn’t change that at all. How do I fix this? DNS challenge appeared to work fine on the server itself once all the directory paths to find the SSL info certbot put on the server were entered.
Why is this so difficult? I’ve been trying for over a year to get this to work, I only got SSL working once with a kemp load balancer but I can’t replicate that success. I don’t have access to port 80, so I needed DNS challenge. Do I have to enter some other characters into the ssl section for ciphers? Do these even get viewed that often?