Introduction
OpenCart is an open-source e-commerce shopping platform that allows to create online stores. It was first released in 2009 and has since become a popular choice for small to medium-sized businesses who want to create an online presence.
Prerequisites
You must following things to complete this tutorial.
- Ubuntu 22.04 LTS up and running.
- Root permission.
- Basic knowledge of linux commands.
- Internet connectivity.
In this post, We will show you how to install OpenCart on ubuntu 22.04 LTS along with LAMP Stack.
Step 1: Updating Ubuntu Repository
Update your Ubuntu system by running the following command:
sudo apt-get update
sudo apt-get upgrade
Step 2: Installing Dependencies
Install the required dependencies for OpenCart:
sudo apt-get install apache2 mariadb-server php libapache2-mod-php php-mysql php-curl php-gd php-zip php-xml php-mbstring unzip -y
Step 3: Downloading OpenCart
Download the latest version of OpenCart from the official website :
wget https://github.com/opencart/opencart/releases/download/3.0.3.7/opencart-3.0.3.7.zip
Step 4: Extracting OpenCart’s Zip
Extract the downloaded file and move it to the web directory:
sudo unzip opencart-3.0.3.7.zip
sudo mv upload /var/www/html/opencart
Step 5: Creating OpenCart’s Database & User
Create a new database and user for OpenCart:
sudo mysql -u root -p
CREATE DATABASE opencart;
GRANT ALL PRIVILEGES ON opencart.* TO 'opencartuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;
Note: Replace ‘opencartuser’ and ‘password’ with your desired values.
Step 6: Updating Permission
Set the correct permissions for the OpenCart directory:
sudo chown -R www-data:www-data /var/www/html/opencart/
sudo chmod -R 755 /var/www/html/opencart/
Step 7: Creating OpenCart Virtualhost
Configure Apache to serve OpenCart:
sudo nano /etc/apache2/sites-available/opencart.conf
Add the following content to the file:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/opencart/
ServerName example.com
ServerAlias www.example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Note: Replace ‘example.com’ with your domain name or IP address.
Step 8: Enabling OpenCart Site
Enable the OpenCart site and restart Apache:
sudo a2ensite opencart.conf
sudo systemctl restart apache2
Step 9: Access OpenCart
Access OpenCart in your web browser by visiting your server’s domain name or IP address. Follow the installation wizard to complete the setup.
Conclusion
We have successfully installed and setup the OpenCart service using the LAMP stack on Ubuntu. If you have any questions or issues, please leave a comment below.