How To Install OpenCart 2.x.x on a VPS Using Ubuntu 14.04

Do you wish to install OpenCart on a VPS but you don’t have an idea how to? Well jump in and learn! Here is a step-by-step easy tutorial on how you would exactly do that.

But first, why do you ever need it to install on a Virtual Private Server (VPS) when you could use a Shared Hosting Service which is way more easy to use.

Well, shared hosting are fun and easy to use especially for newbie webmasters, because it offers an easy to use control panel (like cPanel or DirectAdmin) which let you install any CMS script easily.

Also, shared hosting are ideal for testing purpose or development and could also be for students or self-learners who wants to be a Webmaster.

But shared hosting has limitations, though other companies market their service as “unlimited shared hosting”.

If you have OpenCart on a shared hosting service, by the time you started receiving traffic and gain more clients, you start to consume more server resources like RAM, bandwidth and processing power.

And if you consume a lot of computing resources way more than your neighbors on the same server, then that would be a red flag on your hosting provider. They will notice that and will suspend your account.

Your shared hosting company will suspend your hosting account and will send you a notice that your website is using too much server resources, though they advertised their service as unlimited.

Now the best thing you can do to keep up with your website traffic and to add more computing power to your OpenCart store, is to use a Private Server or Dedicated Server.

With Private Server or Virtual Private Server, you have your own server resources. You have your own dedicated memory, storage space, bandwidth and virtual CPU. But that’s not the case of Dedicated Server.

Dedicated servers are not virtual, they do not run as virtual machines. They are bare-metals or computers with it’s own hdd, memory, cpu, chassis, network connection and software that are offered for rent.

So much for the intro, let’s get started with the procedure and follow the easy steps to install OpenCart on a VPS (Virtual Private Server).

Jump Links

OpenCart Server / System requirements

To successfully install OpenCart on a VPS, these extensions must be installed and enabled on the Web Server.

For this guide, we’ll be using Apache 2.4 for the Web Server.

OpenCart Needs:

  • PHP (at least 5.2)
  • Database (MySQLi suggested)

Required PHP libraries / modules:

  • Curl
  • ZIP
  • Zlib
  • GD Library
  • Mbstrings
  • Mcrypt

We’ll be using Digital Ocean as our VPS host, since they provide an easy way to setup a webserver on an Ubuntu 14.04 VPS.

Their LAMP (Linux Apache MySQL PHP) application installer should take care of Apache, PHP-5 and MySQL installation and will also install and enable the required modules.

Except for the PHP5 extension called Mcrypt, we have to manually configured that ourselves.

Buy ready-to-use OpenCart Themes – Click here!

Installing OpenCart

Here comes the fun part…

But you need to prepare the following requirements first.

You need to have:

  • Hosting account with Digital Ocean (at least 1GB RAM)
  • PuTTy if you’re on Windows
  • Terminal App if you’re on Linux
  • SSH Key Pair
  • Few hours of your time, of course

I’ve mentioned about hosting account above, you might ask…

Where to buy a VPS Hosting Account? other than what you have stated above.

You actually have the option to use any VPS host you would want. But you need to install and setup LAMP differently. What you need to look for is Un-managed VPS Hosting, which means that you yourself should manage/provision your own server. If you are a tech/internet savvy person, you could save a lot of money by managing your own VPS. The internet is full of info about how to manage your own VPS.

You could follow this step-by-step guide on how to setup a webserver, then come back here to continue the OpenCart installation part.

Other VPS Hosting Account You May Use With OpenCart:

Let’s get started!

Step 1: Create a VPS with LAMP

  • Login to your Digital Ocean account and click on the Create Droplet button.

  • Enter a hostname with your domain name.

    Say for example:

    lamp1.chubbable.com
    
  • Choose a package.

    If you just want to play around, you may opt to choose 5USD/monthly. But if you’re migrating your OpenCart store from a shared hosting service, then 10US/monthly should be minimum.

  • Choose a Region or Location

    It’s best if you choose the location of your Data Center that is closest to your target audience.

    If you target Western Europe, you may choose either London or Amsterdam.

    Singapore if you target Asian audiences.

    But this makes no sense if you plan to use a CDN with your OpenCart website.

  • Select Image / Application

    click on the Applications tab and scroll down a bit and click to choose LAMP 14.04. When activated, it should turn blue.

  • Create an SSH Key Pair to use with your OpenCart VPS

    If you’re on Windows, then follow this video tutorial on how to create SSH Key Pair on Windows.

    If you’re on Linux, this video guide will teach you how to create your SSH Key Pair for your VPS.

    Copy and paste in the content of your .pub SSH key. Enter a comment or name for it.

    Make sure it is saved and activated, the button turns blue when activated.

  • Finally, click on the Create Droplet button. This should start creating your VPS.

Tha’s all for creating your VPS. LAMP should be installed after your droplet is created.

Step 2: Login to your OpenCart VPS

  • Login to your newly created VPS and use your IP address. Copy the IP address from your hosting control panel.

    Then launch a terminal (or PuTTy if on Windows) and SSH your way in to your VPS.

    The command should be…

    ssh -i .ssh/name-of-your-ssh-key [email protected]
    

    Note 1: In Linux or Unix, the default SSH folder path is ~/.ssh or /home/anyuser-name/.ssh

    Note 2: This command-prompt signifies that you’re on your home folder; chubbable@i7core ~ $. The ~ character (or tilde) signifies any user’s home folder.

    You’d be ask for your SSH key password, if you opted to fill those up. If not, then you’ll not be ask for it.

  • Secure MySQL server by following the wizard.

    Take note first of your MySQL root password. Write it down or copy to somewhere safe.

    Reference Image: how-to-install-opencart-on-vps-first-time-login

    Now run mysql_secure_installation and follow the wizard.

    Enter mysql_secure_installation command and enter your copied MySQL root password.

    Then answer the following question like so:

    Change the root password? - answer n for no
    
    Remove anonymous users? - answer n for no
    
    Disallow root login remotely? - answer n for no
    
    Remove test database and access to it? - answer n
    
    Reload privileges? answer y for yes
    

    And it should be all done after that.

Step 3: Update the system & install Unzip

  • Update your system by doing the following command.

    apt-get update && apt-get upgrade
    

    It should take a little while to complete.

  • Install Unzip via apt-get, this software shall be used to extract the download archived file o OpenCart.

    To install the software….

    apt-get install unzip -y
    

Step 4: Download OpenCart & Extract

  • Download OpenCart files from it’s official GitHub repository page:

    https://github.com/opencart/opencart
    

    To download the file remotely to your OpenCart VPS, right-click on the Download ZIP button (right-side of the page) and copy the link address.

    While still on your terminal, type wgetthen SPACEBARthen paste in the copied download link address, and hit ENTER key. The command should look like below.

    wget https://github.com/opencart/opencart/archive/master.zip
    
  • Do a ls command on your ~ (home) folder, you should see a new file named master.zip

  • Extract the file by doing unzip command:

    unzip master.zip
    

    Do a ls command.

    You shold see a new folder named opencart-master

  • Copy the contents of the upload folder, which is inside of opencart-master folder, to /var/www/html. This folder should hold all the OpenCart files, it’s your public_html folder.

    If you make a cd opencart-master command, you should see the folder.

    To copy all the files inside the upload folder… do the following command;

    cp -R * ~/opencart-master/upload/ /var/www/html/
    

    Double-check that you have copied all the files, do the following;

    cd /var/www/html
    

    Then do a ls command.

    Reference Image: how-to-install-opencart-on-vps-opencart-files-copied

Step 5: Create OpenCart config.php file

The command;

touch /var/www/html/admin/config.php

and…

touch /var/www/html/config.php

Step 6: Set folder permission and owner

  • To set folder owner for the OpenCart folder, do the following command;

    chown -R www-data:www-data /var/www/html
    
  • To set folder permisson, that is… 755 for all folders while 644 for all files;

    chmod -R a=r,a+X,u+w /var/www/html
    

Step 7: Enable Mcrypt PHP module

The LAMP installer doesn’t automatically enable mcrypt properly on your VPS, so we need to do some extra steps to enable it.

