Prestashop is a popular open-source e-commerce solution that allows businesses to create and manage their online shops. With its fully customizable features and support for multiple languages, Prestashop is trusted by over 250,000 online stores worldwide. In this comprehensive tutorial, we will guide you through the step-by-step process of installing Prestashop on a Debian 12 server using Apache as the web server and Let’s Encrypt SSL certificates for secure communications.
Prerequisites
Before we begin the installation process, make sure you have the following prerequisites in place:
- A Debian 12 server with root access or a non-root user with sudo privileges.
- A domain name pointed to the server’s IP address.
Installing Dependencies
To prepare your server for Prestashop installation, you need to install the necessary dependencies. This includes setting up the LAMP stack (Apache2, MariaDB, and PHP) and installing additional PHP extensions. Follow the steps below to install these dependencies:
Step 1: Adding the PHP Repository
To install PHP 8.1, we need to add a third-party PHP repository and import the GPG key. Run the following commands:
sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
Step 2: Updating the Package Index
Next, update the package index on your Debian system:
sudo apt update
Step 3: Installing Dependencies
Now, install the LAMP stack, Certbot, and additional PHP extensions required by Prestashop:
sudo apt install apache2 mariadb-server certbot python3-certbot-apache php8.1 php8.1-curl php8.1-xmlrpc php8.1-soap php8.1-intl php8.1-zip php8.1-cli php8.1-mysql php8.1-common php8.1-opcache php8.1-memcached php8.1-bcmath php8.1-gd php8.1-mbstring php8.1-xml php8.1-gmp php8.1-imagick unzip
Step 4: Verifying Dependencies
After the installation is complete, verify that the Apache web server and MariaDB are running:
sudo systemctl is-enabled apache2 sudo systemctl status apache2 sudo systemctl is-enabled mariadb sudo systemctl status mariadb
You should see the status of both services as “enabled” and “running” if they are properly installed.
Step 5: Checking PHP Version and Extensions
To confirm that PHP 8.1 is installed and the required extensions are enabled, run the following commands:
php -v php -m
Make sure PHP 8.1 is displayed as the installed version, and the required extensions are listed.
Configuring MariaDB Server
Now that we have installed the dependencies, let’s secure the MariaDB server installation and create a new database and user for Prestashop:
Step 1: Running the Secure Installation Utility
To secure your MariaDB server, run the following command:
sudo mariadb-secure-installation
Follow the prompts and answer the questions to configure the MariaDB server. Make sure to set a strong root password and remove any test databases or anonymous users.
Step 2: Creating a New Database and User
After securing the MariaDB server, log in to the MariaDB shell:
sudo mariadb -u root -p
Enter the root password you set during the secure installation. Once logged in, execute the following queries to create a new database and user for Prestashop:
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 will create a new database named ‘prestashopdb’ and a user named ‘prestashop’ with full privileges on that database.
Step 3: Verifying the User Permissions
To verify that the user ‘prestashop’ has the necessary permissions, run the following command:
SHOW GRANTS FOR 'prestashop'@'localhost';
You should see a list of privileges granted to the ‘prestashop’ user for the ‘prestashopdb’ database.
Step 4: Exiting the MariaDB Shell
To exit the MariaDB shell, type:
quit
Configuring PHP
After configuring the MariaDB server, we need to modify the PHP configuration to meet Prestashop’s requirements:
Step 1: Editing the php.ini File
Open the php.ini file using a text editor:
sudo nano /etc/php/8.1/apache2/php.ini
Locate the following lines and make the necessary changes:
date.timezone = Europe/Amsterdam 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
Adjust the values according to your server environment. Save the file and exit the text editor.
Step 2: Restarting Apache
To apply the changes, restart the Apache web server:
sudo systemctl restart apache2
Verifying the Server Environment
Before proceeding with the Prestashop installation, let’s verify that your server environment meets the requirements. We can use the Prestashop environment checker script for this:
Step 1: Downloading the Environment Check Script
Move to the HTML directory and download the environment check script:
cd /var/www/html wget https://github.com/PrestaShop/php-ps-info/archive/refs/tags/v1.1.tar.gz
Step 2: Extracting and Renaming the Script
Extract the downloaded script and rename the extracted directory:
tar -xf v1.1.tar.gz mv php-ps-info-1.1 check-ps
Step 3: Accessing the Environment Checker
Open your web browser and visit the following URL, replacing ‘YOURSERVERIP’ with your server’s IP address:
http://YOUR_SERVER_IP/check-ps/phppsinfo.php
Enter the default username ‘prestashop’ and password ‘prestashop’, then click ‘Sign in’. The environment checker will provide a detailed report on your server environment.
Downloading Prestashop
Now that your server is properly configured, let’s download the Prestashop source code and set up the installation directory:
Step 1: Downloading the Source Code
Move to the desired directory and download the Prestashop source code:
cd /var/www/ wget https://github.com/PrestaShop/PrestaShop/releases/download/8.1.2/prestashop_8.1.2.zip
Step 2: Extracting the Source Code
Extract the downloaded zip file to the target directory:
unzip prestashop_8.1.2.zip -d /var/www/prestashop
Ensure that the Prestashop source code is extracted to the correct directory (/var/www/prestashop).
Step 3: Setting Ownership and Permissions
Set the proper ownership and permissions for the Prestashop installation directory:
sudo chown -R www-data:www-data /var/www/prestashop sudo chmod u+rw /var/www/prestashop
Configuring Apache2 Virtual Host
To run Prestashop, we need to create a virtual host configuration for Apache:
Step 1: Enabling the Rewrite Module
Enable the rewrite module for Apache:
sudo a2enmod rewrite
Step 2: Creating the Virtual Host Configuration
Create a new virtual host configuration file:
sudo nano /etc/apache2/sites-available/prestashop.conf
Insert the following configuration, replacing ‘YOURDOMAINNAME’ with your domain name:
<VirtualHost *:80>
ServerAdmin test@shapehost.com
DocumentRoot /var/www/prestashop
ServerName YOUR_DOMAIN_NAME
<Directory /var/www/prestashop>
AllowOverride All
Options +Indexes
Require all granted
</Directory>
ErrorLog /var/log/apache2/prestashop.error.log
CustomLog /var/log/apache2/prestashop.access.log combined
</VirtualHost>
Save the file and exit the text editor.
Step 3: Activating the Virtual Host
Activate the virtual host and verify the Apache configuration:
sudo a2ensite prestashop.conf
sudo apachectl configtest
If the configuration test is successful, restart Apache:
sudo systemctl restart apache2
Generating SSL/TLS Certificates
To secure your Prestashop installation, we will use Let’s Encrypt to generate SSL/TLS certificates:
sudo certbot --apache --agree-tos --no-eff-email --redirect --hsts --staple-ocsp --email test@shapehost.com -d YOUR_DOMAIN_NAME
Replace ‘YOURDOMAINNAME’ with your actual domain name. Certbot will automatically configure your virtual host file with HTTPS and generate the SSL/TLS certificates.
Installing Prestashop via Command Line
Now that your server is fully prepared, you can proceed with the Prestashop installation. We will use the command line method for installation:
Step 1: Navigating to the Installation Directory
Go to the Prestashop installation directory:
cd /var/www/prestashop/install
Step 2: Running the Installation Script
Run the installation script to install Prestashop:
sudo -u www-data php index_cli.php --domain=YOUR_DOMAIN_NAME --db_server=127.0.0.1 --db_name=prestashopdb --db_user=prestashop --db_password=password --prefix=myps_ test@shapehost.com --password=Passw0rd
Replace ‘YOURDOMAINNAME’ with your domain name, and adjust the database details and admin user information as needed.
Step 3: Setting Permissions
After the installation is complete, set the proper permissions for specific Prestashop directories:
sudo chmod u+rw /var/www/prestashop/var/cache sudo chmod u+rw /var/www/prestashop/var/logs sudo chmod u+rw /var/www/prestashop/img sudo chmod u+rw /var/www/prestashop/mails sudo chmod u+rw /var/www/prestashop/modules sudo chmod u+rw /var/www/prestashop/translations sudo chmod u+rw /var/www/prestashop/upload sudo chmod u+rw /var/www/prestashop/download sudo chmod u+rw /var/www/prestashop/app/config sudo chmod u+rw /var/www/prestashop/app/Resources/translations
Step 4: Removing the Installation Directory
Finally, remove the installation directory for security purposes:
sudo rm -rf /var/www/prestashop/install
Conclusion
Congratulations! You have successfully installed Prestashop on Debian 12 using Apache as the web server and Let’s Encrypt SSL certificates for secure communication. You can now access your Prestashop store by visiting your domain name in a web browser. If you encounter any issues during the installation process, please refer to the official Prestashop documentation or seek assistance from the Prestashop community.
At Shape.host, we offer reliable and scalable cloud hosting solutions, including Cloud VPS, to empower businesses with efficient and secure e-commerce platforms. Visit our website to learn more about our services and how we can help you streamline your online business.