How To

Install PrestaShop on Ubuntu 24.04 with Nginx

PrestaShop is a free, open-source e-commerce platform built on PHP and MySQL/MariaDB. It powers over 300,000 online stores worldwide and provides a full-featured shopping cart with product management, payment gateways, shipping modules, and a marketplace of themes and add-ons. PrestaShop 9 is the latest major release with support for PHP 8.1 through 8.4 and a modernized Symfony-based architecture.

Original content from computingforgeeks.com - post 4494

This guide walks through installing PrestaShop 9.0.3 on Ubuntu 24.04 LTS with Nginx as the web server, MariaDB as the database backend, and PHP 8.3 from the default Ubuntu repositories. By the end, you will have a fully working PrestaShop store secured with a free Let’s Encrypt SSL certificate. For the full list of requirements, see the PrestaShop 9 system requirements documentation.

Prerequisites

Before starting, make sure you have the following in place:

  • A server running Ubuntu 24.04 LTS with at least 2 GB RAM and 20 GB disk space
  • Root or sudo access
  • A registered domain name pointed to your server’s public IP address (for SSL)
  • Ports 80 (TCP) and 443 (TCP) open in your firewall

Switch to the root user before proceeding. All commands in this guide assume root access.

sudo -i

Update the package index and upgrade installed packages to start from a clean baseline.

apt update && apt upgrade -y

Step 1: Install PHP 8.3 and Required Extensions

Ubuntu 24.04 ships PHP 8.3 in its default repositories, which meets PrestaShop 9’s requirement of PHP 8.1 or newer. Install PHP-FPM along with every extension PrestaShop needs.

apt install -y php8.3-fpm php8.3-mysql php8.3-curl php8.3-gd php8.3-intl php8.3-mbstring php8.3-xml php8.3-zip php8.3-iconv php8.3-fileinfo php8.3-opcache php8.3-cli

Adjust a few PHP settings that PrestaShop requires. Open the PHP-FPM configuration file.

vi /etc/php/8.3/fpm/php.ini

Find and update the following directives. PrestaShop recommends at least 512 MB of memory and needs allow_url_fopen enabled for payment modules and remote API calls.

memory_limit = 512M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
allow_url_fopen = On

Restart PHP-FPM to apply the changes and verify the service is running.

systemctl restart php8.3-fpm
systemctl enable php8.3-fpm

Check that PHP-FPM is active and listening for connections.

systemctl status php8.3-fpm

The output should show active (running), confirming PHP-FPM is ready to process requests.

Step 2: Install MariaDB Database Server

Ubuntu 24.04 includes MariaDB 10.11 in its default repositories. This version is fully compatible with PrestaShop 9. Install the server and client packages.

apt install -y mariadb-server mariadb-client

Start and enable the MariaDB service so it runs on boot.

systemctl start mariadb
systemctl enable mariadb

Run the security hardening script to set a root password, remove anonymous users, and disable remote root login.

mariadb-secure-installation

Answer the prompts: set a strong root password, then answer Y to all remaining questions to remove test databases and reload privileges.

Step 3: Create a Database for PrestaShop

Log in to the MariaDB shell and create a dedicated database and user for PrestaShop.

mariadb -u root -p

Run the following SQL commands to create the database, user, and grant all necessary privileges. Replace StrongPassword123 with your own secure password.

CREATE DATABASE prestashop CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'prestashop'@'localhost' IDENTIFIED BY 'StrongPassword123';
GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashop'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 4: Install Nginx Web Server

Nginx serves as the web server and handles all HTTP requests for PrestaShop. Install it from the default Ubuntu repositories.

apt install -y nginx

Start and enable the service so it launches automatically on boot.

systemctl start nginx
systemctl enable nginx

Verify Nginx is running.

systemctl status nginx

You should see active (running) in the output, confirming Nginx is ready to serve content.

Step 5: Download and Install PrestaShop 9

PrestaShop 9 uses Composer for installation – there is no standalone zip download like older versions. First, install Composer and the required build tools.

apt install -y composer unzip git curl

Create the web root directory and use Composer to download PrestaShop 9.0.3. The create-project command pulls the release and all its PHP dependencies in one step.

composer create-project prestashop/prestashop /var/www/prestashop 9.0.3 --no-dev

This downloads the PrestaShop source code to /var/www/prestashop and installs all required PHP packages through Composer. The process takes a few minutes depending on your server’s internet speed.

PrestaShop 9 also needs frontend assets (JavaScript and CSS) built with Node.js. Install Node.js 20.x from the NodeSource repository.

curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs

Build the frontend assets.

cd /var/www/prestashop && make assets

Set the correct file ownership so Nginx and PHP-FPM can read and write to the PrestaShop directory.

chown -R www-data:www-data /var/www/prestashop
find /var/www/prestashop -type d -exec chmod 755 {} \;
find /var/www/prestashop -type f -exec chmod 644 {} \;

Step 6: Configure Nginx Virtual Host for PrestaShop

Create a new Nginx server block for your PrestaShop domain. Replace shop.example.com with your actual domain name throughout this configuration.

vi /etc/nginx/sites-available/prestashop

Add the following configuration. This server block handles PHP processing through PHP-FPM, sets security headers, and configures URL rewriting for PrestaShop’s friendly URLs.

