Install OpenCart on Linux VPS Hosting

Install OpenCart on Linux VPS Hosting

OpenCart is a widely-used e-commerce software by leading brands and businesses worldwide. An e-shop is expected to have a lot of visitors and it needs to be secure – so Linux VPS hosting for your OpenCart website is a perfect choice. Before we begin the tutorial, you need to know why you should host your website on a Linux VPS:

Why You Should Host OpenCart on a Linux VPS

  • It’s more secure and stable. A Linux server is far more secure than a Windows server. If you add some extra security plugins to your OpenCart and if you install an SSL – your website will be secured properly. You must secure your OpenCart e-shop since you’ll be dealing with a lot of personal information from your customers.
  • It’s faster than Shared hosting. That’s a bit obvious, but VPS and Dedicated servers are a lot faster than a shared server. You need to improve the user experience as much as you can in order to increase sales on your e-commerce website.
  • It’s easier to install. If you compare the methods of installing OpenCart on a Linux VPS vs a Windows VPS, installing it on Linux is easier and more beginner-friendly. You can even use the 1-click-install from Softaculous or you can just follow this tutorial step-by-step.
  • It’s more extensible. You can do almost whatever you want with your Linux VPS, especially if you have full root access. This will come in handy when you’d want to change something to your website, but a Shared hosting wouldn’t allow you to.

All in all you should use a VPS or a Dedicated server for your online store. Linux is preferred. You can get a VPS from RoseHosting, they offer fully-managed VPS hosting with free 24/7 support and they will help you install, set up or migrate your OpenCart based website for free.

Now to the main point of our post. Installing OpenCart is fairly easy on any Linux distro. Just follow these simple steps and you will have your OpenCart instance in no-time.

How To Install OpenCart on a Linux VPS

OpenCart has some minimal requirements for your server, but most servers already meet those requirements:

  • Web Server (Apache suggested)
  • PHP (at least 5.3)
  • Curl enabled
  • Database (MySQL suggested)

This tutorial was prepared and tested for an Ubuntu 16.04 VPS, but the instructions are the same for other Debian-based distros.

We will start by installing Apache. If you have Apache already installed, skip this step. To install the Apache Web Server, log in with your SSH user and password and run the following command:

1
sudo apt-get install apache2

Next, install MySQL server using the following command:

1
sudo apt-get install mysql-server

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:

1
sudo mysql_secure_installation

To install PHP and the other requirements you need to run the command:

1
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql curl php-curl php-gd php-zip

Next, download and configure OpenCart on your Linux VPS by using the commands below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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

Now, create an Apache virtual host for OpenCart

1
sudo nano /etc/apache2/sites-available/opencart.conf

Add the following content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/opencart
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com
    <Directory /var/www/html/opencart/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    ErrorLog /var/log/apache2/yourdomain.com-error_log
    CustomLog /var/log/apache2/yourdomain.com-access_log common
</VirtualHost>

Replace yourdomain.com with your actual domain name.

Enable the OpenCart virtual host and restart the Apache web server using the following commands:

1
2
sudo a2ensite opencart
sudo systemctl restart apache2

Create a MySQL database, user and set up password for OpenCart:

1
2
3
4
5
mysql -uroot -p
mysql> CREATE DATABASE opencart;
mysql> GRANT ALL PRIVILEGES ON opencart.* TO 'opencartuser'@'localhost'     IDENTIFIED BY 'opencart_passwd';
mysql> FLUSH PRIVILEGES;
mysql> \q

Replace opencart_passwd with a more secure password of your choice.

Next, open a web browser and enter your domain name in the search bar to continue with the online installation. After the successful install, delete the install/ directory with the following command:

1
rm -rf /var/www/html/opencart/install/

The installation of OpenCart is complete. Now you can start using your OpenCart website. If you need any additional help either contact your web hosting provider or refer to the official OpenCart documentation.

Author: