How to Install PrestaShop with Nginx on Ubuntu 24.04
This guide installs PrestaShop on Ubuntu 24.04 with Nginx as the web server, MariaDB as the database and PHP-FPM to run the code. Ubuntu 24.04 is the operating system, and Nginx serves the pages quickly so your shop stays responsive. The guide covers Nginx, MariaDB, the database and user, PHP-FPM, the PrestaShop files, the Nginx virtual host, a free Let’s Encrypt certificate and the browser installer.
Before you start, you need a running Ubuntu 24.04 server, root or sudo access, and basic comfort with the command line. A domain name that points to the server’s IP address makes the SSL step much easier. Without one, you can still test the store by IP address. Run every command in the terminal, and read each output before moving on to the next section.
Install Nginx and MariaDB using apt commands. Create a PrestaShop database and user in MariaDB. Finally, configure PHP-FPM to serve your PrestaShop installation.
Install Nginx HTTP server on Ubuntu
Nginx is the web server that hands your store’s pages to visitors. It is the first piece to install, because every later step depends on it. From a terminal, update the package list with sudo apt update, then install the server with sudo apt install nginx.
To do that, open the Ubuntu terminal and run the commands in the block below. The first refreshes the package list. The second installs Nginx. If apt asks you to confirm, type Y and press Enter.
sudo apt update
sudo apt install nginx
Ubuntu normally starts Nginx as soon as it is installed. Still, you should know how to control it, so use the commands in the block below to start it, stop it, and enable it so it starts automatically every time the server boots. The enable command is the one that matters after a reboot. Without it, your shop stays offline until someone starts Nginx by hand.
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl enable nginx
Now test the web server. Open a browser on any computer that can reach the server and browse to the server’s IP address. If you are working on the server itself, use localhost instead.
http://localhost

