Skip to content
CMS

How to Install PrestaShop with Apache on Ubuntu 24.04

Richard
Written by
Richard
Updated 9 min read
PrestaShop featured image
PrestaShop featured image
Before you start
  • 5 steps
  • Needs administrator rights

Installing PrestaShop with Apache on Ubuntu 24.04 gives you a free online store on your own server. PrestaShop is an open-source shopping cart. You use it to add products, track orders, and take payments from customers.

Apache is the web server. It receives each visitor’s request and sends back the page. Ubuntu 24.04 is the Linux system everything runs on. You will also install MariaDB to store the shop data and PHP to run the PrestaShop code.

Before you start, you need an Ubuntu 24.04 server and a user account with sudo rights. A domain name pointing at the server is needed for the SSL step, but you can test everything else with the server’s IP address.

⚡ Quick Answer

Install Apache and MariaDB using `sudo apt install apache2 mariadb-server`. Create a PrestaShop database and user within MariaDB. Finally, install PHP and download the PrestaShop files to your Apache web root.

Advertisement

Install Apache HTTP server on Ubuntu

Apache handles all the incoming web traffic for your store, so every PrestaShop installation on Ubuntu needs it. The two commands you will use are sudo apt update and sudo apt install apache2. The first refreshes the package list. The second installs Apache.

Install Apache with the steps below.

Advertisement
  1. Open the Ubuntu terminal. On a desktop, press Ctrl+Alt+T. On a remote server, connect over SSH.
  2. Run the commands in the block below.
  3. Wait for apt to finish. It prints the packages it is downloading, then returns you to the prompt. Ubuntu starts Apache automatically after it installs.
🐧Bash / Shell
sudo apt update
sudo apt install apache2

Once Apache is installed, you manage it with the commands below. They start Apache, stop it, and make it start automatically when the server boots. You only need the enable command once. Start and stop are useful whenever you need to bring the web server up or down by hand.

🐧Bash / Shell
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2

Next, check that Apache is serving pages.

  1. Open a web browser, on the server itself or on another computer on the same network.
  2. Type the server’s localhost address or IP address in the address bar, as shown below, and press Enter.

http://localhost

Default Apache2 welcome page displayed after installing Apache on Ubuntu 24.04
Default Apache2 welcome page displayed after installing Apache on Ubuntu 24.04

When you see the Apache2 Default Page, the Apache HTTP server is installed and working. If the page does not load from another computer, check that the firewall on the server allows web traffic on port 80.

Additional help on installing Apache on Ubuntu is in the link below.

How to install Apache on Ubuntu

Install MariaDB database server on Ubuntu

The MariaDB database server stores your products, customer details, and orders. The package you need is mariadb-server, and you install it with sudo apt install mariadb-server. Every PrestaShop installation on Ubuntu needs a database like this.

Use the instructions below to install MariaDB and check that it runs.

Open the Ubuntu terminal and run the commands below to install the MariaDB database server.

🐧Bash / Shell
sudo apt update
sudo apt install mariadb-server

After the install finishes, use the commands below to stop, start, and enable the MariaDB server. Enabling it makes the database start by itself when the server boots. Without that, your shop would show a database error after every reboot until someone started MariaDB by hand.

🐧Bash / Shell
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the commands below to confirm that MariaDB is installed and responding.

🐧Bash / Shell
sudo mariadb

The commands above log you into the MariaDB console. You should see a message similar to the one below.

💻Code
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. If you see a connection error instead, MariaDB is not running yet. Go back to the start command in the previous step.

Additional help on installing MariaDB:

Create a PrestaShop database

A dedicated database and user account give PrestaShop its own place to store data. It also means the shop never needs your administrator login. You do this in the MariaDB shell, and it must be finished before you run the web installer.

Advertisement

First, create a database named prestashopdb. Then create a user account called prestashopdbuser.

Finally, grant prestashopdbuser full access to the prestashopdb database. This user can then create tables and change data in that one database only.

You can do all of this with the commands below.

But first, log on to the MariaDB database server:

🐧Bash / Shell
sudo mariadb

The prompt should change to the MariaDB prompt. Then run the commands below to complete the steps:

💻Code
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

Replace type_your_password_here with a strong password of your own before you run the commands. Write it down, because you need the database name, user, and password again in the PrestaShop installer.

Install PHP on Ubuntu

PHP runs the code behind your store. PrestaShop also needs several PHP extensions. The install command is sudo apt install php libapache2-mod-php php-intl php-mysql php-xml php-gd php-zip. It installs PHP, the Apache module, and the extensions for database access, XML, images, and zip files in one go.

Run the commands below to install PHP.

🐧Bash / Shell
sudo apt install php libapache2-mod-php 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. Check the PrestaShop version you download against the PHP versions it supports, because older releases do not run on the newest PHP. The installer’s requirements page also warns you if something is not supported. Additional help on installing PHP:

