How to Build e-Commerce Site with ZenCart in Ubuntu 15.10 / CentOS 7

ZenCart is a free and open source online store management system based on PHP and MySQL. It is user friendly, easy to manage e-Commerce site management tool which is freely available under GNU GPL license version 2. It is platform independent as its a web based application which can be run through any web browser once its installed in a server. ZenCart is developed by a group of like-minded shop owners, programmers, designers, and consultants that think ecommerce web design could be, and should be, done differently. Some of the features of ZenCart making it such a popular application are listed as follows.

  1. Localization is the most important feature in ZenCart with the support of multiple tax rates, shipping methods, payment methods, currencies and languages.
  2. We can add unlimited number of products, categories and set attributes to them.
  3. It has ability to integrate different payment modules including a custom module.
  4. It helps to maintain good relationship between the shop owner and customers.
  5. Gifts, coupons, shipping rate, shipping options, tax rate, tax zone can be easily configured with ZenCart.
  6. ZenCart is pretty easy to install in almost any hosting server that supports PHP and MySQL.

Installing LAMP Stack

In order to run ZenCart in our machine running Ubuntu 15.10 or CentOS 7, we'll need to make sure that LAMP stack is installed in our system. LAMP Stack stands for the combination of Apache Web Server, MariaDB or MySQL Database server and PHP modules in a Linux server. Here in this tutorial, we'll install MariaDB instead of MySQL server for database as MariaDB is completely community driven with speed improvements and free extensions. To do so, we'll need to run the following commands under root or sudo privilege with respect to the distribution of linux installed in the machine.

On Ubuntu 15.10

# apt-get update
# apt-get install apache2 mariadb-server libapache2-mod-php5 php5-mysql php-pear php5-gd php5-curl php5-dev php5-ldap php5-xcache unzip

On CentOS 7

# yum update
# yum install httpd mariadb-­server php-­mysql php-­pear php-gd php-­xml php­-curl php­-dev php-mbstring php-ldap php-­xcache unzip

Starting Apache and MariaDB server

After we have installed the required dependencies, we'll now start our Apache web server and MariaDB database server.

On Ubuntu 15.10

As Ubuntu 15.10 is shipped with systemd as the default init system, we'll use systemctl command to start them. To do so, we'll need to run the following command.

# systemctl start apache2 mysql

Then, we'll make them start automatically in every system boot by enabling the daemons.

# systemctl enable apache2 mysql

apache2.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable apache2
mysql.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable mysql

On CentOS 7

Likewise, CentOS 7 is also shipped with systemd as the default init system so, we'll simply need to run the following command in our linux terminal or console.

# systemctl start httpd mysql

Next, as we did with Ubuntu, we'll simply enable the daemons to start in every system boot.

# systemctl enable httpd mysql

Setting MariaDB Root Password

On CentOS 7/Ubuntu 15.10

Now, as we have instaled MariaDB for the first time and no password has been set for MariaDB root user so, we’ll first need to configure a root password for it.

To configure MariaDB and assign a root password, we’ll need to run the following command.

# mysql_secure_installation

This will ask us to enter the password for root but as we haven’t set any password before and its our first time we’ve installed mariadb, we’ll simply press enter and go further. Then, we’ll be asked to set root password, here we’ll hit Y and enter our password for root of MariaDB. Then, we’ll simply hit enter to set the default values for the further configurations.

so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!
installation should now be secure.
Thanks for using MariaDB!

Note: Please note the MariaDB root password in a secure place as we'll require it to create a database for ZenCart in further steps.

Creating ZenCart Database

We'll now go for creating a new database for our ZenCart so that it can store its data into our MariDB database. To do so, first we'll need to login to our MariaDB console by running the following command.

# mysql -u root -p

Then, it will ask us to enter the password of root user which we had just set in the above step. Then, we'll be welcomed into the MariaDB console in which we'll creat

e our new database, database user and assign its password and grant all privileges to create, remove and edit the tables and data stored in it. Here, we'll set database name, user and password as zencartdb, zencartuser and Pa$$worD123 respectively.

> CREATE USER 'zencartuser'@'localhost' IDENTIFIED BY 'Pa$$worD123';
> GRANT ALL PRIVILEGES ON zencartdb.* TO 'zencartuser'@'localhost';

Creating ZenCart Database MariaDB

Note: It is strongly recommended to replace all the above variables ie database name, user and password for security measure.

Configuring Apache Web Server

Now, we'll gonna add a new virtualhost in our apache web server so that we can define a specific configuration to our ZenCart website. Creating a new virtualhost will help us to define ports, webroot, domain, alias and other configurations for our site. Here are some configurations we'll setup in this tutorial respective to the distribution of linux we're running.

On Ubuntu 15.10

# touch /etc/apache2/sites-available/zencart.conf
# ln -s /etc/apache2/sites-available/zencart.conf /etc/apache2/sites-enabled/zencart.conf
# nano /etc/apache2/sites-available/zencart.conf

Now, we'll gonna add the following lines of configuration into the opened file.

<VirtualHost *:80>
DocumentRoot /var/www/zencart/
<Directory /var/www/zencart/>
Options FollowSymLinks
AllowOverride All
ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ common

After done, we'll gonna save the file and exit the text editor. Then, we'll need to make sure that mod is enabled. To enable it, we'll need to execute the following command.

