Introduction
OpenCart is a free and open-source online store management software based on PHP that manages multiple online stores from a single administrative dashboard with a modern, responsive interface. It has modules to manage inventory, orders, sales reports, discounts, payments, customers, marketing tools, and its functionality is extensible with professionally-written extensions and plugins. This article describes how to install OpenCart on Ubuntu 20.04 server.
Prerequisites
- Deploy a fully updated Rcs Ubuntu 20.04 Server.
- Create a non-root user with sudo access.
- PHP version 5.4 and above.
- Web Server (Apache suggested).
1. Install Required Packages
SSH to your server as a non-root user with sudo access.
Update system package list to update all packages to the latest available versions.
$ sudo apt update
The latest versions of OpenCart only support PHP version 8.0. Ubuntu 20.04 does not contain PHP 8.0 in its default repository list. To install it, add the PHP repository to the APT.
Add
ppa:ondrej/php
repository.$ sudo apt -y install software-properties-common $ sudo add-apt-repository ppa:ondrej/php
Update system package manager.
$ sudo apt update
Install PHP 8.0 and more modules.
$ sudo apt install apache2 mysql-server php8.0 libapache2-mod-php8.0 php8.0-mysql php8.0-curl php8.0-xml php8.0-zip php8.0-gd php8.0-cli php8.0-fpm libapache2-mod-fcgid wget unzip -y
Enable Apache2 with PHP-FPM.
$ sudo a2enmod proxy_fcgi setenvif $ sudo a2enconf php8.0-fpm
Restart Apache service.
$ sudo systemctl restart apache2
2. Create OpenCart Database
Log in to MySQL shell. On password prompt, just press Enter to continue.
$ sudo mysql -u root -p
Crate a database called
opencart
.CREATE DATABASE opencart;
Crate a user called
opencart
with a passwordStrongPassword
.CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'StrongPassword';
Grant all database privileges to the user.
GRANT ALL PRIVILEGES ON opencart . * TO 'opencart'@'localhost';
Save the changes.
FLUSH PRIVILEGES;
Exit the shell.
exit;
3. Install OpenCart
Download the latest OpenCart version.
$ wget https://github.com/opencart/opencart/archive/refs/heads/master.zip
Unzip the downloaded file.
$ sudo unzip master.zip
Create the installation directory
/var/www/html/opencart
.$ sudo mkdir /var/www/html/opencart
Move the unzipped files to the installation directory.
$ sudo mv opencart-master/* /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}
Change ownership of the installation directory.
$ sudo chown -R www-data:www-data /var/www/html/opencart
Change access permissions for the installation directory.
$ sudo chmod -R 755 /var/www/html/opencart
4. Configure Apache2
Create a new Apache virtual host file named
opencart.conf
.$ sudo nano /etc/apache2/sites-available/opencart.conf
Add the following code to the file. Save and close the file.
<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/opencart/upload/ ServerName example.com ServerAlias www.example.com <Directory /var/www/html/opencart/upload/> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/example.com-error_log CustomLog /var/log/apache2/example.com-access_log common </VirtualHost>
Disable Apache default configuration file.
$ sudo a2dissite 000-default.conf
Enable OpenCart Apache configuration file.
$ sudo a2ensite opencart.conf
Enable Apache rewrite mode.
$ sudo a2enmod rewrite
Restart Apache service.
$ sudo systemctl restart apache2
5. Access OpenCart Web Interface
To access the OpenCart Web Interface, go to your browser and visit http://Server_IP/
. For example:
http://192.0.2.10/
Conclusion
You have installed OpenCart on your server. Access the Installation Wizard screen to complete installation by connecting to the database you created, creating an administrator account and other settings. You can now access the Dashboard and configure it to begin managing your business.
More Information
To learn more about using OpenCart, go to the official documentation page.