How to Install PrestaShop on Ubuntu 18.04
PrestaShop is a unfastened and open-supply e-commerce platform. It is based on PHP and MySQL and may be extended with unfastened and top class plugins and subject matters.
With functions like intuitive administrative interface, more than one fee gateways, multi-lingual, analytic and reporting, PrestaShop is a platform of choice for many on line merchants.
In this educational, we are able to show you the way to deploy PrestaShop on Ubuntu 18.04 server. We’ll be using Nginx as a web server, the modern PHP 7.2 and MySQL/MariaDB as a database server.
Prerequisites
Ensure that you have met the following prerequisites earlier than continuing with this educational:
Have a site call pointing for your public server IP. We will use instance.Com.
Nginx is installed on your Ubuntu server with the aid of following these commands .
An SSL certificate hooked up for your area to encrypt person’s statistics. You can install a loose Let’s Encrypt SSL certificate by way of following those commands .
Update the system applications to the modern day variations and installation the unzip application :
sudo apt update && sudo apt upgrade
sudo apt install unzip
Creating a MySQL Database
PrestaShop shops its information in a MySQL database.
If MySQL or MariaDB is mounted for your server you may skip this step. Otherwise, install the MySQL five.7 server bundle from the Ubuntu’s default repositories with the aid of typing:
sudo apt install mysql-server mysql-client
For clean MySQL installations, it's miles recommended to run the mysql_secure_installation command to enhance the security of your MySQL server.
To create a database, log in to the mysql shell:
sudo mysql
From in the MySQL shell, run the subsequent SQL announcement to create a brand new database named prestashop:
CREATE DATABASE prestashop;
Next, create a MySQL person account named prestashop and grant the necessary permissions to the user via strolling the subsequent command:
GRANT ALL ON prestashop.* TO 'prestashop'@'localhost' IDENTIFIED BY 'change-with-strong-password';
Don’t forget to trade change-with-robust-password with a robust password.
Once finished, go out the MySQL console via typing:
EXIT;
Installing and Configuring PHP
PHP 7.2 is the default PHP model in Ubuntu 18.04, and it's miles fully supported and recommended for PrestaShop.
Run the following command to put in 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 set up method is complete the PHP-FPM provider will routinely start. You can confirm it via typing:
sudo systemctl status php7.2-fpm
The output must 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)
Run the subsequent sed instructions to set the encouraged 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 brand new strong model of PrestaShop is version 1.7.6.2.
Download the trendy version of PrestaShop from the PrestaShop Downloads Page using the subsequent wget command :
cd /tmp
wget https://download.prestashop.com/download/releases/prestashop_1.7.6.2.zip
When the down load is complete, create a listing in an effort to hold our PrestaShop documents:
sudo mkdir -p /var/www/html/example.com
Next, extract the PrestaShop archive :
unzip prestashop_*.zip
This archive consists of any other zip document “prestashop.Zip”, which contains all the PrestaShop documents. Extract the documents into the area’s document root directory:
sudo unzip prestashop.zip -d /var/www/html/example.com
Set the perfect permissions so that the webserver may have full get right of entry to to the web site’s files and directories the use of the subsequent chown command:
sudo chown -R www-data: /var/www/html
Configuring Nginx
By now, you need to already have Nginx with an SSL certificate set up to your Ubuntu server. If now not, test the prerequisites for this educational.
Open your textual content editor and create the following file:
sudo nano /etc/nginx/sites-available/example.com
/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 update example.Com along with your PrestaShop domain, and “admin_CHANGE_ME” along with your admin directory. You can discover the listing name by means of list the content of the Prestashop root listing:
sudo ls -l /var/www/html/example.Com make sure you operate the ideal direction to the SSL certificates documents. The snippets used in this configuration are created on this manual .
Before restarting the Nginx provider take a look at the configuration for syntax mistakes:
sudo nginx -t
The output should appear to be 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 way of typing:
sudo systemctl restart nginx
Installing PrestaShop
Now that PrestaShop is downloaded and the server configuration is complete, you can finish the set up via the web interface.
Open your browser, kind your area, and a display much like the following will appear:
Install PrestaShop language
Select the language you would love to apply and click at the “Next” button.
On the following screen, you'll be provided with the PrestaShop license settlement. Read the license and pick “I agree to the above terms and situations.” to keep:
Next, you will see the following facts page:
Make certain all pre-set up requirements are met, and your gadget is compatible with PrestaShop.
On the following display screen, you’ll want to go into your shop details. The e-mail deal with is the username to get admission to the PrestaShop administration backend.
Next, the setup wizard will ask you to enter your database connection information. Enter the MySQL person and database info you formerly created:
Click on the “Next” button, and the installation will start:
The installation may additionally take a few minutes, once finished the following web page will display, informing you that PrestaShop has been set up.
For protection motives, you’ll need to delete the set up directory. To achieve this, pass returned to the terminal and enter the following rm command:
sudo rm -rf /var/www/html/example.com/install
To get admission to your PrestaShop administrative dashboard, click on on the “Manage your store” button. Enter your email and password, and you will be redirected to the administration dashboard.
From right here, you could start customizing your PrestaShop set up and upload new products.
Conclusion
You have efficaciously mounted PrestaShop on your Ubuntu 18.04 server. PrestaShop Documentation is a good beginning vicinity to learn extra approximately a way to manipulate your PrestaShop set up.
If you've got questions, sense loose to depart a comment under.