How to install PrestaShop on Ubuntu 24.04

How to Install PrestaShop on Ubuntu 24.04

Welcome to this step-by-step guide for installing PrestaShop on Ubuntu 24.04! In an era when a powerful, secure online store is essential for business success, choosing the right e-commerce platform makes all the difference. PrestaShop is a robust, open-source solution that offers extensive customization, performance improvements, and enhanced features for building and managing your digital storefront.

This guide provides clear instructions for developers, system administrators, and tech-savvy users ready to deploy PrestaShop on a reliable Ubuntu 24.04 server. Whether you’re launching a new online shop or upgrading an existing one, follow along to ensure a smooth and successful installation.

Prerequisites

Before diving into the installation, ensure you have the following:

  • An Ubuntu 24.04 VPS
  • At least 2GB of RAM
  • SSH root access or a system user with sudo privileges

Step 1: Update System Packages

Start by logging into your Ubuntu 24.04 VPS via SSH:

ssh root@IP_Address -p Port_number

Replace IP_Address and Port_number with your server’s details. If you’re not using the root account, replace root with your sudo user’s username.

Once logged in, update your system packages:

sudo apt-get update -y && sudo apt-get upgrade -y

Step 2: Install Nginx Web Server

PrestaShop requires a web server, and we’ll use Nginx for this purpose. Install Nginx with:

sudo apt install nginx -y

Enable and start the Nginx service:

sudo systemctl enable nginx
sudo systemctl start nginx

Verify the installation:

sudo systemctl status nginx

Step 3: Install MariaDB Database Server

PrestaShop relies on a database to store its data. Install MariaDB:

sudo apt install mariadb-server mariadb-client -y


Enable and start MariaDB:

sudo systemctl enable mariadb
sudo systemctl start mariadb

Verify the installation:

sudo systemctl status mariadb

Step 4: Install PHP and Required Extensions

PrestaShop is built on PHP, so install PHP and its necessary extensions:

sudo apt install php php-{fpm,mysql,common,cli,opcache,readline,mbstring,xml,gd,curl,imagick,gnupg,ldap,imap,zip,bz2,intl,gmp} -y

Step 5: Create a Database for PrestaShop

Log in to the MariaDB console:

sudo mysql -u root

Create a database and user for PrestaShop:

CREATE DATABASE prestashop;
CREATE USER 'prestashop'@'localhost' IDENTIFIED BY 'YourStrongPasswordHere';
GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashop'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace YourStrongPasswordHere with a strong, unique password.

Step 6: Install Composer

To install Composer, begin by downloading the installation script to /tmp/composer-setup.php:

curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php

Next, fetch the official signature and store it in a variable:

HASH=`curl -sS https://composer.github.io/installer.sig`

Verify the script’s integrity with:

php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

If the output says Installer verified, proceed with the system-wide installation:

sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer

Finally, confirm the installation by running:

composer

Step 7: Install Node.js using APT with the PPA method.

Node.js can be installed using the NodeSource repository. Begin by adding the repository:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

After adding the repository, you should see output confirming it’s configured.

2025-12-18 11:45:33 - Repository configured successfully.
2025-12-18 11:45:33 - To install Node.js, run: apt install nodejs -y
2025-12-18 11:45:33 - You can use N|solid Runtime as a node.js alternative
2025-12-18 11:45:33 - To install N|solid Runtime, run: apt install nsolid -y 

Then, update the package list and install Node.js:

sudo apt-get update -y
sudo apt-get install nodejs -y

Once the installation completes, verify the installed version:

node -v

This will display the installed version, such as v20.19.6, confirming the latest version from the NodeSource repository is active.

Step 8: Download Prestashop

Download the latest PrestaShop core files. The latest release is version 9.0.2; you can review other available versions on the official PrestaShop GitHub page.

Move to the /tmp directory and download the release:

cd /tmp
wget https://github.com/PrestaShop/PrestaShop/archive/refs/tags/9.0.2.tar.gz

Uncompress the downloaded file:

tar -zxvf 9.0.2.tar.gz

This will extract a directory named PrestaShop-9.0.2. Move and rename this directory into the web directory:

