This Opencart tutorial is to show you how to install OpenCart on a CentOS-7 64bit which is an Enterprise-class Linux Distribution VPS (Virtual Private Servers), we install Apache, PHP, MySQL, other PHP packages as needed by Opencart and setup virtual host
Login to your VPS
ssh root@IPPROVIDED
Then enter the password.
Now update your system before installing the applications, by updating your server using the command below
sudo yum update
Now install the apache web server by running the command, if it is already installed then you can skip this step as mostly there are installed
sudo yum install httpd
Now start the apache service, which you can do it by the following command as per your system
sudo service httpd start
Till now you can check by typing the IP address provided, you will see the Apache page, mine IP http://178.33.153.139/ and it shows like below:
Better to activate Apache to start after system boot which we can do by the following command:
chkconfig httpd on
Next, install the MySQL server using the following command:
sudo yum install mysql-server
Tell it which run levels to start on:
sudo /sbin/chkconfig --levels 235 mysqld on
Then start the MYSQL server
sudo service mysqld start
To improve the security of your MySQL server, it is recommended to run the interactive security script. You can do that by using the following command:
sudo mysql_secure_installation
Then it asks multiple questions to set the username and password for the database. Once you remove the anonymous users, then disallowing root login remotely, removing test database and reloading privileges on test database then your MySQL installation should be secure.
Like we did for Apache let’s run the MySQL on reboot by the following command:
chkconfig mysqld on
Now let’s install PHP and the other requirements that are needed for the OpenCart, you need to run the command:
sudo yum install php libapache2-mod-php php-mcrypt php-mysql curl php-curl php-gd php-zip
Once all those PHP packages are installed, our server is almost ready. Next, let’s download and configure OpenCart on your VPS by using the commands below:
sudo mkdir /var/www/html/opencart
cd /var/www/html/opencart
sudo wget https://github.com/opencart/opencart/archive/master.zip
sudo unzip master.zip
sudo mv opencart-master/upload/* .
sudo mv opencart-master/upload/.htaccess.txt .htaccess
sudo rm -f master.zip
sudo cp config-dist.php config.php
sudo cp admin/config-dist.php admin/config.php
sudo chown -R www-data: /var/www/html/opencart
sudo chmod 0755 system/storage/cache/
sudo chmod 0755 system/storage/logs/
sudo chmod 0755 system/storage/download/
sudo chmod 0755 system/storage/upload/
sudo chmod 0755 system/storage/modification/
sudo chmod 0755 image/
sudo chmod 0755 image/cache/
sudo chmod 0755 image/catalog/
sudo chmod 0755 config.php
sudo chmod 0755 admin/config.php
Let’s add Nano Text Editor
yum install nano
Next, create an Apache virtual host for OpenCart
sudo nano /etc/httpd/conf/httpd.conf
Add the following VirtualHost content:
<VirtualHost *:80>
ServerAdmin admin@domain.com
DocumentRoot /var/www/html/opencart
ServerName domain.com
ServerAlias www.domain.com
<Directory /var/www/html/opencart/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/domain.com-error_log
CustomLog /var/log/httpd/domain.com-access_log common
</VirtualHost>
Replace domain.com with your actual domain name.
Enable the OpenCart virtual host and restart the Apache webserver using the following commands:
sudo a2ensite opencart
sudo service httpd restart
Login to the MySQL database
mysql -u root -p
Create a MySQL database, user and set up a password for OpenCart:
CREATE DATABASE webocreation;
GRANT ALL PRIVILEGES ON webocreation.* TO 'webocreationuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Replace webocreation with your database name, webocreationuser with your username and password with your password.
Open a web browser and enter your domain name and start the installation.
Let us know any questions about the VPS Virtual Private Servers and any questions about OpenCart in the comment below.