How to install PHP on Ubuntu Linux

Download PrestaShop files

Apache can only show your store once the PrestaShop files are in its web directory. The process has four parts: go to the /tmp directory, download the zip file, extract it, and move the files into the Apache root folder.

First, go to the /tmp directory and download the PrestaShop files. Then unzip the download and move the content into a PrestaShop folder inside the Apache root directory.

The last step is to change the permissions. This lets the Apache web server read and write the files it needs, such as images and cache, without opening them to everyone. Apache runs as the www-data user on Ubuntu, so that user should own the PrestaShop folder.

The download link in the commands points to one specific release. To get the latest version, find it on the official download page and replace the link with the new one. Newer releases include the latest features and security fixes.

⬛Command Prompt
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 Apache to serve the PrestaShop content. This takes a virtual host file, which tells Apache which domain belongs to which folder.

Run the commands below to create an Apache virtual host file for PrestaShop. The command opens a new, empty file in a text editor.

Advertisement
🐧Bash / Shell
sudo nano /etc/apache2/sites-available/prestashop.conf

Copy and paste the content block below into the file. Change the domain name in it to your own domain or server hostname, and check that the folder paths match where you put the PrestaShop files.

💻Code
<VirtualHost *:80>
ServerName prestashop.example.com
ServerAlias www.prestashop.example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/prestashop

<Directory /var/www/prestashop/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save the file and close the editor.

Next, enable the PrestaShop virtual host and restart Apache with the commands below. Apache only reads a new virtual host when it restarts. After the restart, your PrestaShop site is reachable through your domain name. If you still see the Apache default page later, the virtual host is probably not enabled yet, or Apache was not restarted.

🐧Bash / Shell
sudo a2ensite prestashop.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Setup Let’s Encrypt SSL/TLS for PrestaShop

Let’s Encrypt SSL certificates encrypt the data your customers send, such as logins and addresses, and turn on HTTPS for your site. A store should not run without it. The process is to install Certbot and then run its Apache plugin, which creates the certificate and updates your Apache configuration. Let’s Encrypt needs a real domain name that points to your server, so it will not issue a certificate for a bare IP address. If you only have an IP address, skip this step for now and add HTTPS later.

Read the post below for more help on installing and creating Let’s Encrypt SSL certificates for Apache.

How to set up Let’s Encrypt SSL certificate for Apache on Ubuntu Linux

Once Apache has restarted, open your browser and go to the server hostname or IP address you set in the Apache server block. The PrestaShop installer runs in the browser, in the steps below.

💻Code
http://prestashop.example.com

The PrestaShop installation wizard should appear. Select the installation language and click Next. After the license agreement page, you get the system check.

PrestaShop set up select language
PrestaShop set up select language

On the next page, the wizard checks the server. Confirm that all requirements are met, then click Next. If something is marked as missing, it is usually a PHP extension. Install it, restart Apache, and refresh the page.

PrestaShop set up compatibility
PrestaShop set up compatibility

Then type in the store’s name and create your admin account. This page asks for the shop name, your name, an email address, and a password. You use the email and password to sign in to the back office, so choose a strong password and keep it safe.

PrestaShop set up store and account name
PrestaShop set up store and account name

Next, choose whether to install demo products and continue. Demo products are sample items that help you see how a finished store looks. For a live shop you can leave them out and add your own products.

PrestaShop set up demo products
PrestaShop set up demo products

On the next page, type in the database name, user, and password you created earlier. Leave the database server address as it is when MariaDB runs on the same server. Continue when you are done. If the wizard says it cannot connect to the database, check the name, user, and password for typing mistakes.

PrestaShop set up database connection
PrestaShop set up database connection

The wizard now installs the shop. This can take a few minutes. When it finishes, your PrestaShop site is set up and ready to use. The wizard shows links to the store front and the back office. The back office folder gets a random name during the install, so note down that address.

PrestaShop set up complete
PrestaShop set up complete

For security reasons, delete the installation directory. Leaving it in place would let someone else run the installer again. Go back to the terminal and run the command below. PrestaShop may also refuse to open the store until this folder is gone.

🐧Bash / Shell
sudo rm -rf /var/www/prestashop/install

That should do it! Reload your store address in the browser to see the front page, then sign in to the back office with the admin account you created.

Conclusion:

  • In this tutorial, we have set up PrestaShop on Ubuntu with Apache, providing a reliable and secure environment for hosting an e-commerce website.
  • By following the installation steps for Apache, MariaDB, and PHP, you have a solid foundation for your PrestaShop installation.
  • Creating a dedicated PrestaShop database and configuring Let’s Encrypt SSL/TLS add further protection for the online store.
  • With the illustrated setup process and the images, you can work through the installation wizard and finish the PrestaShop configuration.
  • Don’t forget to remove the installation directory using the command provided, to keep the store secure.

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?

Richard

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.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *