fbpx
How to Install PrestaShop on CentOS 7

PrestaShop is a widely used, open-source e-commerce platform. With its flexibility, scalability, and rich feature set, it has been adopted by many online retailers around the world. For those using the CentOS 7 operating system, this guide will take you step by step through the process of installing PrestaShop on CentOS 7.

Step-by-step Guide to Installing PrestaShop on CentOS 7

Before you start with the installation of PrestaShop, you must ensure that your system has the LAMP stack installed. LAMP stands for Linux, Apache, MySQL, and PHP – the essential components to run a web-based application like PrestaShop. If you haven’t installed the LAMP stack on your CentOS 7 yet, we will walk you through the process below.

Update the System:

First and foremost, ensure your CentOS system is up-to-date.

sudo yum update -y
sudo yum install nano wget tar -y

Install LAMP Stack:

Install Apache

sudo yum install httpd -y
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Install and configure MariaDB

sudo yum install mariadb mariadb-server  -y
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
sudo /usr/bin/mysql_secure_installation

Install PHP 7.4

sudo yum install -y epel-release
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi-php74
sudo yum install -y php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-intl
php -v

Download the PrestaShop Package:

You can directly download the PrestaShop package using the wget command. Replace the URL with the latest version if necessary.

wget https://www.prestashop.com/download/old/prestashop_1.7.8.1.zip
unzip prestashop_1.7.8.1.zip

Extract the PrestaShop Files:

Once downloaded, unzip the PrestaShop on CentOS 7 package to the desired directory, usually the web root.

unzip prestashop.zip -d /var/www/html/

Create a MySQL Database for PrestaShop:

Log into MySQL:

mysql -u root -p

Enter the password when prompted.

Now, create a database and user for PrestaShop on CentOS 7:

CREATE DATABASE prestashop_db;
GRANT ALL PRIVILEGES ON prestashop_db.* TO 'prestashop_user'@'localhost' IDENTIFIED BY 'virtonostrongpassword';
FLUSH PRIVILEGES;
EXIT;

Replace ‘virtonostrongpassword’ with a secure password of your choice.

Modify File Permissions:

To ensure that PrestaShop on CentOS 7 can read and write the necessary files, adjust the permissions:

chown -R apache:apache /var/www/html/
chmod -R 755 /var/www/html/

Configure Apache for PrestaShop:

Create an Apache virtual host for your PrestaShop on CentOS 7 website. Let’s assume your domain is ‘example.com’. Create a configuration file:

nano /etc/httpd/conf.d/example.com.conf

Add the following content:

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/html/
    ServerName example.com
    ServerAlias www.example.com
    ErrorLog /var/log/httpd/example.com-error_log
    CustomLog /var/log/httpd/example.com-access_log common
</VirtualHost>

Save and exit the file.

Install Certbot

Now, install Certbot and its Apache plugin:

sudo yum install certbot python2-certbot-apache

Run Certbot along with the Apache plugin:

sudo certbot --apache

During the process, you will be asked for your email and agreement to the terms of service. Following that, Certbot will communicate with the Let’s Encrypt CA and respond with a challenge to prove domain ownership. The --apache flag tells Certbot to automatically update your Apache configuration to serve over HTTPS.

You’ll be given a choice about how you want to configure HTTPS:

  • You can choose to redirect HTTP traffic to HTTPS (recommended).
  • Or you can keep both HTTP and HTTPS.

Restart the Apache Server:

To make these changes take effect, restart Apache:

sudo systemctl restart httpd

Complete the Installation via Web Browser:

Now, open your web browser and navigate to your domain (e.g., https://example.com). Follow the on-screen prompts to complete the PrestaShop installation.

How to Install PrestaShop on CentOS 7
How to Install PrestaShop on CentOS 7

Tips for a Secure PrestaShop Installation:

Use Strong Passwords: Always use complex passwords for both the database and the PrestaShop admin account.
Regular Backups: Schedule regular backups of your PrestaShop store to prevent data loss.
Update Frequently: Ensure you’re always using the latest version of PrestaShop, PHP, and other components.

Final Thoughts

Installing PrestaShop on CentOS 7 is a straightforward process, especially when you have the LAMP stack already in place. By following the steps above, you’ll have your online store up and running in no time. Remember, the key to a successful online store goes beyond the installation. Regular maintenance, monitoring, and updates are vital to keeping your store secure and functional.


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.