Install and configure OpenCart under LNMP [Tutorial]

OpenCart is a set of excellent, free and open source e-commerce solutions. In fact, it is simply an online store program. The discussion on the advantages and disadvantages of OpenCart, Prestashop, Zen Cart, etc. is not included in this article. Recently, I'm working on this OpenCart. I'll simply share with you some information about the LNMP built under VPS (for the installation of LNMP, see here )How to install and configure OpenCart in the environment. Of course, I'm just learning, old bird~

Install and configure OpenCart under LNMP [Tutorial]

  1. Add virtual host under LNMP
  2. Install OpenCart
  3. Nginx pseudo static setting of OpenCart

1、 Add virtual host under LNMP

1. For example, add, the command is as follows,


This article has been updated, and this step is no longer required. Note: Please select [y] to add rewrite rule options and set it as opencart (Nginx will create a file named opencart.conf, which we will use later to write specific pseudo static)

2. Switch to your virtual host directory (assuming your directory is/home/wwwroot/

cd /home/wwwroot/

2、 Install OpenCart

1. Download OpenCart (please check the latest version on the official OpenCart website)


2. Unzip OpenCart (Note: If unzip is invalid, please install the zip program)

unzip opencart_

3. Move the upload folder to the root directory of the virtual host

mv upload/* ./

4. Modify file permissions

chown -R www /home/wwwroot/
chmod 0755 image/
chmod 0755 image/cache/
chmod 0755 cache/
chmod 0755 download/
chmod 0755 config.php
chmod 0755 admin/config.php

5. The browser accesses your domain name to install the graphical interface

Note: If the file permission error is still prompted, please refer to step 2 (3) to continue modifying in SSH

6. The database creation and graphical interface installation under PHPMyAdmin will not be explained. It should not be a problem

7. For security reasons, delete the install folder (Update 2011-12-4!)

rm -rf install

3、 Nginx pseudo static setting of OpenCart

Update on May 25, 2012: The previous pseudo static rules were wrong, which could lead to various problems. Many blog websites copied and reproduced them directly, and Weimo strongly condemned them! Again, we would like to state that WeChat Magic welcomes reprinting, but please keep the original link to stimulate the enthusiasm for originality!

Before execution, please select Enable Use SEO URL's under OpenCart background System ->Settings ->Server. This is mainly to hope that OpenCart can implement pseudo static like WP, which is more conducive to SEO

1. Open the conf file


2. Click [Insert] in location~. * . (php | php5)$ Add the following content before the field ( please change to your own domain name)

 location / { if ($host != '') { rewrite ^/(.*)$ $1 permanent; } try_ files $uri @opencart; } location @opencart { rewrite ^/(.+)$ /index.php?_ route_=$ 1 last; } location /admin/ { index index.php; } location ~* (\.(tpl|ini))$ { deny all; }

3.【ESC】->:wq! Save and Exit

At present, there are so many operations for me. If you have any problems, you are welcome to put forward, and I hope you can also recommend some good website building programs to Weimo. For details, please see QQ Contact Me on the right!

Guess you like

About the author: Micro magic

Small demons, great wisdom!

Multiple comments

    1. If the pseudo static is uncertain, the simplest way is to install lnmpa (add apache on the basis of Lnmp...), cd lnmp0.8/ It seems that Go to to see the details. It's always good to do more and learn more

  1. I opened a new site on VPS, used the LNMP environment, centOS system, and tried several methods, but they all failed. So did you, first or last, which led to the collapse of all VPS websites!

  2. Hehe, private letter owner, said to add location~. * . (php | php5)$ Before this paragraph, remember to back up the files, add them, save them, and then enter reboot to restart! I will add it later

Post reply

Your email address will not be disclosed. Required items have been used * tagging