How to Install OpenCart on Ubuntu 24.04


OpenCart is an open-source as well as free e-commerce platform that is efficient and customizable for online merchants to create their online presence. Installing OpenCart on Ubuntu 24.04 ensures that your e-commerce platform runs efficiently with robust performance and enhanced security. The combination of OpenCart’s user-friendly management area and Ubuntu’s reliability makes for a powerful tool for managing multiple online stores, handling user privileges, and processing transactions.

This article will teach step-by-step instructions for installing OpenCart on an Ubuntu 24.04 system.

How to Install OpenCart on Ubuntu 24.04?

Installing OpenCart on an Ubuntu server involves a series of steps that include updating the system packages, installing a web server like Apache or Nginx, setting up a database such as MariaDB, and configuring PHP settings. Let’s carry forward to the step-by-step instructions:

Step 1: System Update Packages

Start by upgrading the Ubuntu package to make sure all your packages and software are up to date. This can be done with the below commands:

sudo apt update
sudo apt upgrade

Step 2: Install Apache

Apache is a famous choice and OpenCart needs a web server, and. Let’s install Apache using the “apache2” package name:

sudo apt install apache2

After installation, start the service as well as enable Apache to run on startup:

sudo systemctl start apache2 # State Apache
sudo systemctl enable apache2 # Enable Apache

Step 3: Install PHP

OpenCart is written in PHP, so users are required to install PHP along with several extensions that OpenCart requires:

sudo apt install php php-cli libapache2-mod-php php-common php-mbstring php-gd php-intl php-xml php-mysql php-zip php-curl php-xmlrpc

Verify the PHP installation with the version or “v” option as below:

php -v

Step 4: Install MariaDB

MariaDB is a database server that OpenCart uses to store its data. For instance, install MariaDB with the “apt” command:

sudo apt install mariadb-server mariadb-client

After installation, check the status to ensure it’s running:

sudo systemctl status mariadb

Users can also secure MariaDB by setting a password via the given command:

sudo mysql_secure_installation # Secure MariaDB

Step 5: Create a Database for OpenCart

Now, log in to the MariaDB console, then create a specific database and user for OpenCart. After that, granting the necessary privileges afterward:

sudo mariadb
CREATE DATABASE opencart;

CREATE USER 'opencart'@'localhost' IDENTIFIED BY '1212';
GRANT ALL PRIVILEGES ON opencart.* TO 'opencart'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Note: Users can replace “username” as well as “password” based on their choice.

Step 6: Download and Install OpenCart

Download the latest version of OpenCart from the official website or GitHub with the help of the “wget” utility:

sudo wget https://github.com/opencart/opencart/releases/download/4.0.0.0/opencart-4.0.0.0.zip

Unzip the files and move them to your web server’s root folder:

sudo apt install unzip
sudo unzip opencart-4.0.0.0.zip -d /var/www/html/opencart/

Copy configuration files for OpenCart:

sudo cp /var/www/html/opencart/upload/{config-dist.php,config.php}
sudo cp /var/www/html/opencart/upload/admin/{config-dist.php,config.php}

After copying configuration files, now, users need to enable permission by mentioning the path:

sudo chown -R www-data:www-data /var/www/html/opencart/

Step 7: Create Virtualhost for Opencart

Configuring the web server, whether it’s Apache or Nginx, includes editing configuration files to point to the correct directory where OpenCart is installed:

sudo nano /etc/apache2/sites-available/opencart.conf

Now, paste the below text into the configuration file. Users can modify the ServerName by replacing “linuxgenie” according to preferences:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/opencart/upload/
ServerName linuxgenie.com
ServerAlias www.linuxgenie.com

<Directory /var/www/html/opencart/upload/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/linuxgenie.com-error_log
CustomLog /var/log/apache2/linuxgenie.com-access_log common
</VirtualHost>

After that, save and close the file after modifications.

Step 8: Configure Apache for OpenCart

After creating a new Apache configuration file for your OpenCart site. Let’s enable the site and rewrite the module:

sudo a2ensite opencart.conf
sudo a2dissite 000-default
sudo systemctl restart apache2

Step 9: Finalize OpenCart Installation

The final steps involve running the OpenCart installation script by accessing the web interface. For this, navigate to the domain or IP address in a web browser and follow the OpenCart installation wizard:

Note: For finding the ip address use the “ip a” command in the Linux terminal.

It guides you through setting up an administrator account, configuring store settings, and installing additional modules if needed. Then, hit the “Continue” button:

Fill in the database details as well as admin user information to complete the installation:

With OpenCart on Ubuntu, businesses can take advantage of a customizable shopping cart system that supports various payment gateways and extensions, providing a scalable solution for online commerce:

Bonus: Post-Installation Steps

It’s also advisable to secure the OpenCart installation by setting file permissions correctly and using .htaccess files to protect sensitive directories.

By following these steps, users have a fully functional OpenCart installation on the Ubuntu 24.04 system. For more detailed instructions, users can refer to the OpenCart documentation.

Conclusion

OpenCart on Ubuntu offers a flexible and cost-effective way to expand your online presence Whether you’re a small business owner or managing multiple storefronts. To install OpenCart on Ubuntu 24.04, update system packages, install the Apache web server, PHP MariaDB. Then create a database for OpenCart. Once these components are in place, you can proceed to download and configure OpenCart itself. These steps set up the environment needed to run OpenCart on the Ubuntu server.

Categories