Reference Image: how-to-install-opencart-on-vps-mcrypt-disabled

  • This is how to enable mcrypt on your Ubuntu 14.04 VPS.

    Do the following command;

    updatedb
    
  • Then find out where mcrypt is located on your server;

    locate mcrypt.so
    

    Sample output would be;

    /usr/lib/libmcrypt.so.4
    /usr/lib/libmcrypt.so.4.8
    /usr/php520121212/mcrypt.so
    

    You should take note of mcrypt.so location.

  • Find out where mcrypt.ini is located so you could edit it and update the location of the mcrypt.so module.

    Let’s do that now;

    locate mcrypt.ini
    

    Sample output;

    /etc/php5/mods-available/mcrypt.ini
    
  • Edit mcrypt.ini and update mcrypt.so’s location, so do the following command;

    nano /etc/php5/mods-available/mcrypt.ini
    

    Sample file content;

    ; configuration for php MCrypt module
    extension=mcrypt.so
    

    Now, change extension=mcrypt.so

    To

    extension=/usr/php520121212/mcrypt.so
    

    The /usr/php520121212/mcrypt.so is the result of the locate mcrypt.so command we did above.

    Save the fle and exit the editor;

    ctrl + o + enter then ctrl + x

  • Enable the module by doing the command php5enmod mcrypt

  • Restart Apache webserver

    service apache2 restart
    

Step 8: Create OpenCart Database

Let’s create a new database for OpenCart exclusive use. We will use the command-line, so no PHPMyAdmin involve here.

  • Login as root to MySQL server

    mysql -u root -p
    

    Then enter your root password. It won’t be printed on your screen.

  • Create the database

    For the sake of demonstration, I will name my OpenCart database as opencartdb, user is opencartuser, password is letmepass.

    So here we go…

    create database opencartdb;
    

    Hit Enter key.

  • Create the database user and grant privileges

    grant all on opencartdb.* to 'opencartuser'@'localhost' identified by 'letmepass';
    

    Hit enter key.

  • Refresh MySQL

    flush privileges;
    

    That’s it! That’s how to create a database using command-line. Next, install OpenCart.

Step 9: Install OpenCart

Time to install OpenCart

  • Launch your favorite web browser and point to your VPS IP address.

    You should be redirected to OpenCart’s installation wizard.

    Check the page, make sure that all is green. Which means… all the requirements are met by your VPs.

    Everything is straight-forward on this page, just fill all the fields with the proper data and install OpenCart.

    Reference Image: how-to-install-opencart-on-vps-opencart-requirements-met

    Click Continue button till you finish installing it.

    Reference Image: how-to-install-opencart-on-vps-opencart-installed-success.png

  • Delete the install folder for security reason.

    rm -rf /var/www/html/install
    

    And that’s it! If you reached this far, then pat yourself on the back.

OpenCart Custom Logo Designs – Click Here!

It’s a Wrap

So now that you have an OpenCart VPS, the next thing you should do is to setup and configure basic server security before opening your store to the public.

I’ve written a guide on securing a VPS, and I encourage you to read and apply what’s written in there. It is very important to secure your OpenCart installation since your VPS is your business on the Internet.

I hope you followed this guide successfully, if not… feel free to get some help by posting your comments below.

If this post helped you out and you’re happy with the results, please consider sharing it to your friends.

Learning how to install OpenCart on a VPS with Ubuntu 14.04 is not that hard. So long as you’re fueled to do it, you can do it.

By the way… you could make a Snapshot of your OpenCart VPS by using the snapshot action button on your hosting control panel. You could use the snapshot image to restore your VPS from it’s previous state.

…and one more thing, don’t you know that you could also install OpenCart on a portable server? Yes you could! You could put it on a USB drive and plug it in any Windows-based computers.

Chubbable

Hi, I'm Chubby! That's what my friends call me. I'm a tech savvy dude who is passionate in learning stuffs by himself. I post stuffs that I recently learned and also stuffs that I'm very knowledgeable of. I also post articles here to serve as my own reference and knowledge base archiving.