How to Install PrestaShop on Ubuntu 20.04 with Apache

PrestaShop is an open-source e-commerce application. It is written in PHP and offers many built-in themes. The application offers a fully responsive design to the end-user. Translated in many languages, and supports all the major payment services.

PrestaShop is highly customizable and provides many built-in add-ons to help the sellers customize their online shops.

There are two distinct ways to set up PrestaShop. You can host it yourself on your server and have full access to the data and configuration files, or open an online account at the official website.

In this tutorial, you will learn how to install PrestaShop on Ubuntu 20.04 with Apache.

Step 1: Install LAMP Server

PrestaShop is written in PHP and so it requires a LAMP or LEMP stack to run. LAMP is composed of Linux, Apache, MariaDB, and PHP. If your preferred database is MYSQL, you can use it as well.

First, update the Ubuntu system - this will update the package index:

$ sudo apt update

To install PHP and additional PHP extensions, type:

$ sudo apt install php php-cli php-common php-curl php-zip php-gd php-mysql php-xml php-mbstring php-json php-intl libapache2-mod-php

Prestashop supported PHP 7.1 and above. On Ubuntu 20.04, PHP 7.4 is available in the repository. The configuration file is located at /etc/php/7.4/apache2/php.ini.

Consider changing the below PHP derivatives in php.ini file. Refer to PrestaShop basic system requirement page for more information.

memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M

To install Apache2 webserver, type:

$ sudo apt install apache2

Enable mod_rewrite module for Apache2, type:

$ sudo a2enmod rewrite

For the changes to take effect - restart Apache2:

$ sudo systemctl  restart apache2

To install MariaDB database server type:

$ sudo apt install mariadb-server

To improve the security of MariaDB installation, type:

$ sudo mysql_secure_installation

This will allow you to set a password for the root user, remove anonymous users, disallow root login remotely and remove the test database.

Step 2: Create Database for PrestaShop

PrestaShop supports relational databases such as MySQL or MariaDB.Here we are going to use MariaDB.

To login to the MariaDB database management system, type:

$ sudo mysql -u root -p

Let's create a database for Prestashop. To create a new database named presta_shop on MariaDB shell:

mysql> create database presta_shop;

To create a user for the database type:

mysql> create user 'prestashop_user'@'localhost' identified by 'password';

To grant the whole privileges to the user for the presta_shop database type:

mysql> grant all privileges on presta_shop.* to  `prestashop_user`@localhost;

To make the change effective by reloading the grant tables:

mysql> flush privileges;

Then exit the MySQL shell:

mysql> exit;

Step 3: Download PrestaShop on Ubuntu

The latest version of PrestaShop is available to download from their website. As of writing this tutorial, the latest version available is Prestashop 1.7.7.5.

You can download the PrestaShop installation zip using the wget command:

$ wget https://github.com/PrestaShop/PrestaShop/releases/download/1.7.7.5/prestashop_1.7.7.5.zip

Unzip the files to the public directory:

$ unzip prestashop_1.7.7.5.zip -d /var/www/html/root-prestashop

Let's give the document root directory proper ownership and permissions.

$ sudo chown -R www-data:www-data /var/www/html/root-prestashop/
$ chmod -R 755 /var/www/html/root-prestashop

Step 4: Create Virtual Host file on Apache

Virtual host file specifies the configuration of your domain. Apache comes with a default virtual configuration file named 000-default.conf. You can either use that or create a new file.

Here we are going to create a new virtual host file:

$ sudo vim /etc/apache2/sites-available/prestashop.conf

Paste the following in the configuration file:

<VirtualHost *:80> 
ServerAdmin admin@your_example.com 
ServerName your_example.com 
DocumentRoot /var/www/html/root-prestashop 
<Directory /var/www/html/root-prestashop> 
Options +FollowSymlinks 
AllowOverride All 
Require all granted 
</Directory> 
ErrorLog /var/log/apache2/prestashop-error_log 
CustomLog /var/log/apache2/prestashop-access_log common 
</VirtualHost>

Change your_example.com do your domain name and save the configuration file.

To enable the configuration, type:

$ sudo a2ensite prestashop.conf
$ sudo systemctl reload apache2

Step 5: Complete installation of PrestaShop

To start the installation of PrestaShop, navigate to the URL through the web browser. For SSL configuration you either use free Let's Encrypt or a vendor certificate.

http://your_example.com/

Once you enter your domain, the installation of Prestashop starts.

installation start page
installation start page

Enter your preferred language and click the Next button.

Choose your language
Choose your language

Accept the license agreement by enabling the check box

Agree to license agreements
Agree to license agreements

Next, add information about your Store such as Shop name, country, timezone, account name, email address, account password. Remember this email address and password is used for admin access to the PrestaShop dashboard.

Add store information
Add store information

In this step, provide your database information which we created in step 2.

Provide database information
Provide database information

Now, wait for the system to configure.

Once finished, it will display the user name and password to log in - ie the account details which you provided earlier.

installation finished
installation finished

Before start using Prestashop make sure to delete the temporary installation directory - this is for security reasons.

$ sudo rm -Rf /var/www/html/root-prestashop/install

Now you can log in to the PrestaShop application either by clicking the "Manage your store" or using the Sign in button on the home page.

Prestashop Dashboard
Prestashop Dashboard

Conclusion

In this tutorial, we learned how to install PrestaShop on Ubuntu 20.04 with Apache. Prestashop is easy to install and configure, lets us know your experience using it.

Leave a Comment