3.234.254.115

How to Install OpenCart on CentOS 7

How to Install OpenCart on CentOS 7

OpenCart is a free, open source ecommerce web application. It is written in PHP and uses MySQL to store its database. OpenCart is an alternative to Magento and has almost the same set of features.

You can easily manage products, categories, customers, coupons and orders. It also has built-in SEO and multiple stores, which means you can easily manage multiple stores from a single admin interface. You can expand its capabilities using thousands of available themes and plugins. It supports multiple payment gateways, product reviews and ratings, bonus points. It has been translated into over 40 languages and supports multiple currencies. You can easily manage products, categories, customers, coupons and orders. It also has built-in SEO and multiple stores, which means you can easily manage multiple stores from a single admin interface. You can expand its capabilities using thousands of available themes and plugins. It supports multiple payment gateways, product reviews and ratings, bonus points. It has been translated into over 40 languages and supports multiple currencies..

In this guide, we will install OpenCart on a CentOS 7 server..

Requirements

OpenCart does not require special hardware requirements. All necessary dependencies will be installed throughout the lesson. You will need a minimal installation of CentOS 7 with root access. If you are logged in as a non-root user, you can run sudo -i to switch to the root user.

Install OpenCart

Before installing any package, it is recommended that you update the packages and repository using the following command.

yum -y update

After updating the system, you can proceed to install the LAMP stack. Launch the LAMP installation by installing the Apache web server and MariaDB, which is a fork of MySQL, using the following command.

yum -y install httpd mariadb-server mariadb

OpenCart can be installed on any version of PHP more than 5.4. As PHP v5.4 comes to an end, we will install PHP 7 to improve performance and security. PHP 7 is not included in the YUM repository by default, so you will need to add the Webtatic repository to your system. Webtatic repository requires EPEL repository to work. Run the following command to install the EPEL repository.

yum -y install epel-release yum -y update

Now install the Webtatic repository using the following commands.

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum -y update

To install PHP 7.1 and all the necessary PHP modules, run the following command.

yum -y install php71w php71w-curl php71w-mysqli php71w-cli php71w-zlib php71w-gd php71w-mcrypt php71w-mbstring php71w-xml

After installing PHP, you can check the version of PHP using the following command.

php -v

You should get a conclusion similar to this.

[root@liptan-pc ~]# php -v
PHP 7.1.5 (cli) (built: May 12 2017 21:54:58) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Now start the Apache web server and enable it at boot time using the following command.

systemctl start httpd systemctl enable httpd

To start MariaDB and enable it at boot time, use the following commands.

systemctl start mariadb systemctl enable mariadb

Now run the following commands to protect your MySQL or MariaDB installation.

mysql_secure_installation

It will run a small script that asks you to provide the root password for MariaDB. Since we just installed MariaDB, the root password is not set, just press Enter to continue. He will ask you if you want to set the root password for your MariaDB installation, select y and set a strong password for the installation. He will also ask you to delete test databases and anonymous users. Most of the questions speak for themselves, and you should answer yes or all questions.

To create the database, we first need to enter the MySQL command line. Run the following command for the same

mysql -u root -p

This will ask you for a password, enter the MySQL root password that you set earlier. Now run the following query to create a new database for your OpenCart installation.

CREATE DATABASE ocart_data;

The above query will create a database named ocart_data. Make sure you use a semicolon at the end of each query, as the query always ends with a semicolon. After creating the database, you can create a new user and grant him all the permissions for the database. Using the root user is not recommended for databases. To create a new database user, run the following query.

CREATE USER 'ocart_user'@'localhost' IDENTIFIED BY 'StrongPassword';

The above query will create a user with username ocart_user. You can use any preferred username instead of ocart_user. Replace StrongPassword with a strong password. Now grant the appropriate privileges to the user of your database over the database you created. Run the following command.

GRANT ALL PRIVILEGES ON ocart_data.* TO 'ocart_user'@'localhost';

Now run the following command to immediately apply changes to database privileges.

FLUSH PRIVILEGES;

Exit MySQL command line using exit command.

Since we have all the dependencies ready, now we can download the installation package from the OpenCart website.

cd /var/www wget https://github.com/opencart/opencart/releases/download/2.3.0.2/2.3.0.2-compiled.zip -O opencart.zip

You can always find the link to the latest version of the application on the OpenCart download page. Unzip the archive using the following command.

unzip opencart.zip -d opencart

If you do not have the unpacked archive installed, you can run

 yum -y install unzip

You will also need to rename the configuration files. Run the following commands for the same.

mv /var/www/opencart/upload/config-dist.php /var/www/opencart/upload/config.phpmv /var/www/opencart/upload/admin/config-dist.php /var/www/opencart/upload/admin/config.php

Now you need to create a virtual host for your web application. Run the following command for the same.

nano /etc/httpd/conf.d/shop.yourdomain.com.conf

Paste the following lines into the file.


ServerAdmin me@liptanbiswas.com
DocumentRoot /var/www/opencart/upload
ServerName shop.yourdomain.com
ServerAlias www.shop.yourdomain.com

Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted

ErrorLog /var/log/httpd/shop.yourdomain.com-error_log
CustomLog /var/log/httpd/shop.yourdomain.com-access_log combined

Replace shop.yourdomain.com with any domain or subdomain that you want to use to access the application. Save the file and exit the editor. Run the following command to restart the Apache server.

systemctl restart httpd

Now you will need to grant ownership of the application to the web server user using the following command.

cd /var/www chown -R apache:apache /var/www/opencart

You may also need to allow HTTP traffic through port 80 through the firewall if you are using it. Run the following commands to do this.

firewall-cmd --zone=public --permanent --add-service=http firewall-cmd –reload

You will also need to disable SELinux. To temporarily disable SELinux without restarting the server, run the following command.

setenforce 0

To completely disable SELinux, you need to edit the / etc / selinux / config file.

nano /etc/selinux/config

Find the following line:

SELINUX=enforcing

Change it to:

SELINUX=disabled

Now complete the installation using a web browser, click on the following link using your favorite web browser.

http://shop.yourdomain.com

You will see the following page. Click Continue to continue. In the following interface, the installer will check if your system meets all the requirements for installing OpenCart. If you completed the lesson correctly, then all requirements will be met. Click Continue to continue. In the following interface, you will need to provide database and administrator data. Choose a database driver like MySQLi. Provide the username, password, and database name that you created earlier. Leave the default value in the text box for host name, port, and prefix. Provide the username, password, and administrator email address. Click Continue to continue. OpenCart is now installed, before you access the admin panel, you need to delete the installation folder. Run the following command for the same.

rm -rf /var/www/opencart/upload/install

Now you can access the store interface at the following URL:

http://shop.yourdomain.com

You will see the following site.

To access the admin panel, go to the following link.

http://shop.yourdomain.com/admin

Conclusion

In this sample, we learned how to install OpenCart on a CentOS 7 server. Now you can use OpenCart to sell your products online to large people. This will increase sales and profits..