PrestaShop is an open-source e-commerce platform that lets you run your own online store or store on the Internet. It is very well known and runs over 300000 online stores around the world. It is programmed in PHP and uses MySQL/MariaDB as its database backend. With Prestashop you can offer your ideas and products and sell them on the internet. It offers numerous themes, modules and extensions with which you can extend the functionality of your store.

In this article we will show you how to install PrestaShop on Ubuntu 22.04.

Requirements

  • A server running Ubuntu 22.04.
  • A root password is set up on the server.

Install Apache, MariaDB and PHP

First install the Apache and MariaDB server using the command below:

apt install apache2 mariadb-server -y

By default, Ubuntu 22.04 ships with PHP 8.1 version, but PrestaShop does not support PHP 8.1 version. Therefore, you need to install PHP 7.4 version with other extensions on your server.

First, install all the required dependencies using the following command:

apt install software-properties-common ca-certificates lsb-release apt-transport-https

Next, add the PHP repository using the following command:

add-apt-repository ppa:ondrej/php

Once the PHP repository is added, run the following command to install PHP 7.4 with all required extensions:

apt install php7.4 libapache2-mod-php7.4 php7.4-zip php7.4-xml php7.4-gd php7.4-curl php7.4-intl php7.4-xmlrpc php7.4-mbstring php7.4-imagick php7.4-mysql unzip -y

Once PHP and the other required dependencies are installed, edit the PHP default configuration file:

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

Change the following lines:

memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
date.timezone = UTC

Save and close the file and restart the Apache service to apply the changes:

systemctl restart apache2

Create a database for PrestaShop

Next, you need to create a database and a user for PrestaShop. First, log in to the MariaDB shell with the following command:

mysql

Once you are logged in, create a database and a user with the following command:

MariaDB [(none)]> CREATE DATABASE prestashop;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashop'@'localhost' IDENTIFIED BY 'password';

Next, clear the permissions and exit the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Install PrestaShop

First, go to the PrestaShop Git Hub page and download the latest version of PrestaShop using the following command:

wget https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.7/prestashop_1.7.8.7.zip

Once the download is complete, unzip the downloaded file to the PrestaShop directory:

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

Next, change the ownership and permission for the PrestaShop directory:

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

Create an Apache virtual host for PrestaShop.

Next, you need to create a configuration file for an Apache virtual host for PrestaShop. You can create it with the following command:

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

Add the following configurations:

   ServerAdmin [email protected]
   DocumentRoot /var/www/html/prestashop
   ServerName prestashop.example.com

   
        Options FollowSymlinks
        AllowOverride All
        Require all granted 
   
ErrorLog ${APACHE_LOG_DIR}/prestashop_error.log
CustomLog ${APACHE_LOG_DIR}/prestashop_access.log combined

Save and close the file when you are done. Then activate PrestaShop and enable the Apache header module with the following command:

a2ensite prestashop
a2enmod rewrite headers

Then restart the Apache service to apply the changes:

systemctl restart apache2

Next, check the status of the Apache service with the following command:

systemctl status apache2

You will get the following output:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-08-15 04:14:12 UTC; 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 35363 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 35367 (apache2)
      Tasks: 6 (limit: 2242)
     Memory: 21.5M
        CPU: 108ms
     CGroup: /system.slice/apache2.service
             ??35367 /usr/sbin/apache2 -k start
             ??35368 /usr/sbin/apache2 -k start
             ??35369 /usr/sbin/apache2 -k start
             ??35370 /usr/sbin/apache2 -k start
             ??35371 /usr/sbin/apache2 -k start
             ??35372 /usr/sbin/apache2 -k start

Aug 15 04:14:12 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...

Perform PrestaShop Web Installation

Now PrestaShop is installed and configured with Apache. Now open your web browser and access the PrestaShop web installation using the URL http://prestashop.example.com . You should see the language selection screen:

How to Install PrestaShop with Let’s Encrypt SSL on Ubuntu 22.04 linux ubuntu

Select your language and click the Next button. You should see the license agreement screen:

How to Install PrestaShop with Let’s Encrypt SSL on Ubuntu 22.04 linux ubuntu

Accept the license agreement and click the ” Next” button. You should see the Site Information screen:

How to Install PrestaShop with Let’s Encrypt SSL on Ubuntu 22.04 linux ubuntu

How to Install PrestaShop with Let’s Encrypt SSL on Ubuntu 22.04 linux ubuntu

Enter your site information, username and password and click the Next button. You should see the database configuration screen:

How to Install PrestaShop with Let’s Encrypt SSL on Ubuntu 22.04 linux ubuntu

Enter your database information and click the Next button. Once the installation is complete, you should see the following screen:

How to Install PrestaShop with Let’s Encrypt SSL on Ubuntu 22.04 linux ubuntu

Now remove your installation folder using the following command:

rm -rf /var/www/html/prestashop/install/

Next, click the Manage your store button. You should see the login screen for the PrestaShop backend:

How to Install PrestaShop with Let’s Encrypt SSL on Ubuntu 22.04 linux ubuntu

Enter your email address and password and click the LOG IN button. You should see the PrestaShop dashboard:

How to Install PrestaShop with Let’s Encrypt SSL on Ubuntu 22.04 linux ubuntu

Secure PrestaShop with Let’s Encrypt.

Next, you need to install the Certbot client package to install and manage Let’s Encrypt SSL.

First, install Certbot using the following command:

apt-get install certbot python3-certbot-nginx -y

Once the installation is complete, run the following command to install Let’s Encrypt SSL on your website:

certbot --nginx -d prestashop.example.com

You will be prompted to provide a valid email address and accept the terms of service (see below):

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for prestashop.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/prestashop.conf

Next, select whether or not to redirect HTTP traffic to HTTPS (see below):

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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): 2

Type 2 and press Enter to complete the installation. You should see the following output:

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/prestashop.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://prestashop.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=prestashop.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/prestashop.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/prestashop.example.com/privkey.pem
   Your cert will expire on 2022-11-16. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

Conclusion

Congratulations! You have successfully installed PrestaShop with Apache and Let’s Encrypt SSL. Now you can host your own online store on the Internet and start selling your products. If you have any questions, feel free to contact me.