OpenCart is an e-commerce management platform that provides all the necessary tools for creating and managing online stores. It is completely free, open-source, and easy to use, available in different languages. OpenCart has a large number of modules and themes that allow users to customize their stores according to their needs and preferences. OpenCart offers many features, including product, order, and customer management, integration with various payment systems and shipping providers, report generation, and much more.
OpenCart (AlmaLinux 8)
- OS: almalinux 8
Description
Software included
Package | Version |
---|---|
Opencart | latest |
Docker | 3.20.10 |
Docker compose | 2.12.2 |
containerd.io | 1.6.10 |
Initial start of the service
This application uses Docker to provide a faster launch of the companion software (OpenCart) and direct use. This eliminates the need to familiarize yourself with its specifics in terms of configuration and installation. To start working directly with the application, all you need to do is visit the IP address assigned to your virtual machine in your browser to view your new OpenCart installation.
Note: By default, OpenCart can be accessed directly by IP address. To start using OpenCart with your real domain, you first need to point the domain in question to your IP address and change the settings for where OpenCart opens from through its admin panel.
Quick settings and frequently asked questions
- Logging into the cloud service is done using an SSH key or password that you have specified.
- Docker is installed as recommended by the official docker documentation.
- The standard
docker
anddocker compose
commands are now available in this application. - When the virtual machine is first started, it takes a few minutes before a Docker container containing OpenCart is started.
- Opencart data is set to be persistent and is located in
/opt/opencart/data/
and individual static files are stored inopencart_storage_data
. MariaDB is also persistent and stores its databases in/opt/mariadb/data/
. - The user to access the Opencart admin panel is
admin
and the password isP@ssw0rd!
.
Note: By default, OPENCART_HOST is set to be the first address of the virtual machine. The goal is to have access immediately after starting the machine. To start using Opencart with your real domain, you first need to point the domain in question to your IP address and change the settings for where Opencart opens from through its admin panel.
Using your own SSL certificate
An Apache web server is also included in this application, which provides all the necessary software stack needed to run OpenCart. If you wish to use your own SSL certificate, please read how to make these settings in our documentation for Apache for AlmaLinux 8.
Additional Docker settings
Additional OpenCart settings that you can change and that are controlled directly by Docker are set as variable values in the configuration file /opt/docker-opencart/docker-compose.yml
:
Note: After changing any of the values, you must recreate the Docker container on which the application is running. For more information, please read the Recreating Docker containers section.
Opencart configuration options
General options
- APACHE_HTTP_PORT_NUMBER: Port to bind by Apache for HTTP. Default: 8080
- APACHE_HTTPS_PORT_NUMBER: Port to bind by Apache for HTTPS. Default: 8443
- OPENCART_USERNAME: OpenCart application username. Default: admin
- OPENCART_PASSWORD: OpenCart application password. Default: P@ssw0rd!
- OPENCART_EMAIL: OpenCart application email. Default: admin@example.com
- OPENCART_HOST: OpenCart server hostname/address.
- OPENCART_ENABLE_HTTPS: Whether to use HTTPS by default. Default: no.
- OPENCART_EXTERNAL_HTTP_PORT_NUMBER: Port to used by OpenCart to generate URLs and links when accessing using HTTP. Default 80.
- OPENCART_EXTERNAL_HTTPS_PORT_NUMBER: Port to used by OpenCart to generate URLs and links when accessing using HTTPS. Default 443.
- OPENCART_SKIP_BOOTSTRAP: Whether to skip performing the initial bootstrapping for the application. Default: no
Use an existing database
- OPENCART_DATABASE_HOST: Hostname for MariaDB server. Default: mariadb
- OPENCART_DATABASE_PORT_NUMBER: Port used by MariaDB server. Default: 3306
- OPENCART_DATABASE_NAME: Database name that OpenCart will use to connect with the database. Default: bitnami_opencart
- OPENCART_DATABASE_USER: Database user that OpenCart will use to connect with the database. Default: bn_opencart
- OPENCART_DATABASE_PASSWORD: Database password that OpenCart will use to connect with the database. No defaults.
- ALLOW_EMPTY_PASSWORD: It can be used to allow blank passwords. Default: no
SMTP Configuration
- OPENCART_SMTP_HOST: SMTP host.
- OPENCART_SMTP_PORT: SMTP port.
- OPENCART_SMTP_USER: SMTP account user.
- OPENCART_SMTP_PASSWORD: SMTP account password.
PHP configuration
- PHP_ENABLE_OPCACHE: Enable OPcache for PHP scripts. Default: yes
- PHP_EXPOSE_PHP: Enables HTTP header with PHP version. No default.
- PHP_MAX_EXECUTION_TIME: Maximum execution time for PHP scripts. No default.
- PHP_MAX_INPUT_TIME: Maximum input time for PHP scripts. No default.
- PHP_MAX_INPUT_VARS: Maximum amount of input variables for PHP scripts. No default.
- PHP_MEMORY_LIMIT: Memory limit for PHP scripts. Default: 512M
- PHP_POST_MAX_SIZE: Maximum size for PHP POST requests. No default.
- PHP_UPLOAD_MAX_FILESIZE: Maximum file size for PHP uploads. No default.
SSL certificates
Use of own (paid) SSL certificates
If you already have ready-made, valid certificates, you need to make a few configuration modifications before you can use them. To achieve this, please follow these steps:
Step 1 - placing the certificates
Create a directory where the certificates will be stored:
mkdir /opt/certs/
Copy the certificates into the directory you just created and modify their permissions:
chown 1001:1001 /opt/certs/ -R
Step 2 - modify the Docker configuration
Open the docker configuration file /opt/docker-opencart/docker-compose.yml
with a text editor and find the following snippet:
opencart:
image: docker.io/bitnami/opencart:4
ports:
- '80:8080'
- '443:8443'
environment:
- OPENCART_HOST=localhost
- OPENCART_DATABASE_HOST=mariadb
- OPENCART_DATABASE_PORT_NUMBER=3306
- OPENCART_DATABASE_USER=opencart
- OPENCART_DATABASE_NAME=opencart
- ALLOW_EMPTY_PASSWORD=yes
- OPENCART_USERNAME=admin
- OPENCART_PASSWORD=P@ssw0rd!
- OPENCART_EMAIL=admin@example.com
volumes:
- '/opt/opencart/opencart:/bitnami/opencart'
- '/opt/opencart/opencart_storage_data:/bitnami/opencart_storage/'
Edit it so it looks like this:
opencart:
image: docker.io/bitnami/opencart:4
ports:
- '80:8080'
- '443:8443'
environment:
- OPENCART_HOST=localhost
- OPENCART_DATABASE_HOST=mariadb
- OPENCART_DATABASE_PORT_NUMBER=3306
- OPENCART_DATABASE_USER=opencart
- OPENCART_DATABASE_NAME=opencart
- ALLOW_EMPTY_PASSWORD=yes
- OPENCART_USERNAME=admin
- OPENCART_PASSWORD=P@ssw0rd!
- OPENCART_EMAIL=admin@example.com
volumes:
- '/opt/opencart/opencart:/bitnami/opencart'
- '/opt/opencart/opencart_storage_data:/bitnami/opencart_storage/'
- '/opt/certs/cert.pem:/opt/bitnami/apache/conf/bitnami/certs/server.crt'
- '/opt/certs/privkey.pem:/opt/bitnami/apache/conf/bitnami/certs/server.key'
Note that /opt/certs/cert.pem
is the path to the certificate and /opt/certs/privkey.pem
is the path to the private key. You can name the files and directories as you wish, but they must be specified correctly in the configuration
Step 3 - restart the Docker containers
cd /opt/docker-opencart/
docker compose up -d
Issuing certificates with Letsencrypt
If you wish, you can always issue free certificates from Letsencrypt as well. To do this, please follow the steps below:
Step 1 - install the necessary packages
Login to your server as root and run the following commands:
dnf install -y epel-release
dnf install -y certbot
Step 2 - issuance of the certificate
Please note that in order for a free certificate to be issued, you must be able to verify your domain ownership in some way. Letsencrypt provides several options for verifying your domains, in this example we will use verification by running a temporary web server.
To do this, temporarily stop the container with the docker stop docker-opencart-opencart-1
command. Important: Performing this step will temporarily stop your site from working. Make sure you perform this action at a time when it will least affect your users.
Issue the certificate with the command certbot certonly --standalone --preferred-challenges http -d example.com
, replacing "example.com" with the domain you pointed to your Cloud server IP address.
Step 3 - put the new certificates in the configuration
Open the docker configuration file /opt/docker-opencart/docker-compose.yml
with a text editor and find the following snippet:
opencart:
image: docker.io/bitnami/opencart:4
ports:
- '80:8080'
- '443:8443'
environment:
- OPENCART_HOST=localhost
- OPENCART_DATABASE_HOST=mariadb
- OPENCART_DATABASE_PORT_NUMBER=3306
- OPENCART_DATABASE_USER=opencart
- OPENCART_DATABASE_NAME=opencart
- ALLOW_EMPTY_PASSWORD=yes
- OPENCART_USERNAME=admin
- OPENCART_PASSWORD=P@ssw0rd!
- OPENCART_EMAIL=admin@example.com
volumes:
- '/opt/opencart/opencart:/bitnami/opencart'
- '/opt/opencart/opencart_storage_data:/bitnami/opencart_storage/'
Edit it so it looks like this:
opencart:
image: docker.io/bitnami/opencart:4
ports:
- '80:8080'
- '443:8443'
environment:
- OPENCART_HOST=localhost
- OPENCART_DATABASE_HOST=mariadb
- OPENCART_DATABASE_PORT_NUMBER=3306
- OPENCART_DATABASE_USER=opencart
- OPENCART_DATABASE_NAME=opencart
- ALLOW_EMPTY_PASSWORD=yes
- OPENCART_USERNAME=admin
- OPENCART_PASSWORD=P@ssw0rd!
- OPENCART_EMAIL=admin@example.com
volumes:
- '/opt/opencart/opencart:/bitnami/opencart'
- '/opt/opencart/opencart_storage_data:/bitnami/opencart_storage/'
- '/etc/letsencrypt/live/example.com/cert.pem:/opt/bitnami/apache/conf/bitnami/certs/server.crt'
- '/etc/letsencrypt/live/example.com/privkey.pem:/opt/bitnami/apache/conf/bitnami/certs/server.key'
With this modification, you end up "binding" the external certificates issued by Letsencrypt to the configuration that resides inside the docker container. Replace "example.com" with your domain name. After you change the configuration, you need to fix the certificate permissions with the command chown 1001:1001 /etc/letsencrypt/archive/example.com/ -R
, again replacing "example.com" with your domain name.
Step 4 - start the services
Since the docker container is temporarily stopped, it needs to apply the new configuration and start it. Please run the following commands:
cd /opt/docker-opencart/
docker compose up -d
Step 5 (optional) - automatic certificate renewal
Automatic renewal can be arranged via cron. You can set the following cron configuration to make auto-renewal happen:
# Automated Letsencrypt renewal
0 0 * * * /usr/bin/certbot renew --pre-hook 'docker stop docker-opencart-opencart-1' --post-hook 'chown 1001:1001 /etc/letsencrypt/archive/example.com/ -R; docker start docker-opencart-opencart-1'
Of course, you can change the runtime whenever you want. In the above example, this task will run every day at 00:00.
Working with Docker
The organization of this application is entirely done using Docker. In this way, we can provide you with ready-made applications faster. In addition, their configuration is more flexible and quite controllable. To be able to control this application, however, you need to know some basic Docker functionalities and features.
Restarting all services
Restarting the database and the Docker container that contains OpenCart itself, along with the rest of the software, can be done in two ways:
- By restarting the entire virtual machine
- Restarting the Docker containers, which is the faster option. To do this, access your machine via SSH, and run the following commands:
sudo su -
cd /opt/docker-opencart/
docker compose restart
Recreating Docker containers
Recreation of a docker container may be necessary if you've changed the configuration inside the docker-compose.yml
file. If there are changes, please follow these steps:
cd /opt/docker-opencart/
docker compose stop
docker compose up -d
Checking the status of the Docker application
To check, you need to run the following commands:
sudo su -
docker ps -a
Please pay attention to the STATUS
column. It should show how long the service has been running, for example Up X minutes
. If the status is Restarting
then you need to check what is wrong with the application. In such a case, you can check by following the application logs as follows:
- Get the application name that you can see in the
NAMES
column from the output of thedocker ps -a
command. View the logs with thedocker logs <NAME>
command, whereis the name of the container.
Changing settings
The description settings in the section Additional Docker settings can be set in the docker-compose.yml file. The path to it is described again in this section. To change a setting, open the configuration file and note the environment
section under opencart
. Each configuration option must be described on a new line with a dash in front, as in the following example:
environment:
- OPENCART_USERNAME=admin
- OPENCART_PASSWORD=P@ssw0rd!
Please note that the correct indentation (number of spaces) must also be observed, as this is important for yaml configuration files.