PrestaShop is a powerful and customizable e-commerce solution that enables businesses to create and manage online stores efficiently. In this article, we will guide you through the process of installing PrestaShop with Apache web server and Let’s Encrypt SSL on Debian 11, ensuring a secure and seamless online shopping experience for your customers.
Prerequisites
Before we begin, make sure you have the following prerequisites in place:
- A server running Debian 11.
- A valid domain name pointed to your server’s IP address.
- A root password configured on the server.
Step 1: Install Apache, MariaDB, and PHP
To get started, we need to install Apache, MariaDB, PHP, and other necessary PHP extensions. Open your terminal and run the following command:
apt-get install apache2 mariadb-server libapache2-mod-php php php-gd php-mbstring php-mysql php-curl php-xml php-cli php-intl php-zip unzip -y
Once the installation is complete, we need to edit the php.ini
file and make some adjustments. Run the following command to open the file in a text editor:
nano /etc/php/7.4/apache2/php.ini
Within the php.ini
file, locate the following lines and modify them as shown below:
memory_limit = 256M post_max_size = 64M upload_max_filesize = 32M date.timezone = UTC
Save and close the file. Next, restart the Apache service to apply the changes:
systemctl restart apache2
Step 2: Create a Database for PrestaShop
Before we can proceed with the PrestaShop installation, we need to secure the MariaDB installation and set a root password. Run the following command to run the mysql_secure_installation
script:
mysql_secure_installation
You will be prompted to enter the current password for the root user. Since we haven’t set a password yet, press Enter to proceed. Follow the on-screen instructions to configure the root password, remove anonymous users, disallow remote root login, remove the test database, and reload the privilege tables.
Once the MariaDB installation is secured, log in to the MariaDB shell using the following command:
mysql -u root -p
Enter your MariaDB root password when prompted. Create a new database for PrestaShop and a dedicated user for it using the following commands:
CREATE DATABASE prestadb; GRANT ALL PRIVILEGES ON prestadb.* TO 'prestauser'@'localhost' IDENTIFIED BY 'yourpass';
Replace 'yourpass'
with a strong password of your choice. Afterward, flush the privileges and exit the MariaDB shell:
FLUSH PRIVILEGES; EXIT;
Step 3: Download and Install PrestaShop
Now, let’s download the latest version of PrestaShop from the official website. Use the following command to download the PrestaShop archive:
wget https://download.prestashop.com/download/releases/prestashop_1.7.7.7.zip
Once the download is complete, extract the archive using the following command:
unzip prestashop_1.7.7.7.zip
Next, move the extracted files to the Apache web root directory:
unzip prestashop.zip -d /var/www/html/prestashop
To ensure the correct permissions and ownership, run the following commands:
chown -R www-data:www-data /var/www/html/prestashop/ chmod -R 755 /var/www/html/prestashop
Now, we need to configure Apache to serve PrestaShop properly. Create a new virtual host configuration file for PrestaShop using the following command:
nano /etc/apache2/sites-available/prestashop.conf
Within the file, add the following configuration:
<VirtualHost *:80>
ServerAdmin test@example.com
ServerName presta.example.com
DocumentRoot /var/www/html/prestashop
<Directory /var/www/html/prestashop>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined
</VirtualHost>
Save and close the file. Next, enable the Apache rewrite module and activate the virtual host configuration:
a2enmod rewrite a2ensite prestashop
Finally, restart the Apache service to apply the changes:
systemctl restart apache2
You can verify the status of the Apache service by running:
systemctl status apache2
Step 4: Access PrestaShop Web UI
At this point, PrestaShop is installed and configured. To access the PrestaShop web interface, open your web browser and enter the URL http://presta.example.com
(replace with your domain name). You should see the PrestaShop installation page.
Select your preferred language and click on the “Next” button. On the next page, read and accept the terms and conditions, then click “Next” again. Provide the necessary information, such as your store name, admin account details, and click “Next” to proceed with the installation.
On the database configuration page, enter the database details we created earlier and click “Next” to start the installation process. Once the installation is complete, you will see the installation success page.
Click on the “Manage your store” button to access the PrestaShop admin interface. Before proceeding, we need to remove the installation folder for security purposes. Open your terminal and run the following command:
rm -rf /var/www/html/prestashop/install
Now, you can access the PrestaShop admin interface using the URL provided on the previous screen. Enter your admin username and password, then click “Log in” to access the PrestaShop dashboard.
Step 5: Secure PrestaShop with Let’s Encrypt SSL
To secure your PrestaShop website with an SSL certificate from Let’s Encrypt, we will use the Certbot tool. Start by installing the Certbot Let’s Encrypt client with the following command:
apt-get install python3-certbot-apache -y
Once the installation is complete, run the following command to install the SSL certificate for your domain:
certbot --apache -d presta.example.com
Replace presta.example.com
with your actual domain name. During the installation, you will be prompted to provide your email address and agree to the terms of service. Follow the instructions and complete the installation process.
Congratulations! You have successfully installed and configured PrestaShop with Apache and Let’s Encrypt SSL on Debian 11. Your online store is now secure and ready to serve customers.
Remember to regularly update PrestaShop and its modules to ensure optimal performance and security. Should you have any questions or need further assistance, feel free to contact our support team at Shape.host.
Shape.host provides reliable and scalable cloud hosting solutions, including Linux SSD VPS. Visit Shape.host for more information.