How to Install PrestaShop on Debian 9

/ Category: Tutorials / Comments: None

How to Install PrestaShop on Debian 9
Spread the love

In this article, we will show you how to install PrestaShop on a Debian 9 VPS. Prestashop is an easy to use open source shopping cart application written in PHP used by website developers to build and run a successful online store. To install PrestaShop on a Debian 9 VPS follow the very easy steps described below.

Requirements

At the time of writing this tutorial, the latest stable version of PrestaShop is v1.7.4.2 and it requires:

  • Nginx or Apache Web Server
  • MySQL 5.5 or later is recommended, or MariaDB installed on your Linux virtual server.
  • PHP 5.4 or higher with the following PHP extensions enabled: mcrypt, cURL, GD, GZIP and PDO.
  • Full SSH root access or a user with sudo privileges is also required

Step 1: Log in via SSH on the Ubuntu server:

Log in to the VPS via SSH as user root

ssh roo@IP_Address -p Port_number

Step 2: Update all OS packages

Once you are logged, run the following command to make sure that all installed OS packages are up to date:

apt-get update
apt-get upgrade

Step 3: Install Nginx, MariaDB and PHP 7

Stop and disable Apache service:

systemctl stop apache2
systemctl disable apache2

Install Nginx from Debian package repository. Simply, run the following command to install Nginx on your server:

apt-get install nginx

After the installation is complete, Nginx will automatically start.
To verify that Nginx is running on the server, you can use the following command:

systemctl status nginx

Make sure that Nginx server is configured to automatically start upon a server boot:

systemctl enable nginx

Install MariaDB and PHP 7 on your server using the following commands:

apt-get install mysql-server
apt-get install php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-xml php7.0-mcrypt php7.0-mbstring

Enable MariaDB and php-fpm to automatically start upon a server boot:

 systemctl enable mariadb.service
 systemctl enable php7.0-fpm.service

Step 4: Install PrestaShop

Download the latest stable version of PrestaShop in the /opt directory on your server and extract it in the /var/www/html/ directory:

cd /opt
wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip
unzip prestashop_1.7.4.2.zip
unzip prestashop.zip -d /var/www/html/prestashop/

Step 5: Modify the PHP configuration

Edit the ‘/etc/php/7.0/fpm/php.ini’ PHP configuration file.
Modify the memory_limit value to 128MB or higher:

memory_limit = 256M

Also, set upload_max_filesize to 32 MB (or more):

upload_max_filesize = 32M

Also, modify the following settings:

file_uploads = On
allow_url_fopen = On

Restart the php-fpm service for the changes to take effect:

systemctl restart php7.0-fpm.service

Step 6: Set file permissions

The web server user (www-data) needs to be able to write to files and directories inside the ‘/var/www/html/prestashop’ directory, so it can easily be accomplished by executing the following command:

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

Step 7: Configure Nginx to serve PrestaShop

Create a new Nginx server block:

vi /etc/nginx/sites-available/your-domain.com

and add the following content:

server {
server_name your-domain.com;
listen 80;
root /var/www/html/prestashop/;
access_log /var/log/nginx/your-domain.com_access.log;
error_log /var/log/nginx/your-domain.com_error.log;

index index.php;

rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$1$2.jpg last;
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /img/c/$1$2.jpg last;
rewrite ^/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+.jpg$ /img/c/$1.jpg last;
rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /img/c/$1$2.jpg last;
try_files $uri $uri/ /index.php?$args;

location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}

location ~ \.php {
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

Create a symbolic link:

ln -s /etc/nginx/sites-available/your-domain.com /etc/nginx/sites-enabled/your-domain.com

Restart the Nginx service for the changes to take effect:

systemctl restart nginx

Step 8: Create a MariaDB database for PrestaShop

Login to the MariaDB console with the root account:

mysql -u root -p

Create a MariaDB database, user and grant permissions to the user using the following command:

MariaDB [(none)]> CREATE DATABASE prestashop;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashop'@'localhost' IDENTIFIED BY 'Str0ngPa55w0rd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Do not forget to replace ‘Str0ngPa55w0rd’ with an actual strong password.

Open your favorite web browser and type in the following URL to access the PrestaShop web interface and start the setup:

http://your-domain.com/

From here you can finish the setup by selecting the installation language and entering the information about your PrestaShop store. Then, create an administrator account and enter the following information to configure the database:

Database server address: 127.0.0.1

Database name: prestashop

Database login: prestashop

Database password: enter the MariaDB password for the PrestaShop MariaDB user.

For security reason, you must delete the ‘install’ directory:

rm -rf /var/www/html/prestashop/install/

Once you deleted the installation directory, login to the PrestaShop back-end by clicking on the ‘Manage your store’ button.

installing prestashop on debian 9

Congratulations! PrestaShop has been successfully installed on your server. You can now start using PrestaShop and customize it according to your needs.


Of course, you don’t have to Install PrestaShop on a Debian 9 VPS if you use our Managed PrestaShop Hosting services, in which case you can simply ask our expert Linux admins to install PrestaShop on Debian 9, for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to Install PrestaShop on Debian 9, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Be the first to write a comment.

Your feedback