Prestashop is a free and open-source e-commerce solution written in PHP. It allows you to create online stores, self-host, and grow your online business.
Prestashop is a fully customizable and feature-rich e-commerce solution for building comprehensive e-commerce 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 guide, you’ll learn how to install Prestashop on the Ubuntu 24.04 server with the LAMP Stack (Linux, Apache, MySQL/MariaDB, and PHP) and Composer.
Prerequisites
To start with this guide, make sure you have the following:
- An Ubuntu 24.04 server.
- A non-root user with administrator privileges.
- A domain name pointed to a server IP address.
Installing dependencies
To install Prestashop, you must install dependencies on your system. In this example, you’ll install the LAMP Stack (Linux, Apache, MySQL/MariaDB, and PHP), Composer, and Git packages.
Firstly, run the command below to update your Ubuntu package index.
sudo apt update
Now run the following command to install the LAMP Stack (Linux, Apache, MySQL/MariaDB, and PHP), Composer, and Git as dependencies for Prestashop. Input Y
to proceed with the installation.
sudo apt install apache2 mariadb-server composer git php php-curl php-xmlrpc php-soap php-intl php-zip php-cli php-mysql php-common php-opcache php-memcached php-bcmath php-gd php-mbstring php-xml php-gmp php-imagick
After the installation is complete, check the Apache web server status with the following:
sudo systemctl is-enabled apache2
sudo systemctl status apache2
You can see below the Apache web server is running and enabled.
Check the MariaDB server status with the command below:
sudo systemctl is-enabled mariadb
sudo systemctl status mariadb
You will see a similar output, the MariaDB server is running and enabled on your system.
Now check the PHP version and list enabled extensions with the following:
php -v
php -m
In the output below, you can see PHP 8.3 are installed with some extensions fileinfo
, gd
, and opcache
also enabled.
Lastly, check the Composer and Git version with the command below – You will see Composer 2.7.1 are installed.
sudo -u www-data composer --version
Setting up PHP
Now that you’ve installed dependencies for Prestashop, you’ll configure PHP by editing the php.ini
file and changing some default options as needed for Prestashop.
Open the default PHP configuration file /etc/php/8.3/apache2/php.ini
with the following nano editor
command.
sudo nano /etc/php/8.3/apache2/php.ini
Change the default configuration with the following. Adjust the option for date.timezone
and memory_limit
with your server environment.
date.timezone = Europe/Amsterdam
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 and exit the file when you’re done.
Now run the command below to restart the Apache web server and apply your new PHP configuration.
sudo systemctl restart apache2
Setting up MariaDB server
In this section, you’ll secure the MariaDB server and create a new database and user for Prestashop. You’ll secure MariaDB with the mariadb-secure-installation
command, then create a new database and user through the mariadb
client.
To secure your MariaDB server, run the mariadb-secure-installation
command below:
sudo mariadb-secure-installation
After the command is executed, you’ll be asked about the following configurations:
- 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 users? 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 the test database and access it. Input y to confirm and remove the default database ‘test’.
- Lastly, input y again to reload all table privileges on your MariaDB server and apply new changes.
Now that you’ve secured and configured the MariaDB server, you’ll create a new database and user for Prestashop with the mariadb
client.
Log in to the MariaDB server as root
with the mariadb
command below. Input your root
password when prompted.
sudo mariadb -u root -p
Now run the following queries to create a new database prestashopdb
, and a new user prestashop
, with the password p4ssword
. Make sure to change detailed information with yours.
CREATE DATABASE prestashopdb;
CREATE USER prestashop@localhost IDENTIFIED BY 'p4ssword';
GRANT ALL PRIVILEGES on prestashopdb.* TO prestashop@localhost;
FLUSH PRIVILEGES;
Next, run the query t below to ensure user prestashop
can access the database prestashopdb
.
SHOW GRANTS FOR prestashop@localhost;
In the output below, you can see user prestashop
can access the database prestashopdb
.
Lastly, type quit
to exit from the MariaDB server.
Checking server environment
After you’ve configured both PHP and MariaDB, you’ll ensure that your server is ready for the Prestashop installation. You’ll be using the Prestashop checker to ensure your server is ready.
Go to the /var/www/html
directory and download the Prestashop checker with the wget
command below.
cd /var/www/html
wget https://github.com/PrestaShop/php-ps-info/archive/refs/tags/v1.1.tar.gz
Run the following command to extract the Prestashop checker source code and rename the extracted directory to ps-check
.
tar -xf v1.1.tar.gz
mv php-ps-info-1.1 ps-check
Now visit http://server-ip/ps-check/phppsinfo.php with your web browser. Log in with the default user and password prestashop
and make sure that your server is ready for the Prestashop installation.
Downloading Prestashop
Now that your server is ready, you can install PrestaShop with Composer or download manually via wget. In this example, you’ll download Prestashop manually.
Create a new /var/www/prestashop
directory with the following:
mkdir -p /var/www/prestashop
Go to the /var/www/prestashop
directory and download the Prestashop source code with the wget
command below. Make sure to check the Prestasho GitHub page to get the latest version.
cd /var/www/prestashop wget https://github.com/PrestaShop/PrestaShop/releases/download/8.1.6/prestashop_8.1.6.zip
Extract the Prestashop source code with the unzip
command below.
unzip prestashop_8.1.6.zip
Now run the following command to change the permission and ownership of the Prestashop installation directory /var/www/prestashop
.
sudo chown -R www-data:www-data /var/www/prestashop
sudo chmod u+rw /var/www/prestashop
Setting up Apache virtual host
In this section, you’ll create a new virtual host file for Prestashop. So make sure that you’ve your domain name pointed to the Prestashop server IP address.
Run the command below to enable Apache modules rewrite
, headers
, and ssl
.
sudo a2enmod rewrite headers ssl
Create a new virtual host configuration /etc/apache2/sites-available/prestashop.conf
with the nano
editor.
sudo nano /etc/apache2/sites-available/prestashop.conf
Add the following configuration. Make sure to change the ServerName
option with your domain name.
ServerName hwdomain.com
ServerAdmin [email protected]
DocumentRoot /var/www/prestashop
# enable the .htaccess rewrites
AllowOverride All
Options +Indexes
Require all granted
# Disable back office token
# SetEnv _TOKEN_ disabled
ErrorLog /var/log/apache2/prestashop_error.log
CustomLog /var/log/apache2/prestashop_access.log combined
Save and exit the file when done.
Next, run the command below to enable the prestashop.conf
file and verify your Apache syntax. If you’ve the correct syntax, you’ll get an output Syntax is OK
.
sudo a2ensite prestashop.conf
sudo apachectl configtest
Lastly, run the command below to restart the Apache web server and apply your changes.
sudo systemctl restart apache2
Securing Prestashop with HTTPS
In this guide, you’ll secure Prestashop with HTTPS through Certbot and Letsencrypt. You need to install Certbot to generate SSL/TLS certificates from Letsencrypt. You also need an email address for that.
Install the certbot
and python3-certbot-apache
package with the command below. Enter Y
to confirm the installation.
sudo apt install certbot python3-certbot-apache
Now run the certbot
command below to generate SSL certificates and secure prestashop with HTTPS. Make sure to change the email address and domain name.
sudo certbot --apache --agree-tos --no-eff-email --redirect --hsts --staple-ocsp --email [email protected] -d hwdomain.io
After the process is complete, your Prestashop will be secured with HTTPS, and your SSL certificates will be available at the /etc/letsencrypt/live/domain. conf
directory.
Installing Prestashop
Visit your Prestashop domain name, such as http://hwdomain.io, using a web browser. You will see the Prestashop installation wizards.
Select your language, such as English, and click Next.
Click Agree to accept the Prestashop License agreement.
Enter your shop information and the new admin user and password for your Prestashop installation. Then, click Next again.
You can install demo data and additional modules in your Prestashop. Then click Next again.
Enter the details of your MariaDB database and click Next to continue the installation.
After the installation is complete, you will see the following. Click Discover your store to see the Prestashop home page or Manage your store to access the prestashop admin page.
Before accessing the Prestashop admin page, back to the terminal and run the command below to delete the /install
directory.
sudo rm -rf /var/www/prestashop/install
Conclusion
Congratulations! You’ve installed Prestashop on the Ubuntu 24.04 server. You’ve Prestashop running with the LAMP Stack and secured with HTTPS through Certbot and letsencrypt.