How to Install PrestaShop on Ubuntu 18.04
Updated on
•6 min read

PrestaShop is a free and open-source e-commerce platform. It is based on PHP and MySQL and can be extended with free and premium plugins and themes.
With features like intuitive administrative interface, multiple payment gateways, multi-lingual, analytic and reporting, PrestaShop is a platform of choice for many online merchants.
In this tutorial, we will show you how to install PrestaShop on Ubuntu 18.04 server. We’ll be using Nginx as a web server, the latest PHP 7.2 and MySQL/MariaDB as a database server.
Prerequisites
Ensure that you have met the following prerequisites before continuing with this tutorial:
- Have a domain name pointing to your public server IP. We will use
example.com
. - Nginx is installed on your Ubuntu server by following these instructions .
- An SSL certificate installed for your domain to encrypt user’s information. You can install a free Let’s Encrypt SSL certificate by following these instructions .
Update the system packages to the latest versions and install the unzip utility :
sudo apt update && sudo apt upgrade
sudo apt install unzip
Creating a MySQL Database
PrestaShop stores its information in a MySQL database.
If MySQL or MariaDB is installed on your server you can skip this step. Otherwise, install the MySQL 5.7 server package from the Ubuntu’s default repositories by typing:
sudo apt install mysql-server mysql-client
mysql_secure_installation
command to improve the security of your MySQL server.To create a database, log in to the mysql shell:
sudo mysql
From within the MySQL shell, run the following SQL statement to create a new database
named prestashop
:
CREATE DATABASE prestashop;
Next, create a MySQL user account named prestashop
and grant the necessary permissions to the user
by running the following command:
GRANT ALL ON prestashop.* TO 'prestashop'@'localhost' IDENTIFIED BY 'change-with-strong-password';
change-with-strong-password
with a strong password.Once done, exit the MySQL console by typing:
EXIT;
Installing and Configuring PHP
PHP 7.2 is the default PHP version in Ubuntu 18.04, and it is fully supported and recommended for PrestaShop.
Run the following command to install PHP and all required PHP modules:
sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap
Once the installation process is complete the PHP-FPM service will automatically start. You can verify it by typing:
sudo systemctl status php7.2-fpm
The output should look something like this:
* 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 2019-03-24 11:53:33 PDT; 14s ago
Docs: man:php-fpm7.2(8)
Main PID: 15853 (php-fpm7.2)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
Run the following sed
commands to set the recommended PHP options:
sudo sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/zlib.output_compression = .*/zlib.output_compression = on/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/max_execution_time = .*/max_execution_time = 18000/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" /etc/php/7.2/fpm/php.ini
Downloading PrestaShop
At the time of writing this article, the latest stable version of PrestaShop is version 1.7.6.2
.
Download the latest version of PrestaShop from the PrestaShop Downloads Page using the following wget command :
cd /tmp
wget https://download.prestashop.com/download/releases/prestashop_1.7.6.2.zip
When the download is complete, create a directory which will hold our PrestaShop files:
sudo mkdir -p /var/www/html/example.com
Next, extract the PrestaShop archive :
unzip prestashop_*.zip
This archive contains another zip file “prestashop.zip”, which contains all the PrestaShop files. Extract the files into the domain’s document root directory:
sudo unzip prestashop.zip -d /var/www/html/example.com
Set the correct permissions so that the webserver can have full access to the site’s files and directories using the following chown
command:
sudo chown -R www-data: /var/www/html
Configuring Nginx
By now, you should already have Nginx with an SSL certificate installed on your Ubuntu server. If not, check the prerequisites for this tutorial.
Open your text editor and create the following file:
sudo nano /etc/nginx/sites-available/example.com
server {
listen 80;
listen 443 ssl http2;
server_name example.com www.example.com;
root /var/www/html/example.com;
index index.php;
# SSL parameters
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;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;
# Cloudflare / Max CDN fix
location ~* \.(eot|otf|ttf|woff(?:2)?)$ {
add_header Access-Control-Allow-Origin *;
}
# Do not save logs for these
location = /favicon.ico {
auth_basic off;
allow all;
log_not_found off;
access_log off;
}
location = /robots.txt {
auth_basic off;
allow all;
log_not_found off;
access_log off;
}
# Images
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.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$5.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$6.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$7.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$8.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$9.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$10.jpg last;
rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;
# 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;
}
}
# File security
# .htaccess .DS_Store .htpasswd etc
location ~ /\. {
deny all;
}
# 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;
}
# Prevent injection of php files
location /upload {
location ~ \.php$ {
deny all;
}
}
location /img {
location ~ \.php$ {
deny all;
}
}
# PHP FPM part
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
Don’t forget to replace example.com with your PrestaShop domain, and “admin_CHANGE_ME” with your admin directory. You can find the directory name by listing the content of the Prestashop root directory:
sudo ls -l /var/www/html/example.com | grep admin
Also make sure you use the correct path to the SSL certificate files. The snippets used in this configuration are created in this guide .
Before restarting the Nginx service check the configuration for syntax errors:
sudo nginx -t
The output should look like this:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Finally, restart the Nginx service by typing:
sudo systemctl restart nginx
Installing PrestaShop
Now that PrestaShop is downloaded and the server configuration is complete, you can finish the installation through the web interface.
Open your browser, type your domain, and a screen similar to the following will appear:

Select the language you would like to use and click on the “Next” button.
On the next screen, you will be presented with the PrestaShop license agreement. Read the license and select “I agree to the above terms and conditions.” to continue:

Next, you will see the following information page:

Make sure all pre-installation requirements are met, and your system is compatible with PrestaShop.
On the next screen, you’ll need to enter your store details. The email address is the username to access the PrestaShop administration backend.

Next, the setup wizard will ask you to enter your database connection details. Enter the MySQL user and database details you previously created:

Click on the “Next” button, and the installation will start:

The installation may take a few minutes, once completed the following page will show, informing you that PrestaShop has been installed.

For security reasons, you’ll need to delete the installation directory. To do so, go back to the terminal and enter the following rm
command:
sudo rm -rf /var/www/html/example.com/install
To access your PrestaShop administrative dashboard, click on the “Manage your store” button. Enter your email and password, and you will be redirected to the administration dashboard.
From here, you can start customizing your PrestaShop installation and add new products.
Conclusion
You have successfully installed PrestaShop on your Ubuntu 18.04 server. PrestaShop Documentation is a good starting place to learn more about how to manage your PrestaShop installation.
If you have questions, feel free to leave a comment below.