Skip to content

Deployment Overview of OpenCart on Server

Prerequisites and Basic Requirements

The deployment of OpenCart requires a Linux server running either a Debian-based distribution (such as Ubuntu) or a Red Hat-based distribution (such as CentOS or RHEL). The installation process assumes the following system requirements and privileges:

  • Operating System: Debian, Ubuntu, Red Hat, or CentOS.
  • Privileges: Root access or sudo privileges are required to install packages, configure the web server, and manage the database.
  • Web Server: Apache (apache2 on Debian/Ubuntu, httpd on Red Hat/CentOS).
  • Database Server: MySQL (mysql-server).
  • PHP Version: PHP 8.0 with specific extensions.
  • Ports:
  • Port 80/tcp for HTTP traffic.
  • Port 443/tcp for HTTPS traffic (firewall rules are configured for Red Hat systems).

File and Directory Structure

The application files are deployed to the standard web root directory. The configuration and data files are organized as follows:

  • Application Source: The OpenCart source code is cloned from the 3.0.x.x branch of the official GitHub repository into /root/opencart/.
  • Web Root: The application files are copied to /var/www/html/opencart/.
  • Configuration Files:
  • Main configuration: /var/www/html/opencart/config.php (renamed from config-dist.php).
  • Admin configuration: /var/www/html/opencart/admin/config.php (renamed from admin/config-dist.php).
  • Database Socket Locations:
  • Debian/Ubuntu: /run/mysqld/mysqld.sock.
  • Red Hat/CentOS: /var/lib/mysql/mysql.sock.

Application Installation Process

The installation process involves cloning the source code, setting up the directory structure, and configuring the necessary PHP and database components.

  1. Clone Source Code: The OpenCart repository is cloned to the root directory using the following command:

    git clone -b 3.0.x.x https://github.com/opencart/opencart.git /root/opencart/
    

  2. Prepare Web Directory: A directory is created at /var/www/html/opencart to host the application.

  3. Copy Files: The contents of the upload folder from the cloned repository are copied to the web root:

    cp -r /root/opencart/upload/* /var/www/html/opencart/
    

  4. Configure PHP Environment:

  5. Debian/Ubuntu: The ondrej/php PPA is added to install PHP 8. Required extensions include php-mysql, php-gd, php-curl, php-zip, and php-xml.
  6. Red Hat/CentOS: The EPEL and Remi repositories are configured to enable the php:remi-8.0 module. The same PHP extensions are installed via dnf.

  7. Initialize Configuration Files: The default configuration files are renamed to active configuration files:

    mv config-dist.php config.php
    mv admin/config-dist.php admin/config.php
    

Access Rights and Security

Security configurations vary slightly between distributions but focus on firewall rules and user permissions.

  • Firewall Configuration (Red Hat/CentOS): The firewalld service is configured to allow traffic on ports 80 and 443:
    firewall-cmd --permanent --add-port=80/tcp
    firewall-cmd --permanent --add-port=443/tcp
    firewall-cmd --reload
    
  • IPv6 Configuration (Debian/Ubuntu): IPv6 is disabled at the system level by modifying /etc/sysctl.conf with the following settings:
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    net.ipv6.conf.lo.disable_ipv6 = 1
    
    The changes are applied using sysctl -p.

Databases

The MySQL database is installed and configured to host the OpenCart data.

  • Database Name: opencart.
  • Database User: opencart.
  • User Privileges: The user is granted ALL privileges on the opencart.* database.
  • Password: The database user password is set to match the SSH password used during the deployment process.
  • Connection Method: The application connects to MySQL via the local Unix socket.
  • Debian/Ubuntu socket: /run/mysqld/mysqld.sock.
  • Red Hat/CentOS socket: /var/lib/mysql/mysql.sock.

Permission Settings

File and directory permissions are set to ensure the web server can read and write necessary files while maintaining security.

  • Directory Ownership:
  • Debian/Ubuntu: The /var/www directory and its contents are owned by the www-data user and group.
  • Red Hat/CentOS: The /var/www directory and its contents are owned by the apache user and group.
  • Directory Mode: The /var/www/html/opencart directory is set to 0755.
  • Recursive Ownership: Ownership changes are applied recursively to the entire /var/www directory.

Starting, Stopping, and Updating

The web server and database services are managed using systemd.

  • Apache (Debian/Ubuntu):
  • Service Name: apache2.
  • Command to enable and restart:

    systemctl enable apache2
    systemctl restart apache2
    

  • HTTPD (Red Hat/CentOS):

  • Service Name: httpd.
  • Command to enable and restart:

    systemctl enable httpd
    systemctl restart httpd
    

  • MySQL (Debian/Ubuntu):

  • Service Name: mysql (managed via socket, service status depends on distribution defaults).
  • Command to enable and start:

    systemctl enable mysql
    systemctl start mysql
    

  • MySQL (Red Hat/CentOS):

  • Service Name: mysqld.
  • Command to enable and start:
    systemctl enable mysqld
    systemctl start mysqld
    
question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×