server {
    listen 80;
    server_name shop.example.com;
    root /var/www/prestashop;
    index index.php;

    # Logs
    access_log /var/log/nginx/prestashop_access.log;
    error_log /var/log/nginx/prestashop_error.log;

    # Max upload size - matches PHP upload_max_filesize
    client_max_body_size 64M;

    # Gzip compression for faster page loads
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml;

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;

    # Cache static files for 30 days
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
        expires 30d;
        access_log off;
    }

    # Deny access to hidden files
    location ~ /\. {
        deny all;
    }

    # Block access to sensitive PrestaShop directories
    location ~ /(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|var|vendor)/ {
        deny all;
    }

    # PHP processing via PHP-FPM
    location ~ \.php$ {
        include snippets/fastcgi-params.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_read_timeout 300;
    }

    # PrestaShop friendly URL rewriting
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
}

Enable the site by creating a symlink and remove the default Nginx configuration to avoid conflicts.

ln -s /etc/nginx/sites-available/prestashop /etc/nginx/sites-enabled/
rm -f /etc/nginx/sites-enabled/default

Test the Nginx configuration for syntax errors before reloading.

nginx -t

If the test passes with syntax is ok and test is successful, reload Nginx to apply the new configuration.

systemctl reload nginx

Step 7: Run the PrestaShop Web Installer

Open your browser and navigate to your domain to launch the PrestaShop installer.

http://shop.example.com

The installer walks you through several screens:

  • Language selection – choose your preferred language for the installation process
  • License agreement – accept the Open Software License
  • System compatibility – the installer checks PHP version, extensions, and file permissions. All items should show green if the previous steps were done correctly
  • Store information – enter your shop name, country, and create an admin account with email and password
  • Database configuration – enter the credentials created in Step 3:
  • Database server: 127.0.0.1
  • Database name: prestashop
  • Database user: prestashop
  • Database password: the password you set in Step 3
  • Table prefix: ps_ (default)

Click “Test your database connection” to verify the credentials work, then proceed with the installation. The installer creates all database tables and installs the default theme. Once finished, you will see a success page with links to your storefront and the admin panel (back office).

Step 8: Configure SSL with Let’s Encrypt

A production store must run on HTTPS to protect customer data and payment information. Install Certbot with the Nginx plugin to get a free SSL certificate from Let’s Encrypt.

apt install -y certbot python3-certbot-nginx

Request the certificate. Certbot automatically modifies your Nginx configuration to enable HTTPS and set up a redirect from HTTP to HTTPS.

certbot --nginx -d shop.example.com

Follow the prompts to enter your email address and agree to the terms. When asked about redirecting HTTP to HTTPS, choose the redirect option to force all traffic over SSL.

Verify the certificate auto-renewal timer is active. Certbot sets up a systemd timer that renews certificates before they expire.

systemctl status certbot.timer

The timer should show active (waiting), meaning automatic renewal is scheduled and will run before the certificate expires.

After SSL is active, update PrestaShop to use HTTPS. Log in to the admin panel and go to Configure > Shop Parameters > Traffic & SEO. Enable SSL on all pages and update the shop URL to use https://.

Step 9: Configure UFW Firewall

Ubuntu 24.04 uses UFW (Uncomplicated Firewall) by default. Allow HTTP, HTTPS, and SSH traffic to keep the server accessible while blocking everything else.

ufw allow OpenSSH
ufw allow 'Nginx Full'
ufw enable

The Nginx Full profile opens both port 80 (HTTP) and port 443 (HTTPS). Verify the firewall rules are in place.

ufw status

The output should list OpenSSH and Nginx Full as ALLOW from anywhere, confirming the firewall is configured correctly.

Step 10: Post-Installation Cleanup and Security

PrestaShop’s installer leaves behind an install directory that must be removed before the store goes live. This directory is a security risk if left accessible – anyone could re-run the installer and overwrite your database and configuration.

rm -rf /var/www/prestashop/install

Rename the admin directory to a custom name that is harder to guess. Replace admin-secure with your preferred admin panel path.

mv /var/www/prestashop/admin /var/www/prestashop/admin-secure

Your admin panel is now accessible at https://shop.example.com/admin-secure instead of the default predictable path.

Verify the storefront loads correctly by opening your domain in a browser. You should see the default PrestaShop theme with sample products. Access the admin panel through your renamed admin URL to start managing products, orders, payment methods, and store settings.

Conclusion

You now have PrestaShop 9.0.3 running on Ubuntu 24.04 with Nginx, MariaDB, and a valid SSL certificate. The store is ready for product setup, theme customization, and payment gateway configuration through the admin panel.

For production use, set up automated database backups with mariadb-dump on a cron schedule, configure Nginx rate limiting to prevent brute-force attacks on the admin login, and monitor PHP-FPM process usage to tune the pool size based on your traffic volume. Keep PrestaShop, its modules, and PHP packages updated to patch security vulnerabilities as they are disclosed.

Related Articles

Ubuntu Configure Postfix to Relay Email Through Gmail SMTP on Ubuntu 24.04 / 22.04 Ubuntu Disable systemd-networkd on Ubuntu Linux Arch Linux Checking TCP Connections States in Linux with Netstat Web Hosting How To Install Multiple PHP versions on cPanel

Leave a Comment

Press ESC to close