# a2enmod rewrite

Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart

Then, we'll restart our apache web server.

# systemctl restart apache2

On CentOS 7

In our CentOS machine, we'll create a file named zencart.conf under /etc/httpd/conf.d/ directory using a text editor.

# nano /etc/httpd/conf.d/zencart.conf

Then, we'll gonna add the following lines of configuration into the file.

<VirtualHost *:80>
DocumentRoot /var/www/zencart/
<Directory /var/www/zencart/>
Options FollowSymLinks
AllowOverride All
ErrorLog /var/log/httpd/
CustomLog /var/log/httpd/ common

Once done, we'll simply save the file and exit the editor. We'll now need to make sure that mod is enabled. To enable it, we'll need to execute the following command.

# a2enmod rewrite

And then, we'll gonna restart our apache web server.

# systemctl restart httpd

Downloading and Extracting ZenCart

After we have done with above steps, we'll now gonna download the latest release of ZenCart ie 1.5.5 during the time of writing this article. We can get the latest release from the official SourceForge page . Here, we'll get the download link from the sourceforge ZenCart page and then use wget to download it into our server.

# cd /tmp/
# wget

--2016-05-12 14:12:15--
Resolving (
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7716138 (7.4M) [application/octet-stream]
Saving to: ''
zen-cart-v1.5.5a-05 100%[=====================>] 7.36M 800KB/s in 17s
2016-05-12 14:12:34 (435 KB/s) - '' saved [7716138/7716138]

Once its downloaded successfully, we'll gonna extract the zip file using the following unzip command.

# unzip

Then, we'll move the extracted files under the webroot of our webserver that we had just specified above ie /var/www/zencart/ . So, first of all, we'll need to create the webroot directory ie /var/www/zencart as its not created yet.

# mkdir -p /var/www/zencart
# mv zen-cart-v1.5.5a-05052016/* /var/www/zencart

Fixing Ownership and Permission

Now, we'll need to set the ownership of the ZenCart directory to the Apache process user so that apache web server will have full access over the ZenCart files and folders. To do so, we'll need to run the following commands with respect to distribution of linux we are running, as there are different usernames used.

On Ubuntu 15.10

# chown -R www-data: /var/www/zencart

On CentOS 7

# chown ­-R apache: /var/www/zencart

Then, we'll need to set the permission of some directories as writable by executing the following command.

Configuring Firewall

Next, we'll gonna configure the firewall program to allow http or port 80 to expose out of the box. This will allow our ZenCart store to be accessible within the network connected or the internet. As both CentOS 7 and Ubuntu 15.10 are shipped with systemd as init system, firewalld are installed in most machines. To allow http (port 80) we'll need to run the following command.

# firewall-cmd --permanent --add-service=http


# firewall-cmd --reload


Web based Installation

Once everything above is setup and configured correctly as mentioned above, we'll now go towards the web based installation of ZenCart. To do so, we'll need to open a web browser and point it to our ZenCart server ie according to our configuration. Then, we'll see the following screen as we're performing the installation for the first time.

Starting ZenCart Web Installation

We'll now click on "Click here" link located under reason number 1 inorder to continue the installation process. Then, a page "System Integration" will appear which will check and list if we have any problem with our Zen Cart installation. As we haven't configured SSL certification in this article, we'll surely get the error regarding SSL certification.

ZenCart System Setup

Next, we'll need to agree to the GNU GPL 2 license by applying the tick. As we'll want the default settings to go, we'll simply click Continue to continue the installation process further.

Zencart Database Configuration

Now, we'll need to perform the database setting. We'll simply need to enter the database configuration that we had setup in the above steps while creating the database for ZenCart . Here in this tutorial, we'll gonna enter host, database name, username and password as localhost, zencartdb, zencartuser and Pa$$worD123 respectively. If we wanna load the demo data into the database, we can tick it then, we can simply set the settings as our need. Here, we'll gonna leave it as it is and move ahead.

Zencart Admin Setup

Once done, we'll be directed to Admin Setup where we'll need to enter the admin name and email address. Here, the admin password and admin directory are genearted automatically by ZenCart installer. We can change them later once the installation is done.

Note: Please note that, these admin credentials should be noted as they will be required further for logging into the admin panel.

Setup Completed

After that, we'll see a Setup Finished page where we'll be asked to delete /zc_install/ directory as per the security measures so that someone cannot access to the installation of ZenCart further. Here, we can see the links through which we can access to the storefront and backend admin panel.

Post Installation

Once the installation is completed, we'll need to remove the installation ie zc_install from the webroot. To do so, we'll need to get into the web root directory of our ZenCart website by running the following command.

# cd /var/www/zencart/

Then, we'll recursively delete the installation directory.

# rm -rf zc_install


It is very easy to deploy our own e-Commerce website with ZenCart. Though it not mentioned in this article, it is always recommended to setup SSL certification for the ZenCart website as this adds an additional security layer to your business website. Following this tutorial, one should be able to quickly deploy ZenCart in the machine running CentOS 7/Ubuntu 15.04 and its derivatives. So, if you have any questions, suggestions, feedback please write them in the comment box below. Thank you ! Enjoy  :-)

Arun Pyasi 3:00 am


Your email address will not be published. Required fields are marked *

All comments are subject to moderation.