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
sudoprivileges are required to install packages, configure the web server, and manage the database. - Web Server: Apache (
apache2on Debian/Ubuntu,httpdon Red Hat/CentOS). - Database Server: MySQL (
mysql-server). - PHP Version: PHP 8.0 with specific extensions.
- Ports:
- Port
80/tcpfor HTTP traffic. - Port
443/tcpfor 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.xbranch 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 fromconfig-dist.php). - Admin configuration:
/var/www/html/opencart/admin/config.php(renamed fromadmin/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.
-
Clone Source Code: The OpenCart repository is cloned to the root directory using the following command:
-
Prepare Web Directory: A directory is created at
/var/www/html/opencartto host the application. -
Copy Files: The contents of the
uploadfolder from the cloned repository are copied to the web root: -
Configure PHP Environment:
- Debian/Ubuntu: The
ondrej/phpPPA is added to install PHP 8. Required extensions includephp-mysql,php-gd,php-curl,php-zip, andphp-xml. -
Red Hat/CentOS: The EPEL and Remi repositories are configured to enable the
php:remi-8.0module. The same PHP extensions are installed viadnf. -
Initialize Configuration Files: The default configuration files are renamed to active configuration files:
Access Rights and Security¶
Security configurations vary slightly between distributions but focus on firewall rules and user permissions.
- Firewall Configuration (Red Hat/CentOS): The
firewalldservice is configured to allow traffic on ports 80 and 443: - IPv6 Configuration (Debian/Ubuntu): IPv6 is disabled at the system level by modifying
/etc/sysctl.confwith the following settings:The changes are applied usingnet.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1sysctl -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
ALLprivileges on theopencart.*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/wwwdirectory and its contents are owned by thewww-datauser and group. - Red Hat/CentOS: The
/var/wwwdirectory and its contents are owned by theapacheuser and group. - Directory Mode: The
/var/www/html/opencartdirectory is set to0755. - Recursive Ownership: Ownership changes are applied recursively to the entire
/var/wwwdirectory.
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:
-
HTTPD (Red Hat/CentOS):
- Service Name:
httpd. -
Command to enable and restart:
-
MySQL (Debian/Ubuntu):
- Service Name:
mysql(managed via socket, service status depends on distribution defaults). -
Command to enable and start:
-
MySQL (Red Hat/CentOS):
- Service Name:
mysqld. - Command to enable and start: