How to Install PrestaShop on CentOS 7
PrestaShop is a popular open source e-commerce solution. You can use it to create your own online store for free.
In this tutorial, I will show you how to deploy a LAMP-based PrestaShop store on a Vultr CentOS 7 server instance.
Prerequisites
Before proceeding, I assume that you have:
- Deployed a brand new Vultr CentOS 7 server instance.
- Logged in this CentOS 7 server instance from your SSH terminal using a non-root user with sudo privileges. You can learn about how to create such a user in this Vultr tutorial.
Step 1: Update the system
Update your Vultr server instance to the latest stable status:
sudo yum update
sudo reboot
After the reboot, use the same sudo user to log into your machine again.
You need to setup the LAMP stack on your machine before you can deploy and use PrestaShop. In the following steps, I will show you how to install and configure Apache, MariaDB, and PHP.
Step 2: Install and configure Apache
Install Apache and set it to get started automatically after system reboot:
sudo yum install httpd
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
Remove Apache's default welcome page:
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
Disallow Apache to display directories and files within the web root directory /var/www/html
:
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf
Modify the current firewall rules so that visitors can access your online store:
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload
Step 3: Install and configure MariaDB
Install MariaDB and set it to automatically start after system reboot:
sudo yum install mariadb mariadb-server
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Execute the secure MySQL installation process:
sudo /usr/bin/mysql_secure_installation
Go through the process in accordance with the instructions below:
Enter current password for root (enter for none): Press the Enter key
Set root password? [Y/n]: Input Y, then press the Enter key
New password: Input a new root password, then press the Enter key
Re-enter new password: Input the same password again, then press the Enter key
Remove anonymous users? [Y/n]: Input Y, then press the Enter key
Disallow root login remotely? [Y/n]: Input Y, then press the Enter key
Remove test database and access to it? [Y/n]: Input Y, then press the Enter key
Reload privilege tables now? [Y/n]: Input Y, then press the Enter key
Now, log into the MySQL shell so that you can create a dedicated database for PrestaShop:
mysql -u root -p
Input the MariaDB root password you set earlier to log in, then setup the PrestaShop database using the following commands. Be sure to replace the database name "prestashop", the database username "prestashopuser", and the database user password "yourpassword" in each commands with your own ones.
CREATE DATABASE prestashop;
GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashopuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Step 4: Install PHP and required extensions
Install PHP and required extensions using YUM:
sudo yum install php php-gd php-mbstring php-mcrypt php-mysqli php-curl php-xml php-cli
Put all of the configuration changes into effect:
sudo systemctl restart httpd mariadb
Step 5: Download the PrestaShop archive and prepare for installation
Download the latest stable version of PrestaShop, which is 1.6.1.5
as of writing:
cd ~
wget https://www.prestashop.com/download/old/prestashop_1.6.1.5.zip
For future reference, you can always find the URL of the latest download from the PrestaShop official website.
Install unzip
to uncompress the archive:
sudo yum install unzip
unzip prestashop_1.6.1.5.zip
Setup the proper ownership for all of the files and directories in the archive, then move them to the web root directory:
sudo chown -R apache: ~/prestashop/
sudo mv ~/prestashop/* /var/www/html/
Step 6: Finish the installation from a web browser
Visit your Vultr server from a web browser:
http://[your-Vultr-server-IP]/
If each of the prior steps were successful, you will be presented with the PrestaShop installation wizard.
Follow the instructions on the screen to finish the installation. In general, the steps of the installation will be:
- Choose your language.
- License agreements.
- System compatibility.
- Store information.
- System configuration.
- In this step, you need to input the database name, the database login user "root", and the database password you setup earlier.
- Store installation.
For security purposes, you MUST delete the /install
directory after the installation:
sudo rm -rf /var/www/html/install/
Optionally, you can delete the /docs
directory and the README.md
file.
sudo rm -rf /var/www/html/docs/
sudo rm /var/www/html/README.md
You MUST rename the /admin
directory to a private and secure name (e.g. /kdycau0197k8upr2
) before you can manage the store. Choose a secure name. For example:
sudo mv /var/www/html/admin/ /var/www/html/kdycau0197k8upr2/
Afterwards, you would manage the store from the following URL:
http://[your-Vultr-server-IP]/kdycau0197k8upr2/
This path is the only one which can be used to access your PrestaShop dashboard, be sure to save it and keep it private.
That's all. Now, you can customize and populate your store from the PrestaShop dashboard. Enjoy it.