When you see "Welcome to nginx!" the Nginx HTTP server has been installed and is serving pages.
If the page does not load, check two things. First, make sure Nginx is actually running. Second, check whether a firewall, either on the server or at your hosting provider, is blocking port 80. You will also need port 443 open later for HTTPS.
Additional help on installing Nginx on Ubuntu is in the link below.
Install MariaDB database server on Ubuntu
MariaDB is the database server that stores everything about your shop: products, customers, orders and settings. It is installed from the standard Ubuntu package repository, so the process is the same as for Nginx. You install the package, make sure the service runs, and confirm you can log in.
To install and use the MariaDB database server, use the instructions below.
Open the Ubuntu terminal and run the commands in the block below to install the MariaDB database server.
sudo apt update sudo apt install mariadb-server
Once MariaDB is installed, use the commands in the block below to stop it, start it, and enable it so it starts automatically when the server boots. As with Nginx, the enable command keeps the database available after a reboot. A shop whose database is down will show errors on every page.
sudo systemctl stop mariadb sudo systemctl start mariadb sudo systemctl enable mariadb
Next, run the commands in the block below to check that MariaDB installed correctly and that you can reach it.
sudo mariadb
After you run these commands, you are logged on to the MariaDB console. You should see a welcome message similar to the one below.
Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 32 Server version: 10.11.2-MariaDB-1 Ubuntu 23.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]>
That message tells you the server is installed and running. The exact version number depends on what Ubuntu 24.04 currently packages, so it may not match the example.
Additional help on installing MariaDB.
- How to install MariaDB on Ubuntu Linux
- MariaDB without password prompt
Create a PrestaShop database
PrestaShop should have its own database and its own database user. That keeps your store data and its permissions separate from anything else on the server. You do this at the MariaDB prompt with a few SQL statements.
You will create a database named prestashopdb and a user account called prestashopdbuser.
Then you will grant prestashopdbuser full access to the prestashopdb database. The user gets rights on this database only, not on the whole server.
All of this can be done with the commands in the blocks below. Work through them in order.
First, log on to the MariaDB database server:
sudo mariadb
Then run the commands in the next block to create the database, the user and the permissions:
CREATE DATABASE prestashopdb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER prestashopdbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON prestashopdb.* TO prestashopdbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Before you run them, replace type_your_password_here with your own password. Pick a strong one, and write it down along with the database and user names. You will type all three into the PrestaShop installer later.
Install PHP-FPM on Ubuntu
PHP-FPM (FastCGI Process Manager) runs the PHP code that powers PrestaShop. Nginx cannot run PHP itself, so it passes PHP requests to PHP-FPM and sends the result back to the visitor. You install PHP-FPM together with the extensions PrestaShop needs, using a single apt install command.
Run the commands in the block below to install PHP-FPM and its extensions.
sudo apt install php-fpm php-intl php-mysql php-curl php-cli php-zip php-xml php-gd php-common php-mbstring php-xmlrpc php-sqlite3 php-soap php-zip
Ubuntu 24.04 installs PHP 8.3 by default. Before you go further, check which PHP versions your PrestaShop release supports. Look at its system requirements on the PrestaShop site. If a missing extension is flagged later in the installer's requirements check, install it and reload the installer page.
Additional help on installing PHP
Download PrestaShop files
The PrestaShop package holds the code for your storefront and the admin panel. You download it to the /tmp directory with wget, unzip it, and move the files into the web root that Nginx serves.
First, go to the /tmp directory and download the PrestaShop files. After unzipping the file, move the contents into a PrestaShop folder inside the Nginx root directory. Use a separate folder so the files stay apart from the default Nginx page.
The last step in this section is to set ownership and permissions. This lets the Nginx web server, which runs as the www-data user on Ubuntu, read and write the files it needs. PrestaShop must write to some folders during installation and while it runs, and this step is what makes that possible. Setting permissions only as tightly as needed also keeps the site safer.
PrestaShop releases new versions regularly, so the download link in the commands may be out of date. Get the current link from the official download page and replace the link in the commands with the new one. That way you get the latest features and security fixes.
cd /tmp/ wget https://assets.prestashop3.com/dst/edition/corporate/8.1.5/prestashop_edition_classic_version_8.1.5.zip unzip prestashop_*.zip sudo unzip prestashop.zip -d /var/www/prestashop sudo chown -R www-data:www-data /var/www/prestashop/
With the files in place, configure Nginx to serve the PrestaShop content. This is done with a virtual host, also called a server block. It tells Nginx which domain to answer for, where the files are, and how to pass PHP files to PHP-FPM.
Run the command in the block below to create a Nginx virtual host file for PrestaShop. It opens a new, empty file in your editor.
sudo nano /etc/nginx/sites-available/prestashop.conf
Then copy the content block below and paste it into the file.
server {
listen 80;
listen [::]:80;
index index.php;
root /var/www/prestashop;
server_name prestashop.example.com www.prestashop.example.com;
access_log /var/log/nginx/example.com-access.log combined;
error_log /var/log/nginx/example.com-error.log info;
# Redirect 404 errors to PrestaShop.
error_page 404 /index.php?controller=404;
# Watch out: if you encounter issues with a quick view or shopping cart, you might want to use a different rule:
# rewrite '^/((?!js|qq)[a-z]{2})/(.*)' /index.php?isolang=$1&$args last;
# Images.
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;
# AlphaImageLoader for IE and FancyBox.
rewrite ^images_ie/?([^/]+).(gif|jpe?g|png)$ js/jquery/plugins/fancybox/images/$1.$2 last;
# Web service API.
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
# Installation sandbox.
rewrite ^(/install(?:-dev)?/sandbox)/.* /$1/test.php last;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# Source code directories.
location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|var|vendor)/ {
deny all;
}
# vendor in modules directory.
location ~ ^/modules/.*/vendor/ {
deny all;
}
# Prevent exposing other sensitive files.
location ~ .(log|tpl|twig|sass|yml)$ {
deny all;
}
# Prevent injection of PHP files.
location /img {
location ~ .php$ { deny all; }
}
location /upload {
location ~ .php$ { deny all; }
}
location ~ [^/].php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Before you save, check two things in the block. The server name must be your own domain name or the server's IP address. The PHP-FPM socket path must match the PHP version you installed, which is 8.3 on a default Ubuntu 24.04. A wrong value in either place is the most common reason for a 502 Bad Gateway error or a site that does not respond. Then save the file.
Now activate the virtual host and restart Nginx with the commands in the blocks below. The restart makes Nginx load the new configuration for your PrestaShop site. If Nginx fails to restart, there is usually a typo in the file you just saved. The error message names the line, so fix it and restart again.
sudo ln -s /etc/nginx/sites-available/prestashop.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service
Setup Let's Encrypt SSL/TLS for PrestaShop
Let's Encrypt issues free certificates that turn on HTTPS. HTTPS encrypts the traffic between your visitors and the server, which protects logins and payment details. It also matters for customer trust, since browsers warn about shops that are not secure. Certbot is the tool that requests the certificate and sets up Nginx to use it, including redirecting plain HTTP to HTTPS.
The certificate needs a real domain name that already points to your server, and ports 80 and 443 must be open. You cannot get a certificate for a bare IP address.
Please read the post below for more on installing and creating Let's Encrypt SSL certificates for Nginx.
How to set up Let's Encrypt SSL certificate for Nginx on Ubuntu Linux
Once Nginx has been restarted, open your browser and browse to the server hostname or IP address you set in the Nginx server block. If you set up the certificate, use the https:// address.
http://prestashop.example.com
The PrestaShop installation wizard should appear. Choose your installation language from the list and click Next. If the wizard shows a license agreement page, tick the box to accept it and click Next again.

The next page checks that your server meets PrestaShop's requirements. Confirm that every item shows as OK, then click Next. If something is flagged, it is usually a missing PHP extension or a folder permission. Fix it on the server, then reload the page.

Next, type in the store's name and fill in the details for your admin account. Use a real email address, because you will use it with your password to sign in to the back office. Choose a strong password.

Decide whether to install the demo products, then continue. Demo products are handy if you want to explore the store first. For a live shop, you will normally leave them out so you do not have to delete sample items later.

On the database page, enter the database name, user and password you created earlier. The database server address is normally localhost, since MariaDB runs on the same machine. Continue and wait while the installer creates the tables. This can take a few minutes.

When the installer finishes, your PrestaShop site is set up and ready to use. The final page gives you links to the storefront and the back office. Note the back office address. PrestaShop gives the admin folder a random name for security, so you will need that exact address to sign in.

For security reasons, you must delete the installation directory. PrestaShop will not let you use the store or the back office until it is gone. Go back to the terminal and run the command in the block below.
sudo rm -rf /var/www/prestashop/install
Reload the storefront and the back office login page. Both should now load normally. That should do it!
Conclusion:
- Setting up PrestaShop on Ubuntu with Nginx is straightforward and can significantly improve the performance and reliability of your e-commerce website.
- Installing Nginx, MariaDB and PHP-FPM gives your PrestaShop site a solid base to run on.
- Creating a PrestaShop database and configuring Nginx to serve the PrestaShop content are essential steps for a successful installation.
- Securing your PrestaShop installation with Let's Encrypt SSL/TLS certificates helps protect sensitive data and build customer trust.
- By following these steps, you can set up an online store that is fast, secure and ready for customers.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!