Advance

How to Install Opencart with Nginx and SSL on Debian 10

How to Install Opencart with Nginx and SSL on Debian 10

OpenCart is a professional and open-source store-building system that is designed based on numerous features and applications, as well as a user-friendly appearance. It also creates a complete and unique online store and can be used for online business. This store building system is one of the most popular systems used in online stores today. The very attractive and user-friendly appearance of OpenCart allows the seller to create a complete and unique online store and use it for their online business. OpenCart has gained so much popularity and popularity due to its amazing features such as having extremely powerful SEO, various and functional modules and templates, being multilingual, supporting various local and global payment gateways. In this article, we try to learn you How to Install Opencart with Nginx and SSL on Debian 10. If you want to buy a VPS server, you can see the packages available in Eldernode.

Tutorial Install Opencart with Nginx and SSL on Debian 10

To install Opencart with Nginx and SSL on Debian 10, you need to follow the steps in this tutorial. In the first step, you must update the system using the following commands. After executing these commands, you must restart the system once.

apt-get update -y
apt-get upgrade -y
Recommended Article: How to Reset forgotten Debian Linux password [Top Way]

How to Install LEMP Server

After updating and restarting the system, you must now install LEMP Server. First you need to install the requirements for Opencart using the following commands:

apt-get install nginx mariadb-server php-common php-cli php-fpm php-opcache php-gd php-mysql php-curl php-intl php-xsl php-mbstring php-zip php-bcmath php-soap unzip git -y

Now you need to open one of the text editors and edit the php.ini file. We use the nano editor here.

nano /etc/php/7.3/fpm/php.ini

After opening the file, change its variables as follows and save it.

memory_limit = 256M  upload_max_filesize = 100M  opcache.save_comments=1  max_execution_time = 300  date.timezone = Europe/London

Tutorial Configure MariaDB Database

It should be noted that the MariaDB root password is not set in Debian 10. So you have to do this after entering MariaDB with the help of the following command:

mysql
MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("yournewrootpassword");

After setting the password, you should now set the MariaDB authentication plugin to mysql_native_password. To do this, run the following commands:

MariaDB [(none)]> SET GLOBAL innodb_fast_shutdown = 0;
MariaDB [(none)]> UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';

You must now flush the privileges using the following commands:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

In the next step you can enter MariaDB using the following command:

mysql -u root -p

Once you have successfully completed the above steps, now is the time to create your database and user using the following commands:

MariaDB [(none)]> CREATE DATABASE opencartdb;
MariaDB [(none)]> GRANT ALL ON opencartdb.* TO 'opencart'@'localhost' IDENTIFIED BY 'password';

Flush the privileges again after the changes have been made:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

How to Download OpenCart

Download OpenCart using the following command:

wget https://github.com/opencart/opencart/releases/download/3.0.3.2/opencart-3.0.3.2.zip

Then extract the downloaded file using the following command:

unzip opencart-3.0.3.2.zip

The next step is to go to the Nginx web root directory by running the following command:

mv upload /var/www/html/opencart

Now you need to change the directory to opencart and rename the config-dist.php file using the following commands:

cd /var/www/html/opencart/
mv config-dist.php config.php
mv admin/config-dist.php admin/config.php

Finally you need to give the necessary permissions to the opencart list:

chown -R www-data:www-data /var/www/html/opencart/
chmod -R 775 /var/www/html/opencart/

In the next step we will go to the Nginx configuration for OpenCart. Please stay tuned for the rest of this article.

Recommended Article: How to Install Opencart with Nginx and SSL on Debian 10

Learn how to Configure Nginx for OpenCart

In this part of the tutorial, we get to the Nginx for OpenCart configuration step. You must create a Nginx virtual host configuration file for the OpenCart service by running the following command. Open the opencart.conf file using the nano editor.

nano /etc/nginx/sites-available/opencart.conf

Put the following content in the configuration file:

server {  listen 80;  server_name opencart.domain.com;  root /var/www/html/opencart;  index index.php;  access_log /var/log/nginx/opencart_access.log;  error_log /var/log/nginx/opencart_error.log;    location = /favicon.ico {  log_not_found off;  access_log off;  }    location = /robots.txt {  allow all;  log_not_found off;  access_log off;  }    location / {  try_files $uri $uri/ /index.php?$args;  }    location ~ \.php$ {  include snippets/fastcgi-php.conf;  fastcgi_pass unix:/run/php/php7.3-fpm.sock;  }    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {  expires max;  log_not_found off;  }    }

Save the content after inserting it in the configuration file. Now you should check Nginx for syntax errors:

nginx -t

Note that the output of the above command must be similar to the following commands:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

After making sure that the above commands are executed correctly, you can now enable the Nginx virtual host file:

ln -s /etc/nginx/sites-available/opencart.conf /etc/nginx/sites-enabled/

At the end of this step, you must restart Nginx and PHP-FPM using the following commands:

systemctl restart nginx
systemctl restart php7.3-fpm

How to Secure OpenCart with Let’s Encrypt SSL

In this step, you need to install the Certbot client to install Let’s Encrypt on your website. So you need to create a Certbot repository using the following command:

echo "deb http://ftp.debian.org/debian buster-backports main" >> /etc/apt/sources.list

In the next step, you must update the system using the first command. You must also use the second command to install the Certbot client for Nginx:

apt-get update -y
apt-get install python3-certbot-nginx -t buster-backports

Now you need to download Let’s Encrypt SSL. You will also need to configure Nginx to use SSL:

certbot --nginx -d opencart.domain.com

You will need to provide your valid email address in the next step.

In the following, you will encounter an image like the one below. In this section you have to choose whether to direct HTTP traffic to HTTPS or not. So you have to select “2” and press Enter to complete the installation.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    1: No redirect - Make no further changes to the webserver configuration.    2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for  new sites, or if you're confident your site works on HTTPS. You can undo this  change by editing your web server's configuration.  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Conclusion

Opencart is an OpenSourece content management system for building online stores. Being open source means you can make changes to it to personalize it for you. Opencart is perfect for anyone who wants to start a small, compact internet business. In this article, we tried to learn you How to Install Opencart with Nginx and SSL on Debian 10.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day