Install Zen Cart on Ubuntu 20.04

Updated on November 21, 2023
Install Zen Cart on Ubuntu 20.04 header image

Introduction

Zen Cart is a free, open-source shopping cart software with wide community support. It supports the installation of plugins to enhance functionality. Some major features are:

  • Customizable by changing the source code to fit your needs.
  • Built-in payment gateway integration to accept payments from different channels.
  • Simple user interfaces for ease of use.

This article explains how to install Zen Cart on Ubuntu 20.04 server.

Prerequisites

1. Install LAMP Server

Update system package manager.

$ sudo apt update

Install PHP 7.4 and other packages.

$ sudo apt install apache2 mysql-server php7.4 libapache2-mod-php7.4 php7.4-common php7.4-sqlite3 php7.4-json php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap php7.4-imap php7.4-bcmath wget unzip -y

Edit the PHP configuration file.

$ sudo nano /etc/php/7.4/apache2/php.ini

To search for a specific line, use Control + W, enter search phrase then press Enter.

memory_limit = 512M
upload_max_filesize = 100M
post_max_size = 100M

Enable the web server to start automatically on a reboot.

$ sudo systemctl enable apache2

Enable the database server to start automatically on a reboot.

$ sudo systemctl enable mysql

Restart web server for changes to take effect.

$ sudo systemctl restart apache2

2. Create Database for Zen Cart

Run mysql_secure installation script to secure MySQL database server from security breaches.

$ sudo mysql_secure_installation

When prompted, answer the questions as shown bellow:

  • Setup VALIDATE PASSWORD plugin? Press N, then Enter.
  • Remove anonymous users? Press Y, then Enter.
  • Disallow root login remotely? Press Y, then Enter.
  • Remove test database and access to it? Press Y, then Enter.
  • Reload privilege tables now? Press Y, then Enter.

Log in to MySQL shell. On password prompt, enter your password to continue.

$ sudo mysql -u root -p

Create a MySQL database named zencart.

CREATE DATABASE zencart;

Create a database user named zencartuser with a password. Change the value of StrongPassword with your own secure password.

CREATE USER 'zencartuser'@'localhost' IDENTIFIED BY 'StrongPassword';

Grant the user full access to the database.

GRANT ALL ON zencart.* TO 'zencartuser'@'localhost' WITH GRANT OPTION;

Save the changes.

FLUSH PRIVILEGES;

Exit the shell.

EXIT

3. Install Zen Cart

Download the latest version of Zen Cart. To find the latest version of the installation files, please visit files repository.

$ wget https://sourceforge.net/projects/zencart/files/CURRENT%20-%20Zen%20Cart%201.5.x%20Series/zen-cart-v1.5.7c-03052021.zip

Extract the downloaded installation files.

$ sudo unzip zen-cart-v1.5.7c-03052021.zip

Rename the extracted files' directory.

$ sudo mv zen-cart-v1.5.7c-03052021 zencart

Move the renamed directory to the web root.

$ sudo mv zencart /var/www/

Delete the downloaded files.

$ sudo rm zen-cart-v1.5.7c-03052021.zip

Change ownership of the installation directory.

$ sudo chown -R www-data:www-data /var/www/zencart

Change access permissions for the directory.

$ sudo chmod -R 755 /var/www/zencart

4. Configure Apache2

Allow port 80 through the firewall.

$ sudo ufw allow 80

Create a new Apache configuration file zencart.conf.

$ sudo nano /etc/apache2/sites-available/zencart.conf

Add the following content below into the file. Save and close the file:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/zencart
    ServerName example.com
    ServerAlias www.example.com

     <Directory /var/www/zencart/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Disable Apache default configuration file.

$ sudo a2dissite 000-default.conf

Enable Zen Cart Apache configuration file.

$ sudo a2ensite zencart.conf

Enable Apache rewrite mode.

$ sudo a2enmod rewrite

Restart Apache service.

$ sudo systemctl restart apache2

5. Access Zen Cart

To access the Zen Cart web interface, go to your browser and visit http://Server_IP/. For example:

http://192.0.2.10/

Conclusion

You have installed Zen Cart on your server. Access the installation wizard and complete the installation steps by connecting to your database and creating an administrator account. You can now log in to either of the portals.

After the installation process is complete, delete the installation directory for security reasons.

$ sudo rm -r /var/www/zencart/zc_install

More Information

To learn more about how to use Zen Cart, go to the official documentation page.