Embarking on the journey of creating your own online store can be an exciting endeavor, but it often begins with the foundational step of setting up a robust e-commerce platform. OpenCart stands as one of the leading solutions in this realm, renowned for its user-friendly interface and extensive customization options. In this comprehensive guide, we’ll walk you through the step-by-step process of installing OpenCart on the latest iteration of Ubuntu, version 22.04. By the end of this tutorial, you’ll have a fully functional OpenCart instance ready to power your online business ventures.
First, let’s begin by creating your VPSie Account if you haven’t already done so, and then proceed to install the Ubuntu 22.04 server as per your requirements.
To initiate the installation, please SSH into your system. Our first step is to advise updating your system prior to installing any software. To accomplish this, kindly execute the following commands:
sudo apt-get update
Install Apache webserver
The Apache HTTP Server is a free and open-source cross-platform web server. You can install it via apt package manager by executing the following command.
sudo apt install apache2
You can initiate the Apache service and set it to automatically run on startup with the following commands:
sudo systemctl start apache2
sudo systemctl enable apache2
Verify the status of the Apache service.
sudo systemctl status apache2
Install PHP
To set up PHP and additional PHP modules necessary for OpenCart support, execute the given command:
sudo apt-get 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 if PHP is installed.
php -v
Install MariaDB and create a database
To initiate the installation of MariaDB, execute the following command:
sudo apt install mariadb-server mariadb-client
Verify the status of the MariaDB service.
sudo systemctl status mariadb
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script.
sudo mysql_secure_installation
Configure it like this:
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Now run the command below to log in to the MariaDB shell.
sudo mysql -u root -p
Once you are logged in to your database server you need to create a database for the OpenCart installation:
MariaDB [(none)]> CREATE DATABASE opencart;
MariaDB [(none)]> CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'Your Password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON opencart . * TO 'opencart'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;
SetUp OpenCart
You can download the latest version of OpenCart from the Git repository using the following command:
sudo wget https://github.com/opencart/opencart/releases/download/4.0.0.0/opencart-4.0.0.0.zip
Unpack the file into the directory /var/www/html/opencart/ using the following command:
sudo apt -y install unzip
sudo unzip opencart-4.0.0.0.zip -d /var/www/html/opencart/
Copy OpenCart configuration files:
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}
Enable permission for the Apache webserver user to access the files:
sudo chown -R www-data:www-data /var/www/html/opencart/
Create Virtualhost for Opencart
Create an virtual host configuration file to host OpenCart:
sudo nano /etc/apache2/sites-available/opencart.conf
Paste the content as shown below:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/opencart/upload/ ServerName your-domain.com ServerAlias www.your-domain.com <Directory /var/www/html/opencart/upload/> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/your-domain.com-error_log CustomLog /var/log/apache2/your-domain.com-access_log common </VirtualHost>
Remember to replace your-domain.com with your domain name if you have one Save and exit the configuration file.
Now, Change to Apache configs directory:
cd /etc/apache2/sites-available/
Enable the opencart virtual host:
sudo a2ensite opencart.conf
Now rewrite the module.
a2enmod rewrite
Disable Apache default configuration file.
sudo a2dissite 000-default.conf
Enable Apache rewrite mode.
sudo a2enmod rewrite
Restart the Apache web server.
systemctl restart apache2
Access OpenCart Web Interface
Now, please launch your web browser and navigate to the Opencart web UI by entering the URL http://{your-domain} or if you don’t have domain simply using your server’s IP address. Upon doing so, you should be directed to the following page.
On the initial page, you’ll encounter the license agreement. Simply scroll down and hit Continue to proceed.
Enter the details you defined in the MariaDB database and click Continue.
In wrapping up, this article has provided a clear and concise guide on installing OpenCart on Ubuntu 22.04. By following these steps, you can swiftly set up your e-commerce platform and begin your online business journey. With OpenCart’s user-friendly interface and Ubuntu’s reliability, you’re well-equipped to create and manage your online store efficiently. So, roll up your sleeves and get ready to unleash your products to the digital market. Happy selling!