PrestaShop is an ecommerce platform that specializes in the development of e-commerce sites. Its purpose is to assist you in creating a stylish, fast online store.


In this tutorial, 1Byte will show you how to deploy a LAMP-based PrestaShop store on a CentOS 7 server instance.

PREREQUISITES

1) Domain name

+ Here are some reasons why you must have a domain name:

  • When purchasing Cloud Server, you need a domain name to connect to the hosting
  • Without a domain name, you can not install SSL Certificate on it
  • When you put your website into business, how do customers know what your website’s name is to access?

→ A domain name is a MUST

→ If you do not have a domain name, consider visiting 1Byte to buy it

 

2) Cloud Server

+ Because you have full root access, you can install PrestaShop framework entirely, whereas this is not possible with Shared Hosting.

→ If you do not have, you can buy it directly at Cloud Server

3) Deploy and logged in your Server

+ To be able to install packages in the easiest and most standard way. You need to use terminal 

→ Logged in your Cloud Server

 

NOTE:

+ If your Cloud Server was previously used to host a website. Then 1Byte encourages you to:

  • Backup all data (if necessary)
  • Reinstall Cloud Server

+ You may ask why?

→ Because there is a significant likelihood that previously installed packages and frameworks may conflict with the packages and frameworks that are about to be installed

END OF NOTTING

Let's Get Your Hands wet

Step 1: Login into your Server

+ log in to Cloud server by terminal

Playlist

2 Videos

Step 1: Update the system

+ Regardless of what we decide to do, we should first make sure that all of our packages is up to date.

				
					sudo yum update -y
				
			

+ Next, we need to install nano, unzip and wget packages. We will need these commands later on

  • Nano: a command-line based text editor
  • Unzip: a command is used to unpack zip files
  • Wget: a free and open source software package for retrieving files using HTTP, HTTPS, and FTP
				
					sudo yum install nano -y
sudo yum install unzip -y
sudo yum install wget -y
				
			

+ By default, SELinux is enabled on a default CentOS 7 system. We recommend to disable SELinux on your system to prevent any security conflicts. You can disable SELinux by editing the /etc/selinux/config file

 
 

 

 

				
					nano /etc/selinux/config
				
			

+ Find the following line: SELINUX=enforcing

+ Then, replace it with the following line: SELINUX=permissive

+ Next, use combined-key Clrl + O to save and Ctrl + X to close the file.

+ Finally, restart your system to apply the changes.

				
					sudo reboot
				
			

+ In order for PrestaShop to function correctly, 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.

NOTE:

+ LAMP stands for Linux, Apache, MySQL, and PHP. Together, they provide a proven set of software for delivering high-performance web applications

 

Step 2: Install and configure Apache

				
					sudo yum -y install httpd
				
			
NOTE:
+ In case you cannot install httpd as shown below
 
+ Don’t worry, This could be the repository package of http has been excluded to another place. This leads to you not being able to run “yum install httpd (If you not run into the problem like this, please skip)
 
+ To fix this, please do as follow:
 
 

 

 

				
					nano /etc/yum.conf
				
			

+ As you can see, you cannot install the “httpd” package because it is currently excluded

+ Ok we know the reason, now we just need to remove “httpd” from “exclude” line

+ By the way, we also have to remove “mariadb” and “php” from “exclude” line too.

→ Because later on we need to install php and mariadb

 
 

 

 

+ Please make sure that the file yum.conf has been modified correctly as shown below
(There is no more php, httpd, and mariadb in exclude section)
 
+ As always, use combined-key Clrl + O to save and Ctrl + X to close the file.
 
+ Ok let’s install httpd package again by running this command
 
 

 

 

				
					yum clean all && yum update -y && yum install httpd -y
				
			

END OF FIXING INSTALL HTTPD WHEN GET ERROR!!!

+ Back to the road, if there is no error when installing httpd, please follow the steps below:

				
					sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
				
			

(Please make sure that Apache HTTP Server is running )

 
 

 

 

+ 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
sudo firewall-cmd --list-services
				
			

(Successfully added http service)

 Step 3: Install and configure MariaDB

+ Install MariaDB and set it to automatically start after system reboot:

				
					sudo yum install mariadb mariadb-server -y
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
sudo systemctl status mariadb.service
				
			
(Please make sure that MariaDB database server is running)
 
 

 

 

+ 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
				
			

NOTE:

+ In these steps above, you must remember the root user’s password in order to access the database.

+ Current password for root = password of root to connect to your server

+ Set root password = password of root to connect to your database

END OF NOTING

 

+ 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

				
					CREATE DATABASE prestashop;
GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashopuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
				
			

 
(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.)
 
 

 

 

 

