How to Install OpenCart on CentOS 7

Select distribution:
Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

What is OpenCart?

OpenCart is free open source ecommerce platform for online merchants. OpenCart provides a professional and reliable foundation from which to build a successful online store. This foundation appeals to a wide variety of users; ranging from seasoned web developers looking for a user-friendly interface to use, to shop owners just launching their business online for the first time. OpenCart has an extensive amount of features that gives you a strong hold over the customization of your store. With OpenCart’s tools, you can help your online shop live up to its fullest potential.

Before You Begin

  1. You should set up LAMP on CentOS 7.

  2. Install the Extra Packages for Enterprise Linux (EPEL) repository. sudo yum install epel-release

  3. Make sure your server packages are up to date. sudo yum update

  4. Install the unzip utility. sudo yum install unzip

PHP Setup

Make sure that you have the following PHP extensions/modules installed (They should be installed by default on almost all PHP installations):

  • Curl
  • Zip
  • Zlib
  • GD Library
  • Mcrypt
  • Mbstrings
  • Xml

You can install them by running the following commands:

sudo yum install php-mcrypt curl zlib php-gd php-mbstring php-xml php-mysql

Create a Database and User

You will need to make sure you have a MySQL database and a database user set up for OpenCart. To create a database and a database user, please complete the following instructions:

  1. Login to MySQL/MariaDB:

    mysql -u root -p
    

    Enter your MySQL/MariaDB root password when prompted. You should now see a MySQL prompt similar to

    MariaDB [(none)]>
    
  2. Create a new database and user with permissions to use it for OpenCart:

    create database opencart;
    grant all on opencart.* to 'ocuser' identified by 'yourpassword';
    flush privileges;
    

    In the above example, opencart is the name of the database, ocuser the user, and yourpassword a strong password.

  3. Exit MySQL/MariaDB.

    quit
    

Install OpenCart

Download OpenCart and configure permissions

Issue the following commands to download and unpack OpenCart into your web root directory:

cd /var/www/html/example.com/public_html/
curl -OL https://github.com/opencart/opencart/releases/download/2.3.0.2/2.3.0.2-compiled.zip
unzip 2.3.0.2-compiled.zip 'upload/*'
cp upload/config-dist.php upload/config.php
cp upload/admin/config-dist.php upload/admin/config.php
sudo chown -R apache:apache upload
shopt -s dotglob
mv upload/* .
rm -rf upload

In the above example, replace /var/www/html/example.com/public_html/ with your virtual host’s web root and 2.3.0.2-compiled.zip with the file name of the latest OpenCart release.

Note
You can find the latest version of OpenCart from their Download Page.

Next, run the following commands to make sure these directories are writable.

chmod 0755 system/storage/cache/
chmod 0755 system/storage/logs/
chmod 0755 system/storage/download/
chmod 0755 system/storage/upload/
chmod 0755 system/storage/modification/
chmod 0755 image/
chmod 0755 image/cache/
chmod 0755 image/catalog/
chmod 0755 config.php
chmod 0755 admin/config.php

Run the OpenCart Installer

Visit your website in your browser. You should be redirected to the OpenCart Installer in a page that looks like this:

Press CONTINUE and you will see the Pre-Installation page.

Make sure that you see the green checkmark for every section before proceeding. If you see any red marks, please go back and make sure all of the instructions in this guide were followed properly. Once you’ve confirmed that every section has a green checkmark, press the CONTINUE button to see the OpenCart configuration page:

Here, select the MySQLi driver and fill out the form with the relevant information from the Create a Database and User section of this guide. You also need to select a username and password for the default administrator account for this OpenCart installation.

Finally, press the CONTINUE button and you should now see the Installation complete screen. You will also see a warning box telling you to remove your installation directory. We can do this by going back to your web root directory and running:

rm -rf install

Once you’ve done that, the installation is complete. Browse to

http://example.com/admin

In the above example, example.com is your domain name.

You can now login using the administrator account details you entered previously.

Now that you have your OpenCart installation up and running, there are a few more steps that we recommend. Because of the security-sensitive nature of ecommerce websites, you will want to make sure your system is secure.

  1. Make sure you follow our Securing Your Server guide.

  2. Secure your website with SSL/TLS. Learn to Install a SSL certificate with Apache on CentOS 7. Once you’ve installed a certificate, enable Use SSL by following the Opencart Documentation on SSL.

  3. Follow the Basic Security Practices from the OpenCart documentation.

  4. Install vQmod if you wish to use 3rd party extensions.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.