Prestashop, a free and open-source e-commerce solution written in PHP, is a powerful tool for creating online stores and growing your business. With over 250,000 online stores worldwide and support for 65 languages, Prestashop is a fully customizable and feature-rich e-commerce solution. In this tutorial, we will walk you through the step-by-step process of installing Prestashop on an Ubuntu 22.04 server using the LAMP stack (Linux, Apache, MySQL/MariaDB, and PHP). We will also cover the basic configurations of the LAMP stack for PHP web applications.
Prerequisites
Before we dive into the installation process, make sure you have the following prerequisites in place:
- An Ubuntu 22.04 server: For this tutorial, we will use an Ubuntu server with the hostname ‘server-ubuntu’ and the IP address ‘192.168.5.100’.
- A non-root user with root administrative privileges.
- A domain name pointed to the Ubuntu server IP address.
Installing Apache Web Server
The first step is to install the Apache web server on your Ubuntu system. Prestashop requires at least Apache web server v2.2, but we will install Apache v2.4, which is available by default on the Ubuntu repositories.
To begin, update and refresh your repositories by running the following command:
sudo apt update
Next, install the Apache web server using the following command:
sudo apt install apache2
Once the installation is complete, check and verify the status of the ‘apache2’ service using the following command:
sudo systemctl is-enabled apache2
sudo systemctl status apache2
You should see that the ‘apache2’ service is enabled and running.
Next, add the HTTP and HTTPS ports to the UFW firewall using the following commands:
sudo ufw allow "Apache Full"
sudo ufw status
This will ensure that the Apache web server is accessible through the firewall.
Installing MariaDB Database Server
Since Prestashop only supports the MySQL/MariaDB database, we need to install this database server on our Ubuntu machine. In this tutorial, we will use MariaDB as the database for our Prestashop installation.
To install MariaDB, run the following command:
sudo apt install mariadb-server
Once the installation is complete, check and verify the status of the ‘mariadb’ service using the following command:
sudo systemctl is-enabled mariadb
sudo systemctl status mariadb
You should see that the ‘mariadb’ service is enabled and running.
Next, secure your MariaDB deployment by running the following command:
sudo mysql_secure_installation
This command will guide you through a series of prompts to secure your MariaDB installation. Follow the prompts and set up a new root password, remove anonymous users, disallow remote root login, remove the test database, and reload the privileges table.
Installing PHP
Prestashop recommends using at least PHP v7.1 for the latest version of their software. In this tutorial, we will install PHP 7.4 on our Ubuntu 22.04 system using a third-party repository.
Before installing PHP, install the basic packages and dependencies for managing repositories by running the following command:
sudo apt install software-properties-common apt-transport-https -y
Next, add the PHP 7.4 PPA repository to your Ubuntu system using the following command:
sudo add-apt-repository ppa:ondrej/php -y
Update your repositories by running the following command:
sudo apt update
Now install PHP 7.4 and the required extensions for Prestashop using the following command:
sudo apt install php7.4 php7.4-curl php7.4-xmlrpc php7.4-soap php7.4-intl php7.4-zip php7.4-cli php7.4-mysql php7.4-common php7.4-opcache php7.4-memcached php7.4-bcmath php7.4-gd php7.4-mbstring php7.4-xml php7.4-gmp php7.4-imagick
After PHP is installed, open the PHP configuration file using your preferred text editor. In this example, we will use nano:
sudo nano /etc/php/7.4/apache2/php.ini
Make the following changes to the PHP configurations:
date.timezone = Europe/Paris max_execution_time = 130 memory_limit = 256M allow_url_fopen = On allow_url_include = Off post_max_size = 128M upload_max_filesize = 128M max_input_vars = 5000
Save the changes and exit the file. Then, restart the ‘apache2’ service to apply the changes:
sudo systemctl restart apache2
To verify that PHP is running correctly, create a phpinfo file by running the following command:
cat <<EOF | sudo tee /var/www/html/info.php <?php phpinfo(); ?> EOF
Access the phpinfo file through your web browser by entering the following URL: http://192.168.5.100/info.php
(replace the IP address with your server’s IP address). You should see detailed information about your PHP installation.
Installing Prestashop System Checker
Before installing Prestashop, let’s install the Prestashop System Checker on your server. This PHP script checks your server environment for the Prestashop installation.
To download the Prestashop System Checker script, run the following commands:
cd /var/www/html sudo wget https://github.com/PrestaShop/php-ps-info/archive/refs/tags/v1.1.tar.gz
Extract the Prestashop System Checker source code and rename the directory:
sudo tar -xzvf v1.1.tar.gz sudo mv php-ps-info-1.1 check-ps
Now, access the Prestashop System Checker through your web browser by entering the following URL: http://192.168.5.100/check-ps/phppsinfo.php
(replace the IP address with your server’s IP address).
Log in using the default username and password ‘prestashop’. Ensure that all the LAMP Stack configurations meet the requirements of Prestashop. If any settings are missing or if any PHP extensions are not installed, you can edit the PHP config file ‘/etc/php/7.4/apache2/php.ini’ and install the necessary extensions.
Creating MariaDB Database and User
Before installing Prestashop, we need to create a new MariaDB database and user.
Log in to the MariaDB shell as the root user by running the following command:
sudo mysql -u root -p
Enter your MariaDB root password when prompted.
Next, create a new database and user for Prestashop by running the following queries:
CREATE DATABASE prestashopdb; GRANT ALL PRIVILEGES ON prestashopdb.* TO 'prestashop'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
Replace ‘password’ with a strong password of your choice. These commands create a new database named ‘prestashopdb’ and a user named ‘prestashop’ with all privileges on that database.
To verify the privileges for the MariaDB user ‘prestashop@localhost’, run the following query:
SHOW GRANTS FOR prestashop@localhost;
You should see information about the ‘prestashop@localhost’ user having privileges for the ‘prestashopdb’ database.
Exit the MariaDB shell by running the following command:
quit
Downloading Prestashop Source Code
Now that we have created the MariaDB database and user, let’s download the Prestashop source code and set up the necessary permissions and ownership for the installation directory.
First, install the ‘unzip’ package by running the following command:
sudo apt install unzip -y
Move to the ‘/var/www/’ directory and download the Prestashop source code by running the following command:
cd /var/www/ sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.8.7.zip
Extract the Prestashop source code to the ‘/var/www/prestashop’ directory by running the following command:
sudo unzip prestashop_1.7.8.7.zip -d /var/www/prestashop
Change the ownership of the Prestashop installation directory and set the necessary permissions by running the following commands:
sudo chown -R www-data:www-data /var/www/prestashop sudo chmod u+rw /var/www/prestashop
Setting Up Apache Virtual Host
Now that we have all the dependencies and configurations in place, and the Prestashop source code is downloaded, let’s set up the Apache virtual host for our Prestashop installation.
Before we begin, make sure you have your domain name pointed to your Ubuntu server IP address and have SSL certificates generated. Additionally, enable the required Apache2 modules for Prestashop by running the following command:
sudo a2enmod ssl rewrite headers
To create a new virtual host configuration for Prestashop, run the following command:
sudo nano /etc/apache2/sites-available/prestashop.conf
In the text editor, add the following virtual host configurations for your Prestashop installation. Be sure to replace ‘shapehost.io’ with your domain name, and update the paths to your SSL certificate files:
<VirtualHost *:80>
ServerName shapehost.io
Redirect permanent / https://shapehost.io/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin test@shapehost.io
DocumentRoot /var/www/prestashop
ServerName shapehost.io
Protocols h2 http/1.1
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/shapehost.io/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/shapehost.io/privkey.pem
<Directory /var/www/prestashop>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/prestashop_error.log
CustomLog /var/log/apache2/prestashop_access.log combined
</VirtualHost>
Save the configuration file and exit the text editor.
Next, enable the virtual host file ‘prestashop.conf’ by running the following command:
sudo a2ensite prestashop.conf
Verify your Apache configurations by running the following command:
sudo apachectl configtest
If there are no syntax errors, you should see a message saying “Syntax OK”.
Finally, restart the ‘apache2’ service to apply the new changes:
sudo systemctl restart apache2
Installing Prestashop via Web Installer
Now that our virtual host is set up, we can start the Prestashop installation process.
Open your web browser and navigate to your Prestashop installation domain (e.g., https://shapehost.io/
).
You should see the Prestashop web installer starting the installation process. Select your preferred language and click ‘Next’.
Agree to the Prestashop License agreement and click ‘Next’.
Create a new admin user for your Prestashop installation by entering the required details (username, email, and password). Then, click ‘Next’ to proceed to the database configuration.
For the store content, you can select ‘No’ and click ‘Next’.
Enter the database user, database name, and the password you created earlier for the MariaDB user ‘prestashop’. Click ‘Next’ to start the Prestashop installation.
The installation process will begin, and you will see a progress bar indicating the installation status.
Once the installation is complete, you will see a page confirming the successful installation of Prestashop. At this point, it is important to delete the ‘install’ directory from your Prestashop document root for security reasons.
To do this, return to your terminal and run the following command:
sudo rm -rf /var/www/prestashop/install
Finally, click the ‘Manage your store’ button to access the Prestashop administration login page. Enter the admin username and password you created earlier, and click ‘LOG IN’.
Congratulations! You have successfully installed Prestashop on your Ubuntu 22.04 server.
Conclusion
In this comprehensive guide, we have walked you through the step-by-step process of installing Prestashop on an Ubuntu 22.04 server. We started by setting up the LAMP stack (Linux, Apache, MySQL/MariaDB, and PHP) and securing the MariaDB database server. Then, we installed PHP and configured it for Prestashop. We also installed the Prestashop System Checker to ensure that our server environment meets the requirements.
We created a MariaDB database and user for Prestashop and downloaded the Prestashop source code. Finally, we set up the Apache virtual host and installed Prestashop using the web installer.
Now that you have Prestashop up and running, you can customize your online store, add themes, install plugins, and start selling your products. Prestashop offers a wide range of features and flexibility to help you build a successful e-commerce business.
If you’re looking for reliable and scalable cloud hosting solutions for your Prestashop store, Shape.host offers Linux SSD VPS services that are optimized for performance and security. Visit Shape.host to learn more about our hosting options and get started today.