Step 4: Install PHP and required extensions

+ Install PHP and required extensions using yum command:

				
					sudo yum install httpd mariadb-server php php-cli php-bcmath php-mysqli php-gd php-pdo php-xmlrpc php-intl php-posix php-json php-curl php-zip unzip -y
				
			

+ After installing all the required packages, edit the php.ini file and change some default settings:

				
					nano /etc/php.ini
				
			

+ Change the following lines corresponding to the values in the figure below :

 

 

TIP BEFORE EDITTING:

+ When working with nano, to find navigate to a certain keyword, use Ctrl + W, then type the keyword to find , finally just press Enter (basically, it works like you press Ctrl + F to file a keyword in your browser, or in Microsoft Word Office)

The nano will automatically move the mouse pointer to the location containing that keyword 

				
					max_input_vars = 3000
post_max_size = 64M
upload_max_filesize = 64M
max_execution_time = 600
memory_limit = 256M
				
			
(The original value of max_input_vars is 1000, now change to 3000)
 

(The original value of post_max_size is 8M, now increase to 64M)

 

(The original value of upload_max_filesize is 2M, now increase to 64M)

 

(The original value of max_execution_time is 30, now change to 600)

 

(The original value of memory_limit is 128M, now increase to 256M)

 

NOTE:

+ Please make sure to press Ctrl + O to save and Ctrl + X to quit

END OF NOTTING

 
 

 

 

+ Put all of the configuration changes into effect:

				
					sudo systemctl restart httpd mariadb
				
			

 

Step 5: Create a web root and download the PrestaShop archive

+ Create web root “prestashop”

				
					mkdir /var/www/html/prestashop
cd /var/www/html/prestashop
				
			

After this, all website related data such as plugins, themes, files, …etc will be put in this directory 

 
 

 

 

+ Download the latest stable version of PrestaShop, which is 1.7.8.3 as of writing:

				
					sudo wget https://www.prestashop.com/download/releases/prestashop_1.7.8.3.zip
ls -l
				
			

(Successfully downloaded prestashop version 1.7.8.3)

+ For future reference, you can always find the URL of the latest download from the PrestaShop official website.
 
+ Now we need to unzip to uncompress the archive
				
					unzip prestashop_1.7.8.3.zip
ls -la
				
			

(Here we can see, after we unzip the file “prestashop_1.7.8.3.zip”, we get another file “prestashop.zip” )

 

NOTE:

+ Please do not delete or unzip file “prestashop.zip“. Because this file will be used when installing PrestaShop in the browser (Part 2) 

END OF NOTTING

 

+ Setup the proper ownership for all of the files and directories in the archive, then move them to the web root directory:

				
					chown -R apache:apache /var/www/html/prestashop
				
			

Step 6: Remove the default page and configure apache to accept PrestaShop site

				
					nano /etc/httpd/conf.d/prestashop.conf
				
			
+ After running the above command, please paste the following lines into prestashop.conf
 
 

 

 

				
					<VirtualHost *:80>
    ServerAdmin admin@hobbykh.fun
    ServerName hobbykh.fun
    ServerAlias *.hobbykh.fun
    DocumentRoot /var/www/html/prestashop

    <Directory /var/www/html/prestashop>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd/prestashop-error_log
    CustomLog /var/log/httpd/prestashop-access_log common
</VirtualHost>
				
			

NOTE:

Remember that change the value at:

+ ServerAdmin into your webmaster email

+ ServerName to your domain name

END OF NOTTING

 

Step 7: Visit your server from a web browser

 
 

 

 

				
					http://[your-server-IP]/
				
			

(As you can see, the server’s PHP seems to be outdated. So we will update PHP to the latest version as below)

 

7.1 – Lets start by install yum-utils

				
					yum install yum-utils -y
				
			


7.2 – Lets download Remi repo

				
					yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
				
			

7.3 – We will now run the commands to install the PHP version 7.4
				
					yum-config-manager --enable remi-php74
				
			


7.4 – Refresh the repossitory and restart the httpd service

				
					yum update -y
systemctl restart httpd
				
			


7.5 – Let’s check our PHP version

				
					php --version
				
			

(Congratulations, we have successfully updated PHP version from 5.4 to 7.4)

 
 

 

 

 

7.6 – Visit your server again via web browser

				
					http://[your-server-IP]/
				
			

(Hic hic, one more error. But don’t worry because 1Byte is here to help you overcome all difficulties ^^)

 

+ Ok now we just need to back our terminal, and install the so-called PHP zip extension

				
					yum install php-zip -y
systemctl restart httpd
				
			

 

7.7 – Comeback our server in web browser again