Prestashop is a free and open-source e-commerce solution written in PHP. It allows you to self-hosted and create online stores and grow your online business. Prestashop is a fully-customizable and feature-rich e-commerce solution for building comprehensive eCommerce websites. In the meantime, Prestashop is used by more than 250.000 online stores around the globe and is available in 65 languages.

In this tutorial, we are going to explain how to install an open-source eCommerce solution – Prestashop using the LAMP Stack (Linux, Apache, MySQL/MariaDB, and PHP) on the Ubuntu 22.04 server. This tutorial also includes the basic configuations of LAMP Stack for PHP web applications.

Prerequisite

Here’s what you need to complete this tutorial:

  • An Ubuntu 22.04 server – This tutorial uses an ubuntu server with the hostname ‘server-ubuntu’ and the IP address is ‘192.168.5.100’.
  • A non-root user with root administrative privileges.
  • A domain name pointed to the Ubuntu Server IP address.

Installing Apache Web Server

In the following step, you will install the Apache web server on your Ubuntu system. The Prestashop eCommerce requires at least the Apache web server v2.2. For this installation, you will install Apache v2.4, which is available by default on the Ubuntu repositories.

We always recommend updating and refreshing your repositories before installing any packages. So, run the apt command to update Ubuntu repositories.

sudo apt update

Install the Apache web server using the following apt command. When prompted to confirm the installation, input Y to accept and press ENTER.

sudo apt install apache2

<img alt="install apache2" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/1-install-apache.png6543e1a5f2531.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="264" loading="lazy" src="data:image/svg xml,” width=”750″>

Once the Apache web server is installed, you need to check and verify the ‘apache2‘ service and make sure it’s running. You can use the following systemctl command to check and verify the ‘apache2‘ service.

You will receive an output about the ‘apache2‘ service enabled, which means it will be running automatically at system startup. And the current status of the ‘apache2‘ service is running.

sudo systemctl is-enabled apache2

sudo systemctl status apache2

<img alt="check apache" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/2-check-apache.png6543e1a62ba7e.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="233" loading="lazy" src="data:image/svg xml,” width=”750″>

Lastly, you also need to add the HTTP and HTTPS ports to the UFW firewall. Use the following ufw command to add the custom rule “Apache Full” to the UFW firewall. Then, verify the list of enabled UFW rules.

You will receive an output that the rule “Apache Full” is added to the UFW firewall.

sudo ufw allow "Apache Full"

sudo ufw status

<img alt="setup firewall" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/3-setup-ufw.png6543e1a65f2bf.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="275" loading="lazy" src="data:image/svg xml,” width=”560″>

Installing MariaDB Database Server

Since Prestashop only supports the MySQL/MariaDB database, you will now install this database server on your Ubuntu machine. In this example, you will install and use MariaDB as the database for your Prestashop installation.

Use the following apt command to install the MariaDB database server. Input Y when prompted to confirm the installation, then press ENTER.

sudo apt install mariadb-server

<img alt="install mariadb" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/4-install-mariadb.png6543e1a678ac0.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="313" loading="lazy" src="data:image/svg xml,” width=”750″>

After the MariaDB server is installed, check and verify the ‘mariadb‘ service using the following systemctl command. You should receive an output that the ‘mariadb‘ service is enabled, which means it will be automatically running at system boot. And the status of the ‘mariadb‘ service is ‘running‘.

sudo systemctl is-enabled mariadb

sudo systemctl status mariadb

<img alt="check mariadb" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/5-check-mariadb.png6543e1a692f31.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="372" loading="lazy" src="data:image/svg xml,” width=”750″>

Lastly, you will also need to secure the MariaDB deployment. You can do this via the command-line ‘mysql_secure_installation‘ that is provided by MariaDB server packages.

Run the following ‘mysql_secure_installation‘ to start configuring and securing your MariaDB server deployment.

sudo mysql_secure_installation

You will be prompted with the following questions about the MariaDB server deployment:

  • Switch to unix_socket authentication?. Input n and press ENTER. The default MariaDB root user is already protected. optionally, you can also enable it by typing y for yes.
  • Change the root password?. Input y to confirm and set up your new MariaDB root password.
  • Remove anonymous user?. Input y to confirm.
  • Disallow root login remotely? Input y to confirm. Only local connection will be allowed if you are using the MariaDB root user.
  • Remove test database and access to it?. Input y to confirm and remove the default database ‘test‘.
  • Lastly, input y again to reload all tables privileges on your MariaDB server and apply new changes.

Installing PHP

For the latest version of Prestashop installation, it’s recommended to use at least PHP v7.1. In this demo, you will use PHP 7.4 for the Prestashop, and you can install PHP 7.4 on the latest Ubuntu 22.04 system via third-party repository.

Before installing PHP, run the following apt command to install the basic packages dpendencies for managing repositories.

sudo apt install software-properties-common apt-transport-https -y

Picture

Now add the PHP 7.4 PPA repository to your Ubuntu system via the ‘add-apt-repository’ command below. Also, the following command will automatically update and refresh your Ubuntu repositories.

sudo add-apt-repository ppa:ondrej/php -y

<img alt="install apt tools" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/6-install-apt-tools.png6543e1a6d6123.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="250" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, use the following apt command to install PHP packages with some extensions for the Prestashop. When prompted to confirm the installation, input Y to agree and press ENTER.

sudo apt install php7.4 php7.4-curl php7.4-xmlrpc php7.4-soap php7.4-intl php7.4-zip php7.4-cli php7.4-mysql php7.4-common php7.4-opcache php7.4-memcached php7.4-bcmath php7.4-gd php7.4-mbstring php7.4-xml php7.4-gmp php7.4-imagick

<img alt="install php 7.4" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/7-install-php74.png6543e1a723cce.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="314" loading="lazy" src="data:image/svg xml,” width=”750″>

After PHP is installed, open the PHP config file ‘/etc/php/7.4/apache2/php.ini’ using your text editor. In this example, we will use nano.

sudo nano /etc/php/7.4/apache2/php.ini

Change details PHP configurations as below. Be sure to change the option ‘date.timezone‘ and ‘memory_limit‘ options with your current server environment.

date.timezone = Europe/Paris

max_execution_time = 130

memory_limit = 256M

allow_url_fopen = On

allow_url_include = Off

post_max_size = 128M

upload_max_filesize = 128M

max_input_vars = 5000

Save your changes and close the file when you are finished.

Next, run the following systemctl command below to restart the ‘apache2‘ service. Also, this will apply any changes to the PHP config file ‘php.ini‘.

sudo systemctl restart apache2

Now the Apache web server and PHP should be running. You can verify that by creating the phpinfo file and testing it via the web browser.

Run the following command to create a new phpinfo file ‘/var/www/html/info.php‘. This file should now be accessible via the URL path ‘/info.php’.

cat <<EOF | sudo tee /var/www/html/info.php

<?php

phpinfo();

?>

EOF

Open the web browser and access the phpinfo file via your server IP address followed by the path of the file ‘/info.php’ (http://192.168.5.100/info.php). You should get a page with detailed information about your PHP installation.

<img alt="phpinfo" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/8-phpinfo.png6543e1a764d96.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="414" loading="lazy" src="data:image/svg xml,” width=”750″>

Installing Prestashop System Checker

Before installing Prestashop, let’s install the Prestashop Checker on your current server. This is the PHP script that checks your server environment for the Prestashop installation.

Run the following command to download the Prestashop Checker script to the directory ‘/var/www/html‘.

cd /var/www/html/

wget https://github.com/PrestaShop/php-ps-info/archive/refs/tags/v1.1.tar.gz

Extract the Prestashop Checker source and rename the directory to ‘check-ps‘.

tar -xzvf v1.1.tar.gz

mv php-ps-info-1.1 check-ps

Back to the web browser and visit your server IP address followed by the URL path ‘check-ps’ (i.e: http://192.168.5.100/check-ps/phppsinfo.php).

Log in with the default user and password ‘prestashop‘.

<img alt="prestashop checker" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/9-login-prestasho-checker.png6543e1a78dc67.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="296" loading="lazy" src="data:image/svg xml,” width=”492″>

Now ensure all of your LAMP Stack configurations are met with the Prestashop requirements.

If some settings missing, you can edit the PHP config file ‘/etc/php/8.1/apache2/php.ini‘. Also, you can install PHP extensions if there is an extension missing.

<img alt="php configurations and settings" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/10-php-configurations.png6543e1a7a7cee.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="750" loading="lazy" src="data:image/svg xml,” width=”529″>

Creating MariaDB Database and User

Before you start installing Prestashop, you will need to create a new MariaDB database and user.

Run the following ‘mysql’ command to log in to the MariaDB shell as the MariaDB ‘root‘ user. When prompted for a password, input your password or you can just press ENTER.

sudo mysql -u root -p

Next, run the following queries to create a new database and user for Prestashop. In this example, the database for Prestashop will be ‘prestashopdb‘ with the MariaDB user ‘prestashop‘. You can change the password here with the strong password.

CREATE DATABASE prestashopdb;

GRANT ALL PRIVILEGES ON prestashopdb.* TO 'prestashop'@'localhost' IDENTIFIED BY 'password';

FLUSH PRIVILEGES;

<img alt="create database" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/11-create-db-user.png6543e1a7d47e3.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="133" loading="lazy" src="data:image/svg xml,” width=”750″>

Now run the following queries to verify the privileges for the MariaDB user ‘prestashop@localhost‘. Then, log out from the MariaDB shell. You should receive information about the ‘prestasho@localhost‘ user having privileges for the database ‘prestashopdb‘.

SHOW GRANTS FOR prestashop@localhost;

quit

<img alt="check user privileges" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/12-check-user-privileges.png6543e1a7f292b.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="159" loading="lazy" src="data:image/svg xml,” width=”750″>

Downloading Prestashop Source Code

After created the MariaDB database and user, you will download the Prestashop source code and setup the correct permission and ownership of the prestashp installation directory.

Now run the apt command below to install the ‘unzip‘ package. This will be used to extract the Prestashop source code.

sudo apt install unzip -y

Move the working directory to ‘/var/www/‘ and download the Prestashop source code using the wget command below.

cd /var/www/

wget https://download.prestashop.com/download/releases/prestashop_1.7.8.7.zip

Extract the Prestashop source code to the new directory ‘/var/www/prestashop‘ via the ‘unzip‘ command below.

unzip prestashop_1.7.8.7.zip -d /var/www/prestashop

Now change the ownership of the Prestashop installation directory ‘/var/www/prestashop‘ and change its permission. The ownership should be the user ‘www-data‘and permission is ‘u rw‘ (owner/user can write to the directory).

chown -R www-data:www-data /var/www/prestashop

chmod u rw /var/www/prestashop

Setting Up Apache Virtual Host

All of your dependencies and configurations are ready, and the Prestashop source code is downloaded. Now you will set up the Apache virtual host for your Prestashop installation.

Before you start, ensure you have the domain name pointed to your Ubuntu server IP address and the SSL certificates generated. Also, you must enable some of the Apache2 modules for your Prestashop.

Use the following command to enable Aapche2 modules.

sudo a2enmod ssl rewrite headers

<img alt="enable apache modules" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/13-enable-apache-modules.png6543e1a82f785.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="326" loading="lazy" src="data:image/svg xml,” width=”652″>

Create a new virtual host configuration for Prestashop ‘prestashop.conf‘ using the following command. All Apache2 virtual host files must be located at the ‘/etc/apache2/sites-available/‘ directory.

sudo nano /etc/apache2/sites-available/prestashop.conf

Add the following virtual host configurations for the prestashop. Be sure to change the domain name and the path of SSL certificates.



    ServerName hwdomain.io

    Redirect permanent / https://hwdomain.io/



    ServerAdmin [email protected]

    DocumentRoot /var/www/prestashop

    ServerName hwdomain.io

    Protocols h2 http/1.1

    SSLEngine On

    SSLCertificateFile /etc/letsencrypt/live/hwdomain.io/fullchain.pem

    SSLCertificateKeyFile /etc/letsencrypt/live/hwdomain.io/privkey.pem

   

        Options FollowSymlinks

        AllowOverride All

        Require all granted

   

     ErrorLog /var/log/apache2/prestashop_error.log

     CustomLog /var/log/apache2/prestashop_access.log combined

Save the configuration file when you are finished and close the file.

Next, run the following command to enable the virtual host file ‘prestashop.conf’. Then, verify your configurations.

You should receive an output message such as “Syntax OK” when your configurations have no error.

sudo a2ensite prestashop.conf

sudo apachectl configtest

Now run the following systemctl command to restart the ‘apache2‘ service and apply new changes. And you can start the installation wizard for Prestashop via the web browser.

sudo systemctl restart apache2

<img alt="configure apache virtual host prestashop" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/14-configure-prestashop-virtual-host.png6543e1a845b84.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="226" loading="lazy" src="data:image/svg xml,” width=”750″>

Installing Prestashop via Web Installer

Back to your web browser and browse the domain name of your Prestashop installation (i.e: https://hwdomain.io/). You should see the web installer is starting the Prestashop installation.

<img alt="start web installer" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/15-prestashop-installer.png6543e1a87c4fa.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="614" loading="lazy" src="data:image/svg xml,” width=”750″>

Select the default language for your PrestaShop installation and click Next. The default installation language for PrestaShop is ‘English‘.

<img alt="select language" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/16-select-language.png6543e1a893cac.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="432" loading="lazy" src="data:image/svg xml,” width=”750″>

Click agree when showed the Prestashop License agreement page.

<img alt="license agreement" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/17-agree-license.png6543e1a8b3c71.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="440" loading="lazy" src="data:image/svg xml,” width=”750″>

Now create a new admin user for your Prestashop installation. Input details admin user, email, and password. Then, click Next to continue to the database configurations.

<img alt="store configurations" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/18-store-configurations.png6543e1a8cc991.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="721" loading="lazy" src="data:image/svg xml,” width=”750″>

For the store content, you can select ‘No” and click ‘Next‘.

<img alt="store content" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/19-store-content.png6543e1a8f0595.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="446" loading="lazy" src="data:image/svg xml,” width=”750″>

For the Prestashop database configuration. Input details database user, database name, and the password that you have created. Then, click Next and the Prestashop installation will be starting.

<img alt="database configuration" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/20-database-configurations.png6543e1a93dd6e.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="561" loading="lazy" src="data:image/svg xml,” width=”750″>

Below you can see the installation is processed.

<img alt="installation processed" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/21-installation-starting.png6543e1a968652.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="465" loading="lazy" src="data:image/svg xml,” width=”750″>

When the Prestashop installation is finished, you will see the page that informs you about your Prestashop installation. Also, there is an additional change that you should do, which is deleting the ‘install‘ directory on your Prestashop document root.

<img alt="installation finished" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/22-installation-finished.png6543e1a9b3029.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="589" loading="lazy" src="data:image/svg xml,” width=”750″>

Back to your terminal server and run the following command to make some of the Prestashop directory writable and delete the Prestashop ‘install‘ directory.

chmod u rw /var/www/prestashop/var/cache

chmod u rw /var/www/prestashop/var/logs

chmod u rw /var/www/prestashop/img

chmod u rw /var/www/prestashop/mails

chmod u rw /var/www/prestashop/modules

chmod u rw /var/www/prestashop/translations

chmod u rw /var/www/prestashop/upload

chmod u rw /var/www/prestashop/download

chmod u rw /var/www/prestashop/app/config

chmod u rw /var/www/prestashop/app/Resources/translations

rm -rf /var/www/prestashop/install

Back to the web browser and click the button ‘Manage your store‘ to access the Prestashop administration login. You will be redirected to the new Prestashop login page, and be sure to copy the path of your Prestashop admin URL.

Input the admin user and password for your Prestashop and click ‘LOG IN‘.

<img alt="prestashop admin login" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/23-admin-login.png6543e1a9cc9bb.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="750" loading="lazy" src="data:image/svg xml,” width=”660″>

You will get the administration dashboard of Prestashop.

<img alt="prestashop admin dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/11/echo/24-admin-dashboard.png6543e1aa41b2b.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="493" loading="lazy" src="data:image/svg xml,” width=”750″>

At this point, you have finished the installation of the open-source eCommerce solution Prestashop on Ubuntu 22.04.

Conclusion

Throughout this tutorial, you have learned how to install the eCommerce solution Prestashop on an Ubuntu 22.04 server. You have also learned the basic installation and configuration of the LAMP Stack (Apache, MariaDB, and PHP) on the Ubuntu system and learned the how to secure MariaDB server and setup Apache virtual host.

Ultimately, you have the Prestashop eCommerce solution running with LAMP Stack on an Ubuntu server and secured via SSL certificates. You can now add your themes for your customization and add plugins to extend your eCommerce website. Then, you can add your products.