How to Install PrestaShop on Ubuntu 16.04
Updated by Linode Contributed by Alexandru Andrei
What is PrestaShop?
If you’ve ever thought about opening an online store, you may have felt overwhelmed by variety of free, open-source ecommerce solutions available. While having so many options means that there is almost certainly an available and effective solution for your particular situation, it can also be confusing for newcomers. One of those options, the subject of this guide, is PrestaShop, a comprehensive ecommerce solution used by thousands of merchants around the world.
PrestaShop’s ecommerce breadth can make it seem daunting to learn; however, its menus are neatly structured, terms are intuitive, and interface is easily navigable. In addition, customizing your website with PrestaShop’s many What You See Is What You Get (WYSIWYG) tools makes for a user-friendly set up, without having to inspect and edit source code. Also, PrestaShop comes with many out-of-the-box features and plug-ins that streamline setup and use.
Installing Prestashop on a remote server is more involved and time-consuming than using cloud hosting, but the rewards are greater: you will have better performance, since you have conserved server resources, and greater flexibility, with the freedom to tweak your settings as you see fit. You won’t ever have to wait for a cloud-host support team to change PHP settings for you. Furthermore, high availability, load balancing, advanced backup schemes, and other features become easily accessible, allowing you to scale your business and increase your site’s reliability.
Before You Begin
Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.
This guide will use
sudowherever possible. Complete the sections of our Securing Your Server to create a standard user account, harden SSH access and remove unnecessary network services.
Update your system:
sudo apt-get update && sudo apt-get upgrade
In order to obtain a free SSL certificate from Let’s Encrypt, you will need to buy a Fully Qualified Domain Name (FQDN) and set it to point to your Linode. See our DNS Manager Overview guide for more information.
NoteThroughout this guide, replace
example.comwith the public IP address or Fully Qualified Domain Name (FQDN) of your Linode.
In most cases, you can start out with an Ubuntu 16.04 instance with 1GB of RAM. As your online store grows, keep an eye on your memory usage; scale to a bigger Linode when necessary. If your business becomes especially large, it may be a good idea to separate your store across at least three servers: one that runs Apache and hosts the PHP code running the ecommerce platform, one for the database, and one for storing static content, like .jpg images.
Install Apache and MariaDB
This guide will run PrestaShop on a modified LAMP stack using MariaDB instead of MySQL. You can read more about MariaDB and its features here. If you would prefer to use a traditional LAMP stack, please see our guide, How to Install a LAMP Stack on Ubuntu 16.04.
Install Apache, PHP, and MariaDB:
sudo apt-get install apache2 libapache2-mod-php mariadb-server
Use the following command to secure your MariaDB installation:
This script will ask a series of questions. You can leave the first question (for MariaDB’s root password blank), then choose ‘n’ (“No”) to decline to create a new root password. Answer ‘y’ (Yes) for the remaining questions.
The next step is to create a basic configuration file for Apache, telling it where it will find your website files and what your domain name is. Start by copying the default config file to use it as a template:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
Edit the configuration file. Uncomment the
example.comwith your Linode’s domain name or IP address, and edit the remaining lines as follows:
1 2 3 4 5 6
. . . ServerName example.com ServerAdmin firstname.lastname@example.org DocumentRoot /var/www/html/example.com . . .
Create the directory for our website files:
sudo mkdir /var/www/html/example.com
Disable the default configuration file and enable the newly created one:
sudo a2dissite 000-default.conf sudo a2ensite example.com.conf
sudo systemctl restart apache2.service
Allow PrestaShop to Use .htaccess Files
PrestaShop can make use of
.htaccess files. This allows it to automatically adjust Apache’s settings and makes it possible to enable advanced features such as “pretty links,” web page compression, or https redirects from the administration backend (PrestaShop’s admin page).
- Edit the config file to enable .htaccess overrides:
1 2 3
<Directory /var/www/html/example.com> AllowOverride All </Directory>
Install TLS (SSL) Certificate to Encrypt Website Traffic
Obtaining an SSL certificate for your store will help keep your customers’ data secure, and will avoid Google search ranking penalties for sites that don’t use
https. It is not possible to complete this step using the public IP address of a Linode; you need to have a FQDN that is already listed in the DNS servers.
Check to see if your domain name has propagated to the DNS servers:
dig @220.127.116.11 example.com
You should receive a response that looks like this:
example.com 36173 IN A 203.0.113.10
If the A value is equal to the IP address of your server, you can continue. Otherwise, check the DNS configuration of your Linode, and then repeat this step after a few minutes.
Add the official Personal Package Archive (PPA) of the Let’s Encrypt Team, update the package repository, and install certbot:
sudo apt-get install software-properties-common sudo add-apt-repository ppa:certbot/certbot sudo apt-get update sudo apt-get install python-certbot-apache
Request and install the TLS certificate:
sudo certbot --apache
When asked if you want https redirection answer 2.
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. ------------------------------------------------------------------------------- 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. ------------------------------------------------------------------------------- Select the appropriate number [1-2] then [enter] (press 'c' to cancel):
Make sure https is working correctly before continuing. You do this by navigating to
https://example.comin your web browser.
Since certificates expire after 90 days, it’s a good idea to set up automatic renewal:
sudo crontab <<< "33 3 * * Sat /usr/bin/certbot renew -q"
Prepare Environment for PrestaShop and Install Dependencies
Set ownership of
/var/www/html/example.com to allow PrestaShop to enable plug-ins, automatic updates, and other features.
sudo chown www-data: /var/www/html/example.com/
You can also use:
chown -R www-data * chgrp -R www-data *
Download and Unzip PrestaShop’s Files
Change the working directory to where the website’s code will be installed:
Download the zip archive containing all of the necessary files. At the time of writing this tutorial, the latest version was
18.104.22.168. Check this website for the newest version available: PrestaShop’s Download Page and change the link in the following command so that it reflects the current release:
sudo curl -O https://download.prestashop.com/download/releases/prestashop_22.214.171.124.zip
sudo apt-get install unzip
Decompress the zip archive:
sudo unzip prestashop_126.96.36.199.zip
Install and Configure PrestaShop Dependencies
Install PrestaShop’s PHP dependencies:
sudo apt-get install php7.0-curl php7.0-gd php7.0-mysql php7.0-zip php7.0-xml php7.0-intl
These modules allow PrestaShop to download content, process images, access the database, unzip files, process XML data, and access internationalization functions.
Enable the Apache
sudo a2enmod rewrite
sudo systemctl restart apache2.service
PrestaShop makes use of a SQL database to store information about products, users, categories and so on. Log in as the superuser (root) to MariaDB:
Create a database and a user with the appropriate permissions. Replace
choose_passwordbelow. Record the information for later use.
CREATE DATABASE your_database_name; CREATE USER 'prestashop_user'@'localhost' IDENTIFIED BY 'choose_password'; GRANT ALL ON your_database_name.* TO 'prestashop_user'@'localhost'; exit
https://example.comin a browser. Be sure to include the
httpsso your connection is secure.
An install wizard will guide you through the setup process. When prompted, fill in the database credentials you set up earlier. Leave the first field as it is: 127.0.0.1. The table prefix can be left unchanged as well.
Test your connection to the database server.
After clicking Next the installer will create the necessary tables and finalize setting up the store. You will see a page that looks something like this:
cd /var/www/html/example.com sudo rm -r install prestashop_188.8.131.52.zip
Optimize Prestashop and Enable TLS/SSL
Enable https redirection. In the PrestaShop backend, in the far-left menu, look for CONFIGURE. Click on Shop Parameters under it.
Choose YES for Enable SSL and Enable SSL on all pages. Scroll down and click Save.
If you can’t switch on Enable SSL on all pages, try again after enabling SSL and saving your settings.
Go back to the left menu, and as your mouse pointer hovers on top of Shop Parameters you’ll see a submenu pop up. Click on Traffic and SEO. Scroll down until you find the settings pictured below:
Select YES for Friendly URL and 301 Moved Permanently for Redirect to the canonical URL. Save your settings.
Out of the box, PrestaShop includes some features that help it render pages faster for your clients. You can access these from the far-left menu. Under CONFIGURE, hover over Advanced Parameters and click on Performance in the submenu that opens up. Select Recompile templates if the files have been updated under Template compilation and YES for Cache. This will activate Smarty cache and decrease the need for your server to compile parts of the PHP code, decreasing load times for the frontend. The final settings should look like this:
Scroll down until you find CCC (COMBINE, COMPRESS AND CACHE). Switch everything there to YES. Save your settings.
/etc/php/7.0/apache2/php.iniin a text editor and look for the following three settings:
1 2 3
memory_limit = 128M upload_max_filesize = 2M max_execution_time = 30
upload_max_filesizeto 10M to enable uploading of larger images. The other two settings don’t need to be changed at this point, but if your site’s memory usage increases or you install a plug-in whose scripts run slowly, you may want to consider increasing
sudo systemctl restart apache2.service
Set Up Mail Delivery
Setting up mail delivery in PrestaShop is vital because so much happens through email: customer account confirmations, subscriptions, delivery statuses, order confirmations, etc. Although an email server like this one can be hosted on a Linode, it can be complicated to set up and maintain.
It’s also possible to use an all-in-one solution like Mail-in-a-Box, but the easiest approach is to use a dedicated solution like Google’s G Suite or Fastmail. This way you can focus on maintaining your store and get dependable email service without worrying about the technical details.
Once you have decided on an email provider, configure PrestaShop’s email system: in the left menu, under CONFIGURE, hover over Advanced Parameters and click E-mail in the submenu. Once the page loads, look for Set my own SMTP parameters (for advanced users ONLY).
New options will appear further down in the page:
Now that you have PrestaShop up and running, you can begin to customize the site to meet the needs of your store. The official PrestaShop site has a list of modules that can be installed to add features such as online chat, SEO optimization, and product statistics. It is also important to maintain the security of your site. Make sure to frequently update PrestaShop, any installed modules or plug-ins, as well as your Linode system.
Join our Community
This guide is published under a CC BY-ND 4.0 license.