This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
See Instead: This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.
OpenCart is an widely used Open Source E-Commerce CMS which uses PHP & MySQL. It has its own Psuedo MVC structure and it is easier to handle and faster to setup. More information can be seen on <a href=“http://opencart.com/”>OpenCart</a> site.
This tutorial require the user to have root privileges. You can check that here: <a href=“https://www.digitalocean.com/community/articles/initial-server-setup-with-ubuntu-12-04”>Initial Server Setup.</a> Before working with OpenCart, you need to have LAMP installed on your VPS. If you don’t have it, then you can install it by following this tutorial: <a href=“https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6”>Installing LAMP Stack.</a>
Once we have the above requirements, we can start with the OpenCart installation.
First, we will navigate to the root folder where OpenCart will be installed. To do this, open the terminal and type in the following command:
cd /var/www
Then we will download the latest release of OpenCart (v1.5.5.1) from the github repo:
sudo wget https://github.com/opencart/opencart/archive/v1.5.5.1.zip
On running ls
command, you will find the v1.5.5.1.zip file in your www directory.
Now to unzip this folder, we will need to have Unzip module installed. In case you don’t have it, you can install it by inputting:
sudo apt-get install unzip
Now we will unzip this downloaded OpenCart zip file in the current directory:
unzip v1.5.5.1.zip
If you traverse the directory of extracted OpenCart folder, you will find the upload folder inside. We have to move the files & folders present in uploads
folder into the root www
folder. The next command will do that for us:
mv -v /var/www/opencart-1.5.5.1/upload/* /var/www
You can now find all the core files & folders of OpenCart directly sitting in your root www folder.
We will need to create a database which will be required during OpenCart Installation.
Log into your MySQL shell by command:
mysql -u root -p
Let’s create the database first (I’m setting my database name as opencart, but you can choose whatever name you want):
CREATE DATABASE opencart;
Query OK, 1 row affected (0.00sec)
In next steps, we will create a new database user with a password and grant access to the opencart database created above. Run the following commands carefully and keep noting down the username & password you choose.
Create database user:
CREATE USER opencartuser@localhost;
Query OK, 0 rows affected (0.00 sec)
Set password for this user:
SET PASSWORD FOR opencartuser@localhost= PASSWORD("yourpassword");
Query OK, 0 rows affected (0.00 sec)
Grant this new user permission to access the opencart database:
GRANT ALL PRIVILEGES ON opencart.* TO opencartuser@localhost IDENTIFIED BY 'yourpassword';
Query OK, 0 rows affected (0.00 sec)
Then we refresh MySQL so that the changes are effective:
FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
We are done with Database part, So now, we can log out of the MySQL Shell:
exit
Now we need to rename the OpenCart config files from config-dist.php
to config.php
. There are two such files: one in the direct www
folder and one inside the www/admin
folder:
cp /var/www/config-dist.php /var/www/config.php
Similarly:
cp /var/www/admin/config-dist.php /var/www/admin/config.php
We will give the ownership of our opencart files to the apache user by running the following command:
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data username
You are good to go. Simply hit your IP Address in browser (http://198.102../) to access the installation screen. After accepting the terms and conditions, you should see a screen similar to this:
All green indicates you are good to go ahead. In some cases, it might say that cURL & GD are not installed. It simply means that these php5 libraries are not installed on your VPS. You can install these libraries by running this simple command:
sudo apt-get install php5-curl php5-gd
Then you can refresh the page again and you should find the status against cURL & GD changed. On the third step, you will be asked to enter the database credentials we created above and then you are done :)
Once you have installed OpenCart, it is good practice and necessary from a security point of view to delete your install folder. We should be careful that only the install folder is to be deleted and not admin, catalog, or system folders. You can use the following command.
rm -rf /var/www/install/
Congratulations! You have just setup your own e-commerce site using OpenCart!
<div class=“author”>Article Submitted by: <a href=“http://jigarjain.com/”>Jigar Jain</a></div>
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hello, I have installed Lamp and everything, copied my site files, and changed config.php files. The site and the admin area seems to work and start. But when I go to checkout I get an internal server error or when I log in in the administration area everything I choose I get again internal server error anyone knows why?
@astarr thanks for your reply
I am using nginx I did these steps
I also did these steps add
extension=mcrypt.so
in php.ini thenit did the job :)
@lalitvohra2000: You can install and enable it with:
How to turn on mcrypt ?
Hi guys,
Not exactly on the topic but maybe your OpenCart users will find this beneficial. How to install OpenCart on a nGinx server: http://isenselabs.com/posts/how-to-install-and-run-opencart-on-nginx-server
if you feel like this post does not belong here you can remove it.
Thanks
For anyone who encounters the same problems I did during installation; when mcrypt cURL and gd have been installed they still showed as red for me. They must be turned on which you can do by just restarting apache, using “sudo service apache2 restart”
I wanted to install OC in a sub-domain. I downloaded & extracted the files. But when I try to move the files to the root of my sub-domain it says it’s not a directory.
My sub-domain name is shop.mydomain.tld. So, I did as follow,
wget https://github.com/opencart/opencart/archive/v1.5.6.1.zip
unzip v.1.5.6.1
while I was inside the extracted opencart-1.5.6.1 folder I executed
mv /upload/. /var/zpanel/hostdata/zadmin/public_html/shop_mydomain_tld
It returned with the error "shop_mydomain_tld is not a directory.
Any ideas?
I am on CentOS.
@gorodsb: You can install mcrypt by running the following command: <pre>sudo apt-get install php5-mcrypt</pre>
How can I turn on Mcrypt? (only it is marked as red)
@startsev.ar You can also use other services like Mandrill(their SMTP settings) for sending emails through Opencart in case if you have any problems with postfix