mv PrestaShop-9.0.2/ /var/www/prestashop/

Finally, set the appropriate ownership for the PrestaShop directory:

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

Step 9: Install Composer dependencies:

Use composer to download the project’s dependencies:

cd /var/www/prestashop
sudo -u www-data /usr/bin/php /usr/local/bin/composer install

Step 10: Install JavaScript and CSS dependencies

PrestaShop uses NPM to manage dependencies and Webpack to compile them into static assets. You can use the following command:

cd /var/www/prestashop
sudo -u www-data make assets

Step 11: Configure Nginx

After installation, nginx will already be running. Next, create an nginx server block (virtual host) for the PrestaShop site:

nano /etc/nginx/sites-enabled/prestashop.conf

Then, paste the following into the file.

server {
    listen 80;


    server_name yourprestashopdomain.com www.yourprestashopdomain.com;


    access_log /var/log/nginx/prestashopdomain.com-access.log combined;
    error_log /var/log/nginx/prestashopdomain.com-error.log info;


    root /var/www/prestashop;


    index index.php;


    client_max_body_size 16M;


    error_page 404 /index.php?controller=404;


    location ~* /\.(?!well-known\/) {
    deny all;
    }


    location ~* ^/\.well-known\/ {
    default_type text/plain;
    }


    rewrite ^/(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$1$2.jpg last;
    rewrite ^/(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
    rewrite ^/(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
    rewrite ^/(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(-[\w-]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
    rewrite ^/c/([\w.-]+)/.+\.jpg$ /img/c/$1.jpg last;
    rewrite ^images_ie/?([^/]+)\.(gif|jpe?g|png)$ js/jquery/plugins/fancybox/images/$1.$2 last;
    rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
    rewrite ^(/install(?:-dev)?/sandbox)/.* /$1/test.php last;


    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }


    location /admin-dev/ {
        try_files $uri $uri/ /admin-dev/index.php$is_args$args;
    }


    location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|var|vendor)/ {
        deny all;
    }


    location ~ ^/modules/.*/vendor/ {
        deny all;
    }


    location ~ \.(log|tpl|twig|sass|yml)$ {
        deny all;
    }


    location /img {
        location ~ \.php$ { deny all; }
    }


    location /upload {
        location ~ \.php$ { deny all; }
    }


    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        try_files $fastcgi_script_name =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_index index.php;
        fastcgi_keep_conn on;
        fastcgi_read_timeout 60s;
        fastcgi_send_timeout 60s;
        fastcgi_buffer_size 256k;
        fastcgi_buffers 256 16k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
    }
}

Save and close the file. Then, verify the nginx configuration for any errors:

nginx -t

If the test passes, restart nginx to apply the changes:

systemctl restart nginx

Step 12. Install SSL Certificate

To enable SSL for the PrestaShop installation, first install the required Certbot package:

apt install python3-certbot-nginx -y

Then, obtain and install the SSL certificate from Let’s Encrypt by running:

certbot

You would need to provide your email address, accept the Let’s Encrypt TOS, and indicate whether you want to share your email address with the Electronic Frontier Foundation or not. Then choose which domain or subdomain you would like to activate HTTPS for. Choose your PrestaShop website by typing the number and hitting ENTER. Let’s Encrypt will install the certificate, and it will ask you whether to configure HTTP to HTTPS redirect or not. You can choose to redirect, then certbot will create the redirection and reload Nginx if everything is okay.

Congratulations! PrestaShop is now installed and secured on your Ubuntu 24.04 server. Run the initial setup at https://yourprestashopdomain.com, configure your shop settings, and begin building your e-commerce site. Enjoy the powerful, flexible, and scalable features of PrestaShop for your online business!

Of course, you don’t have to install PrestaShop on Ubuntu 24.04 if you use one of our PrestaShop Hosting services. Simply ask our expert Linux admins to install and configure PrestaShop on Ubuntu 24.04 for you. They are available 24×7 and will take care of your request immediately.

If you liked this post on how to install PrestaShop on Ubuntu 24.04, please share it with your friends or leave a comment below. Thanks

Leave a Comment