OpenCart is a popular open source shopping cart solution designed to provide excellent functionality, ease of use, and appearance. With OpenCart, you can easily build an online store on a LAMP- or LEMP-based server.
In this tutorial, we will introduce how to install OpenCart on a Vultr LEMP server instance.
Before further reading, you need to:
- Deploy a fresh server instance with the one-click Vultr LEMP App.
- Log in as a sudo user from your SSH terminal.
Step 1: Setup a database for OpenCart
Find the default MySQL credentials of Vultr LEMP:
sudo cat /root/.my.cnf
Use the credentials displayed on the screen to log into MySQL:
mysql -u root -p
Create a database in the MySQL shell with the following commands. Be sure to replace the database name “opencart”, the user name “opencartuser”, and the password “opencartpassword” with your own ones.
CREATE DATABASE opencart;
CREATE USER 'opencartuser'@'localhost' IDENTIFIED BY 'opencartpassword';
GRANT ALL PRIVILEGES on *.* TO 'opencartuser'@'localhost' IDENTIFIED BY 'opencartpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Step 2: Download the OpenCart package
Download the latest stable version of OpenCart, which as of writing is 2.1.0.2, from its github repository:
cd ~
wget https://github.com/opencart/opencart/archive/2.1.0.2.tar.gz
Unzip the OpenCart package, delete the default files in your server’s Web directory, and then move necessary files into it:
tar -zxvf 2.1.0.2.tar.gz
cd /usr/share/nginx/html/
sudo rm background.jpg index.php logo.png
sudo cp -R ~/opencart-2.1.0.2/upload/* .
Step 3: Prepare the OpenCart installation files
Setup the configuration files:
sudo mv config-dist.php config.php
sudo mv admin/config-dist.php admin/config.php
Modify the ownership of each installation file:
sudo chown -R nginx:nginx ./*
sudo service nginx restart
Step 4: Install OpenCart from your browser
Visit http://[your-server-ip] from your browser to continue the installation.
First, click the “Continue” button to agree the license.
On the second screen, check server requirements for installing OpenCart. With a Vultr LEMP server instance configured as above, these requirements are already satisfied. Click the “Continue” button to move on.
On the third screen, input the database name, the database username, and the database password you have setup in step 1, then fill in a username, a password and an email address for administration. Click the “Continue” button to finish the installation.
Step 5: Some basic security practices
For security purposes, you should also perform the following instructions on your machine.
Delete the “install” directory:
sudo rm -r /usr/share/nginx/html/install
Rename the “admin” directory to a name which is hard to guess, like “c2tdfjk”:
sudo mv admin c2tdfjk
Modify the “config.php” file in the “c2tdfjk” directory, replace every instance of “admin” with “c2tdfjk”:
cd c2tdfjk
sudo sed -i "s/admin/c2tdfjk/g" config.php
In the future, you can only access your admin panel from “http://[your-server-ip]/c2tdfjk”.
Conclusion
Now, you can visit your new online store from “http://[your-server-ip]”. Enjoy it.
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article