Websites & apps

Install PrestaShop on a Linux VPS with Nginx and PHP-FPM

Set up PrestaShop 8 on an Ubuntu or AlmaLinux VPS with Nginx, PHP-FPM and MariaDB, including the right PHP extensions, an Nginx config, SSL and post-install security.

IntermediateLinux VPS3 min read

PrestaShop is a popular open-source shop platform. On a VPS you control PHP, caching and the database, which helps once the catalogue grows. This guide installs PrestaShop 8 on a Linux VPS with Nginx, PHP-FPM and MariaDB.

Before you start

  • A VPS with at least 2 GB RAM running Ubuntu 22.04/24.04 or AlmaLinux 9, and root or sudo access.
  • A working LEMP stack. If you do not have one yet, follow install a LEMP stack first.
  • A domain whose A record points to the VPS IP.
  • Prefer shared hosting? See install PrestaShop on cPanel.

Install the PHP extensions PrestaShop needs

PrestaShop 8 supports PHP 7.2–8.1. Use PHP 8.1 for the best compatibility. On Ubuntu:

sudo apt install php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-intl php8.1-mbstring php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap unzip

Then raise the limits in /etc/php/8.1/fpm/php.ini:

memory_limit = 256M
upload_max_filesize = 32M
post_max_size = 32M
max_execution_time = 300
max_input_vars = 5000

Restart PHP-FPM with sudo systemctl restart php8.1-fpm. Missing extensions are covered in install and enable PHP extensions.

Create the database

sudo mysql -e "CREATE DATABASE prestashop CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'ps_user'@'localhost' IDENTIFIED BY 'StrongPasswordHere'; GRANT ALL ON prestashop.* TO 'ps_user'@'localhost'; FLUSH PRIVILEGES;"

Download PrestaShop

  1. Download the latest release zip from the official PrestaShop GitHub releases page into /tmp.
  2. Unzip it. The release contains a second archive, prestashop.zip; extract that into the web root:
sudo mkdir -p /var/www/shop && cd /tmp && unzip prestashop_8*.zip && sudo unzip prestashop.zip -d /var/www/shop
sudo chown -R www-data:www-data /var/www/shop

On AlmaLinux the web user is usually nginx instead of www-data.

Configure Nginx

Create /etc/nginx/sites-available/shop.conf:

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

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ /(app|bin|cache|classes|config|var|vendor)/ {
        deny all;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    }
}

Enable it and reload:

sudo ln -s /etc/nginx/sites-available/shop.conf /etc/nginx/sites-enabled/ && sudo nginx -t && sudo systemctl reload nginx

Add SSL

Issue a free certificate before running the installer so the shop is created with HTTPS URLs:

sudo certbot --nginx -d shop.example.com

Details are in Certbot and Let's Encrypt on a Linux server.

Run the web installer

  1. Open https://shop.example.com. The installer starts automatically.
  2. Pick the language, accept the licence and fix anything the compatibility check flags.
  3. Enter the shop name, country and admin account.
  4. For the database, use server 127.0.0.1, database prestashop, user ps_user and your password. Click Test your database connection now.
  5. Wait for the install to finish.

Secure the installation

  • Delete the installer: sudo rm -rf /var/www/shop/install.
  • PrestaShop renames the admin folder to a random name. Bookmark that URL and do not share it.
  • In Shop Parameters → General, enable SSL on all pages.
  • In Advanced Parameters → Performance, set debug mode off and enable smarty cache and CCC for production.

Troubleshooting

  • 404 on every page except the home page: the try_files line is missing, or friendly URLs were enabled before Nginx was configured.
  • 500 error during install: check /var/log/nginx/error.log and var/logs inside the shop; it is usually a missing extension or low memory_limit.
  • Uploads fail: raise client_max_body_size in Nginx and upload_max_filesize in PHP together.

FAQ

Which PHP version should I use for PrestaShop 8?

PHP 8.1 is the newest version PrestaShop 8.x supports officially, and it is the best choice. Check the release notes before you use a newer PHP.

How much RAM does a PrestaShop VPS need?

2 GB is a practical minimum for a small shop. Add RAM as you add products, modules and traffic, and add swap as a safety net.

Can I use Apache instead of Nginx?

Yes. PrestaShop ships a .htaccess file that Apache and LiteSpeed read automatically, so friendly URLs work without extra rules.

How do I back up the shop?

Back up the /var/www/shop folder and dump the database regularly, as described in MySQL backups with mysqldump.

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.