How to Deploy Zencart on Ubuntu 22.04

Updated on July 25, 2024
How to Deploy Zencart on Ubuntu 22.04 header image

Introduction

Zen Cart is an open-source e-commerce platform used to set up and manage online store applications. It's highly customizable and allows you to build an online store based on your needs. Zen Cart also supports additional features and extensions you can integrate to ease the publication of products or services for sale online.

This article explains how to deploy Zen Cart on a Ubuntu 22.04 server and secure it for public use.

Prerequisites

Before you begin:

Set Up the Zen Cart Database

Zen Cart uses a MySQL database server as the backend. Follow the steps below to create a new Zen Cart database using your Vultr Managed Database for MySQL to improve the application performance and reliability.

  1. Log in to your Vultr Managed Database for MySQL cluster. Replace example.vultrdb.com, and 16751 with your actual database details.

    console
    $ mysql -h example.vultrdb.com -P 16751 -u vultradmin
    

    Enter your Vultr Managed Database for MySQL when prompted.

  2. Create a new Zen Cart database zencart.

    console
    mysql> CREATE DATABASE zencart;
    
  3. Create a new MySQL user with a secure password to use with the Zen Cart database.

    console
    mysql> CREATE USER 'zencart'@'localhost' IDENTIFIED BY 'securepassword';
    
  4. Grant the user full privileges to the database.

    console
    mysql> GRANT ALL PRIVILEGES ON zencart.* TO 'zencart'@'localhost';
    
  5. Refresh the MySQL privileges table to apply changes.

    console
    mysql> FLUSH PRIVILEGES;
    
  6. Exit the MySQL shell.

    console
    mysql> EXIT;
    

Download Zen Cart

  1. Install all required PHP modules on your server.

    console
    $ sudo apt install php-mysqli php-mbstring php-json php-gd php-xml
    
  2. Download the latest Zen Cart release file using wget.

    console
    $ wget https://github.com/zencart/zencart/archive/refs/tags/v2.0.0.zip --no-check-certificate
    

    The above command installs the Zen Cart version 2.0.0, visit the official website to verify the latest version to download on your server.

  3. Extract files from the Zen Cart archive using the Unzip utility.

    console
    $ unzip v2.0.0.zip
    
  4. Move the extracted files to your web root directory /var/www/html.

    console
    $ sudo mv zencart-2.0.0 /var/www/html/zencart
    
  5. Copy the Zen Cart sample configuration file dist-configure.php as configure.php.

    console
    $ sudo cp /var/www/html/zencart/includes/dist-configure.php /var/www/html/zencart/includes/configure.php
    
  6. Grant the Apache web server user and group www-data ownership privileges to the Zen Cart directory.

    console
    $ sudo chown -R www-data:www-data /var/www/html/zencart
    
  7. Change the Zen Cart directory permissions to 755.

    console
    $ sudo find /var/www/html/zencart/ -type d -exec chmod 755 {} \;
    
  8. Change the Zen Cart file permissions to 644.

    console
    $ sudo find /var/www/html/zencart/ -type f -exec chmod 644 {} \;
    

Configure the Apache Web Server

  1. Create a new Apache virtual host configuration file to use with Zen Cart

    console
    $ sudo nano /etc/apache2/sites-available/zencart.conf
    
  2. Add the following configurations to the file.

    apacheconf
    <VirtualHost *:80>
        ServerAdmin admin@example.com
        DocumentRoot /var/www/html/zencart/
        ServerName zencart.example.com
    
        <Directory /var/www/html/zencart/> 
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory> 
    
        ErrorLog /var/log/apache2/zencart-error_log
        CustomLog /var/log/apache2/zencart-access_log common
    
     </VirtualHost>
    

    Save and close the file.

    The above configuration creates a new Zen Cart profile using the /var/www/html/zencart web root directory.

  3. Enable the Zen Cart virtual host configuration.

    console
    $ sudo a2ensite zencart.conf
    
  4. Enable the Apache rewrite module to allow Zen Cart to rewrite URL rules.

    console
    $ sudo a2enmod rewrite
    
  5. Restart Apache to apply changes.

    console
    $ sudo systemctl restart apache2
    

