VK Cloud logo
Updated at April 15, 2024   08:50 AM

Installing OpenCart on Linux

OpenCart is a platform for creating an online store. OpenCart is built on the MVC principle and can be installed on any web server with PHP and MySQL support.

This instruction will help you deploy OpenCart version 4.0.2.3 in the Ubuntu 22.04 operating system in VK Cloud, as well as configure a DNS record for domain name access. MySQL 8.0 Single configuration is used as a DBMS.

Preparatory steps

  1. Register at VK Cloud.

  2. Create network1 network with internet access and a subnet with the address 10.0.0.0/24.

  3. Create VM:

    • name: Ubuntu_22_04_OpenCart;
    • operating system: Ubuntu 22.04;
    • network: network1 with subnet 10.0.0.0/24;
    • assign a public IP address. The example will use 87.239.106.48;
    • security groups (firewall settings): default, ssh+www.
  4. Create DB instance:

    • name: MySQL-7313;
    • DBMS: MySQL 8.0;
    • configuration type: Single;
    • network: network1;
    • DB name: MySQL-9341;
    • DB username: user;
    • DB password: AN0r25e0ae4d626p;

    In the example, the internal IP of the created instance: 10.0.0.7.

  5. Create DNS zone.

  6. Create an record in the selected zone:

    • record type: A;
    • name: for example, site-opencart.example.vk.cloud;
    • IP address: external VM address 87.239.106.48.
  7. (Optional) Check the name resolution to the IP address using the command nslookup site-opencart.example.vk.cloud. Output upon successful operation:

    Non-authoritative answer:Name:   site-opencart.example.vk.cloudAddress: 87.239.106.48

Install OpenCart on VM

  1. Connect to the Ubuntu_22_04_OpenCart VM.

  2. Update the packages to the current version and reboot the VM using the commands:

    sudo dnf update -ysudo systemctl reboot
  3. Download the necessary repositories and start the web server:

    sudo apt install apache2 apache2-utils libapache2-mod-php php8.1 php8.1-cli php8.1-curl php8.1-fpm php8.1-gd php8.1-intl php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-readline php8.1-soap php8.1-xml php8.1-xmlrpc php8.1-zip php-gd -ysudo systemctl enable apache2 --now
  4. Download the OpenCart repository and deploy it in the opencart subdirectory on the running web server:

    cd ~wget https://github.com/opencart/opencart/archive/refs/tags/4.0.2.3.tar.gztar xzf 4.0.2.3.tar.gzsudo cp -r opencart-4.0.2.3/upload /var/www/html/opencartsudo chown -R www-data:www-data /var/www/html/opencartsudo mv /var/www/html/opencart/config-dist.php /var/www/html/opencart/config.phpsudo mv /var/www/html/opencart/admin/config-dist.php /var/www/html/opencart/admin/config.php
  5. In the browser, enter the VM's public IP address with /opencart. In the current instruction it is site-opencart.example.vk.cloud/opencart.

  6. In the installation wizard, read and accept the terms of the OpenCart license agreement.

  7. At the “Pre-Installation” step, check that the VM is ready to install OpenCart — all checks must be completed successfully.

  8. At the “Configuration” step, specify the parameters MySQL-9341:

    • DB Driver: MySQLi.
    • Hostname: 10.0.0.7.
    • Username: user.
    • Password: AN0r25e0ae4d626p.
    • Database: MySQL-9341.
    • Port: 3306.

    At the same step, specify the administrator credentials.

  9. Wait for the installation to complete: the page Installation complete will appear.

  10. (Optional) Customize OpenCart according to the recommendations of the software developer:

    1. Delete the install directory from the web server:

      sudo rm -rf /var/www/html/opencart/install
    2. Move the storage directory to /var/www:

      sudo mv /var/www/html/opencart/system/storage/ /var/www
    3. At configuration files /var/www/html/opencart/config.php and /var/www/html/opencart/admin/config.php replace:

      // source stringdefine('DIR_STORAGE', DIR_SYSTEM . 'storage/');// replaced stringdefine('DIR_STORAGE', '/var/www/storage/');

3. Check the functionality of OpenCart

In the browser, go to http://site-opencart.example.vk.cloud/opencart/. Upon successful installation, a page with a demo store will open.

Delete unused resources

Deployed virtual resources are charged. If you don't need them anymore:

  • Delete Ubuntu_22_04_OpenCart VM.
  • Delete MySQL-9341 instance.
  • If necessary, delete 87.239.106.48 floating IP address.
  • Delete site-opencart.example.vk.cloud DNS record.