How to Install and Configure the Latest PrestaShop on Ubuntu 16.04 or 18.04
This post will guide you how to install and configure latest PrestaShop on your Ubuntu Linux 18.04 or 16.04 or your dedicated server. And this guide you will show you the following steps to install PrestaShop on an Ubuntu Linux server.
- What is PrestaShop?
- Prerequisites
- Step1: Installing Apache
- Step2: Configuring Apache
- Step3: Installing PHP
- Step4: Installing MySQL or MariaDB
- Step5: Creating Database and User
- Step6: Downloading the Latest PrestaShop Package
- Step7: Installing PrestaShop
What is PrestaShop?
PrestaShop is a free open-source shopping cart software that you can use to run an e-commerce website. It is published under the Open software License. And it is written in the PHP programming language with support for the MySQL or MariaDB database management system. This website framework also provide lots of beautiful themes and premium plugins.
PrestaShop is also support many different payment gateway systems, like PayPal, Google Checkout, etc. And you can easily change the theme of the shop without changing its content. And it is also support add-on modules that extend the software’s built-in functionalities.
If you want to open an online store, and PrestaShop solution may be a best choice for you. As it is free and open source and it is wide support from developers, and also it is a comprehensive ecommerce solution used by thousands of merchants around the world.
Prerequisites
- A running Ubuntu Linux system or VM
- You need to have a non-root user with sudo privileges
- A FQDN Domain name that point to your IP address. Such as: mytest.com
Step1: Installing Apache
Before you begin to install packages on your Ubuntu system, you need to make sure that your system is up to date, so you need to run yum update command to update the APT index and upgrade all packages that can be updated.
$ sudo apt update $ sudo apt upgrade
Then you can begin to install the Apache package with the following command:
$ sudo apt-get install apache2 libapache2-mod-php
Outputs:
devops@devops:~$ sudo apt-get install apache2 libapache2-mod-php
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic
linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic
linux-modules-extra-4.18.0-22-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
libapache2-mod-php
The following packages will be upgraded:
apache2 apache2-bin apache2-data apache2-utils
4 upgraded, 1 newly installed, 0 to remove and 56 not upgraded.
Need to get 1,413 kB of archives.
After this operation, 16.4 kB of additional disk space will be used.
Do you want to continue? [Y/n]
…..
Setting up libapache2-mod-php (1:7.2+60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Setting up apache2-utils (2.4.29-1ubuntu4.7) ...
Setting up apache2-bin (2.4.29-1ubuntu4.7) ...
Setting up apache2-data (2.4.29-1ubuntu4.7) ...
Processing triggers for systemd (237-3ubuntu10.23) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up apache2 (2.4.29-1ubuntu4.7) ...
Step2: Configuring Apache
Once Apache package is installed on your system, you need to create a basic configuration file for Apache, and it will set DocumentRoot variable to specify the location of your website files and set ServerName variable to specify what you domain name is. And you can create it by copying a default config file, and then modify it. Just do the following steps:
1# Run the following command to copy the default config file to use it as a template.
$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mytest.com.conf
2# edit the configuration file mytest.com.conf with vim text editor, and uncomment the ServerName line, and replace example.com with you domain name, and then update the remain lines as below:
$ sudo vim /etc/apache2/sites-available/mytest.com.conf
ServerName mytest.com ServerAdmin test@mytest.com Documentroot /var/www/html/mytest.com <Directory /var/www/html/mytest.com> AllowOverride All </Directory>
3# you need to create the directory to store your website files with the following mkdir command:
$ sudo mkdir /var/www/html/mytest.com
4# you need to disable the default configuration file and enable the newly created one, mytest.com.conf, run the below command:
$ sudo a2dissite 000-default.conf $ sudo a2ensite mytest.com.conf
Outputs:
devops@devops:~$ sudo a2dissite 000-default.conf Site 000-default disabled. To activate the new configuration, you need to run: systemctl reload apache2 devops@devops:~$ sudo a2ensite mytest.com.conf Enabling site mytest.com. To activate the new configuration, you need to run: systemctl reload apache2
5# you also need to enable the mod_rewrite Apache module for PrestaShop with the following command:
$ sudo a2enmod rewrite
6# need to restart Apache service with the following command:
$ sudo systemctl restart apache2.service
Step3: Installing PHP
You need to install php package on your Ubuntu system for PrestaShop software. Just run the following command to install it:
$ sudo apt install php libapache2-mod-php
Ouputs:
devops@devops:~$ sudo apt install php libapache2-mod-php [sudo] password for devops: Reading package lists... Done Building dependency tree Reading state information... Done libapache2-mod-php is already the newest version (1:7.2+60ubuntu1). The following packages were automatically installed and are no longer required: linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic linux-modules-extra-4.18.0-22-generic Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: php 0 upgraded, 1 newly installed, 0 to remove and 56 not upgraded. Need to get 3,084 B of archives. After this operation, 12.3 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 php all 1:7.2+60ubuntu1 [3,084 B] Fetched 3,084 B in 0s (14.6 kB/s) Selecting previously unselected package php. (Reading database ... 210189 files and directories currently installed.) Preparing to unpack .../php_1%3a7.2+60ubuntu1_all.deb ... Unpacking php (1:7.2+60ubuntu1) ... Setting up php (1:7.2+60ubuntu1) ...
Then you still need to install other required PHP modules with the following command:
$ sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap
Outputs:
devops@devops:~$ sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.2-cli is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-common is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-common set to manually installed.
php7.2-curl is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-gd is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-mysql is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-opcache is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-intl is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-mbstring is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-zip is already the newest version (7.2.19-0ubuntu0.18.04.1).
The following packages were automatically installed and are no longer required:
linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic linux-modules-extra-4.18.0-22-generic
Use 'sudo apt autoremove' to remove them.
Suggested packages:
php-pear
The following NEW packages will be installed:
php7.2-bcmath php7.2-fpm php7.2-soap php7.2-xsl
0 upgraded, 4 newly installed, 0 to remove and 56 not upgraded.
Need to get 1,550 kB of archives.
After this operation, 5,456 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Step4: Installing MySQL or MariaDB
Now you can begin to install MySQL database management or MariaDB database to store data for your PrestaShop. Just run the following command to install it:
$ sudo apt install mariadb-server
Or
$ sudo apt install mysql-server mysql-client
Once the installation is completed, you’d better to run mysq_secure_installation script to secure your MySQL or MariaDB installation by running the following command:
$ sudo mysql_secure_installation
Step5: Creating Database and User
Once the Database installation is completed, and you need to create a database for your PrestaShop site, and create one mysql user.
Firstly, you need to log in to your MySQl shell by issue the following command:
$ sudo mysql -u root -p
Then run the following SQL statement to create a new database called myprestashop in the MySQL Shell prompt:
Mysql> create database myprestashop;
Outputs:
mysql> create database myprestashop; Query OK, 1 row affected (0.00 sec)
Next, you need to create a MySQL username called mypres and you also need to grant the necessary permissions to this user account, just issue the following MySQL commands:
Mysq> create user 'mypres'@'localhost' identified by 'password'; Mysql> grant all on myprestashop.* to 'mypres'@'localhost'; Mysql> flush privileges; Mysql> exit;
Outputs:
mysql> create user 'mypres'@'localhost' identified by 'password'; Query OK, 0 rows affected (0.00 sec) mysql> grant all on myprestashop.* to 'mypres'@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)
Step6: Downloading the Latest PrestaShop Package
Now you can download the latest version of PrestaShop package (1.7.5.2) from its official website. You’d better download the package on the /var/www/html/mytest.com directory with wget command:
$ cd /var/www/html/mytest.com $ sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip
Outputs:
devops@devops:/var/www/html/mytest.com$ sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip --2019-07-05 06:38:53-- https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip Resolving download.prestashop.com (download.prestashop.com)... 184.28.14.204 Connecting to download.prestashop.com (download.prestashop.com)|184.28.14.204|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 71376003 (68M) [application/zip] Saving to: ‘prestashop_1.7.5.2.zip’ prestashop_1.7.5.2.zip 100%[=================================================================================>] 68.07M 961KB/s in 52s 2019-07-05 06:39:46 (1.30 MB/s) - ‘prestashop_1.7.5.2.zip’ saved [71376003/71376003]
When the download is complete, you need to extract the PrestaShp archive file to your current directory, run:
$ unzip prestashop_1.7.5.2.zip
Outputs:
devops@devops:/var/www/html/mytest.com$ sudo unzip prestashop_1.7.5.2.zip Archive: prestashop_1.7.5.2.zip inflating: prestashop.zip inflating: index.php inflating: Install_PrestaShop.html
Step7: Installing PrestaShop
Before you install PrestaShop, you still need to assign the right directory ownership for /var/www/html/mytest.com directory, so that the Apache web server can have full access to your website’s files and directories, issue the following command:
$ sudo chown www-data: /var/www/html/mytest.com/ $ sudo chmod -R 755 /var/www/html/mytest.com/
Then you can begin to install PrestaShop through the web interface, you just need to open your browser, and type your domain name or IP address, you should get a screen similar to the below screenshot:
Choose your language, then click Next button to continue the installation.
Select “I agree to the above terms and conditions” option, click next button to continue.
The installation script will check PrestaShop compatibility with your system environment.
Next, you need to enter your shop detail, such as: Shop name, username, password, etc. click Next button to continue.
Enter the database details that you created in the above step, such as: database name, database username, password, then click next button. The installation will start now.
Once your installation is completed, and it will show the following page. And it indicates that the PrestaShop has been installed on your ubuntu server.
If you want to your PrestaShop administrative dashboard, just click on the Manage your store button. And you need to enter your username and password for authentication.
Conclusion
You should know that how to install and use PrestaShop on your Ubuntu or Debian Linux. If you want to see more detailed information about PrestaShop, you can directly go to its official web site.