Secure Zen Cart with Trusted SSL Certificates

Secure Zen Cart with HTTPS traffic by generating trusted SSL certificates that are essential when protecting customer data, search engine presence, online store compliance requirements and customer experience. Follow the steps below to secure Zen Cart with trusted SSL certificates.

  1. Allow the HTTP port 80 through the default UFW firewall.

    console
    $ sudo ufw allow 80/tcp
    
  2. Allow the HTTPS port 443.

    console
    $ sudo ufw allow 443/tcp
    
  3. Reload the Firewall table to apply changes.

    console
    $ sudo ufw reload
    
  4. Install the Certbot Let's Encrypt client using Snap.

    console
    $ sudo snap install certbot --classic
    
  5. Generate a new SSL certificate for your Zen Cart domain. Replace zencart.example.com and hello@example.com with your actual details.

    console
    $ sudo certbot --apache --redirect -d zencart.example.com -m hello@example.com --agree-tos
    

    When successful, your output should look like the one below:

    Deploying certificate
    Successfully deployed certificate for zencart.example.com to /etc/apache2/sites-available/zencart-le-ssl.conf
    Congratulations! You have successfully enabled HTTPS on https://zencart.example.com
  6. Test the Certbot automatic certificate renewal process.

    console
    $ sudo certbot renew --dry-run
    

    When successful, your output should look like the one below:

    Account registered.
    Simulating renewal of an existing certificate for zencart.example.com
    
    Congratulations, all simulated renewals succeeded: 
      /etc/letsencrypt/live/zencart.example.com/fullchain.pem (success)

Access Zen Cart

  1. Visit your Zen Cart domain using a web browser such as Chrome.

    https://zencart.example.com

    Verify that the Zen Cart splash screen displays in your browser.

    Zencart Welcome Screen

  2. Click the CLICK HERE option to start the Zen Cart configuration process.

  3. Verify that the System Inspection includes little or no dependency errors.

  4. Click Continue to perform a requirements check on your server and click Continue to access the System Setup page.

    System Setup Screen

  5. Agree to the application license terms, and enter your domain in the Admin Server Domain field. Then, click enable SSL for a storefront and set up your additional domain paths.

  6. Click Continue to save changes and access the Database Setup page.

  7. Enter your Vultr Managed Database for MySQL URL in the Database Host field. Then, enter your Zen Cart database details and the user you created earlier.

    Database Setup Screen

  8. Click Continue to save your database configurations and access the Admin Setup page.

  9. Enter your administrator username, and email. Then, copy the generated temporary user password to your clipboard.

    Admin Setup Screen

  10. Click Continue to start the Zen Cart installation process on your server.

  11. Verify the Zen Cart Admin Backed dashboard and Storefront links in your Zen Cart Set Up Complete.

    Zen Cart Installation Finished

  12. Click the Admin backend link to access the Zen Cart login page.

  13. Enter your Zen Cart administrator username and temporary password to log in. Then, click Submit to access the initial setup wizard.

Initial Setup Wizard Screen

  1. Enter your store name, owner, store owner email address, store country, store zone and store address details in the respective fields. Then, click Update to save changes.

    Zen Cart Dashboard

    You can now manage your online store, add new products and store information in your Zen Cart dashboard.

  2. Visit your Zen Cart frontend store and verify that the default demo products are available on your store's front page.

    https://zencart.example.com

    Zen Cart Frontend Store Screen

  3. Delete the Zen Cart installation directory from your web root directory to secure your application.

    console
    $ sudo rm -rf /var/www/html/zencart/zc_install
    

Conclusion

You have deployed Zen Cart on a Ubuntu 22.04 server and secured the application with trusted Let's Encrypt SSL certifications. Configure your Zen Cart application to showcase and display your products or services for sale using your domain. For more configuration options, visit the Zen Cart documentation.