WooCommerce (AlmaLinux 8)

WooCommerce (AlmaLinux 8)

  • OS: almalinux 8

Description

WooCommerce is a free e-commerce plugin used as an extension for WordPress. It provides powerful tools for creating online stores, including product management, order processing, payment and shipping management, and more. WooCommerce is one of the most widely used e-commerce solutions in the world, known for its flexibility and easy integration with various platforms and payment gateways.

In this image, WordPress is installed together with WooCommerce to reduce deployment time.

Software included

Package Version
Wordpress + Woocommerce 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 faster startup of the accompanying software (WordPress + Woocommerce) 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 WooCommerce installation.

Note: By default, Wordpress + Woocommerce can be accessed directly by IP address. To start using Wordpress + Woocommerce with your real domain, you must first point the domain in question to your IP address and change the settings for where Wordpress + Woocommerce opens from 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 and docker 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 Wordpress + Woocommerce is started.
  • WordPress + Woocommerce data is set to be persistent and is located in /opt/wordpress/data/. MariaDB is also persistent and stores its databases in /opt/mariadb/data/.
  • The user to access the Wordpress + Woocommerce admin panel is admin and the password is P@ssw0rd!.

Frequently asked questions, specific to Wordpress and WooCommerce

  • By default, the fields WordPress Address (URL) and Site Address (URL) in the Wordpress administrative panel are grayed out and are inactive. These options are set in the wp-config.php file and are overriding the settings in in web panel. If you want to edit the settings directly via the web panel, then you will need to open your wp-config.php file and remove or comment out the rows 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/' ); and define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/' );.
  • By default, each WooCommerce installaction comes with the following pre-installed plugins, which are inactive. You can activate them at your leisure at any time. The plugins are: "Akismet Anti-Spam", "All in One SEO", "All-in-One WP Migration", "AMP", "Google Analytics for WordPress by MonsterInsights", "Hello Dolly", "Jetpack", "TaxoPress", "W3 Total Cache" and "WP Mail SMTP"..
  • Wordpress XML-RPC pingback function is disabled via a filter by default. XML-RPC is used by third-party apps to connect to your Wordpress website. In rare occasions, this function is needed. The problem with XML-RPC is that it makes your Wordpress website vulnerable to Brute Force and Dos attacks, thus it is disabled. If you wish to enable XML-RCP for any reason, the you will need to edit your wp-config.php file, find the following rows and remove or comment them out:
if ( !defined( 'WP_CLI' ) ) {
        // remove x-pingback HTTP header
        add_filter("wp_headers", function($headers) {
                unset($headers["X-Pingback"]);
                return $headers;
        });
        // disable pingbacks
        add_filter( "xmlrpc_methods", function( $methods ) {
                unset( $methods["pingback.ping"] );
                return $methods;
        });
}

Additional Docker settings

Additional settings for Wordpress + Woocommerce that you can change and that are controlled directly by Docker are set as variables in the configuration file /opt/docker-wordpress/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.

Wordpress + Woocommerce configuration options

General options

  • APACHE_HTTP_PORT_NUMBER: Port used by Apache for HTTP. Default: 8080
  • APACHE_HTTPS_PORT_NUMBER: Port used by Apache for HTTPS. Default: 8443
  • WORDPRESS_USERNAME: WordPress application username. Default: admin
  • WORDPRESS_PASSWORD: WordPress application password. Default: P@ssw0rd!
  • WORDPRESS_EMAIL: WordPress email. Default: user@example.com
  • WORDPRESS_FIRST_NAME: WordPress user first name. Default: FirstName
  • WORDPRESS_LAST_NAME: WordPress user last name. Default: LastName
  • WORDPRESS_BLOG_NAME: WordPress blog name. Default: User's blog
  • WORDPRESS_HTACCESS_OVERRIDE_NONE: Set the Apache AllowOverride variable to None. All the default directives will be loaded from /opt/bitnami/wordpress/wordpress-htaccess.conf. Default: yes
  • WORDPRESS_ENABLE_HTACCESS_PERSISTENCE: Persist the custom changes of the htaccess. It depends on the value of WORDPRESS_HTACCESS_OVERRIDE_NONE, when yes it will persist /opt/bitnami/wordpress/wordpress-htaccess.conf if no it will persist /opt/bitnami/wordpress/.htaccess. Default: no
  • WORDPRESS_DATA_TO_PERSIST: Space separated list of files and directories to persist. Use a space to persist no data: " ". Default: "wp-config.php wp-content"
  • WORDPRESS_RESET_DATA_PERMISSIONS: Force resetting ownership/permissions on persisted data when restarting WordPress, otherwise it assumes the ownership/permissions are correct. Ignored when running as non-root. Default: no
  • WORDPRESS_TABLE_PREFIX: Table prefix to use in WordPress. Default: wp_
  • WORDPRESS_PLUGINS: List of WordPress plugins to install and activate, separated via commas. Can also be set to all to activate all currently installed plugins, or none to skip. Default: none
  • WORDPRESS_EXTRA_INSTALL_ARGS: Extra flags to append to the WordPress 'wp core install' command call. No defaults.
  • WORDPRESS_EXTRA_CLI_ARGS: Extra flags to append to all WP-CLI command calls. No defaults.
  • WORDPRESS_EXTRA_WP_CONFIG_CONTENT: Extra configuration to append to wp-config.php during install. No defaults.
  • WORDPRESS_ENABLE_HTTPS: Whether to use HTTPS by default. Default: no
  • WORDPRESS_SKIP_BOOTSTRAP: Skip the WordPress installation wizard. This is necessary when providing a database with existing WordPress data. Default: no
  • WORDPRESS_AUTO_UPDATE_LEVEL: Level of auto-updates to allow for the WordPress core installation. Valid values: major, minor, none. Default: none
  • WORDPRESS_ENABLE_REVERSE_PROXY: Enable WordPress support for reverse proxy headers. Default: no

Salt and keys configuration

  • WORDPRESS_AUTH_KEY: Set the value of the AUTH_KEY constant in wp-config.php
  • WORDPRESS_SECURE_AUTH_KEY: Set the value of the SECURE_AUTH_KEY constant in wp-config.php
  • WORDPRESS_LOGGED_IN_KEY: Set the value of the LOGGED_IN_KEY constant in wp-config.php
  • WORDPRESS_NONCE_KEY: Set the value of the NONCE_KEY constant in wp-config.php
  • WORDPRESS_AUTH_SALT: Set the value of the AUTH_SALT constant in wp-config.php
  • WORDPRESS_SECURE_AUTH_SALT: Set the value of the SECURE_AUTH_SALT constant in wp-config.php
  • WORDPRESS_LOGGED_IN_SALT: Set the value of the LOGGED_IN_SALT constant in wp-config.php
  • WORDPRESS_NONCE_SALT: Set the value of the NONCE_SALT constant in wp-config.php

Multisite configuration

  • WORDPRESS_ENABLE_MULTISITE: Enable WordPress Multisite configuration. Default: no
  • WORDPRESS_MULTISITE_HOST: WordPress hostname/address. Only used for Multisite installations. No defaults.
  • WORDPRESS_MULTISITE_EXTERNAL_HTTP_PORT_NUMBER: Port to used by WordPress to generate URLs and links when accessing using HTTP. Will be ignored if multisite mode is not enabled. Default 80
  • WORDPRESS_MULTISITE_EXTERNAL_HTTPS_PORT_NUMBER: Port to used by WordPress to generate URLs and links when accessing using HTTPS. Will be ignored if multisite mode is not enabled. Default 443
  • WORDPRESS_MULTISITE_NETWORK_TYPE: WordPress Multisite network type to enable. Valid values: subfolder, subdirectory, subdomain. Default: subdomain
  • WORDPRESS_MULTISITE_ENABLE_NIP_IO_REDIRECTION: Whether to enable IP address redirection to nip.io wildcard DNS when enabling WordPress Multisite. This is useful when running on an IP address with subdomain network type. Default: no
  • WORDPRESS_MULTISITE_FILEUPLOAD_MAXK: Maximum upload file size allowed for WordPress Multisite uploads, in kilobytes. Default: 81920

Database connection configuration

  • WORDPRESS_DATABASE_HOST: Hostname for the MariaDB or MySQL server. Default: mariadb
  • WORDPRESS_DATABASE_PORT_NUMBER: Port used by the MariaDB or MySQL server. Default: 3306
  • WORDPRESS_DATABASE_NAME: Database name that WordPress will use to connect with the database. Default: wordpress
  • WORDPRESS_DATABASE_USER: Database user that WordPress will use to connect with the database. Default: wordpress
  • WORDPRESS_DATABASE_PASSWORD: Database password that WordPress will use to connect with the database. No defaults.
  • WORDPRESS_ENABLE_DATABASE_SSL: Whether to enable SSL for database connections. Default: no
  • WORDPRESS_VERIFY_DATABASE_SSL: Whether to verify the database SSL certificate when SSL is enabled for database connections. Default: yes
  • WORDPRESS_DATABASE_SSL_CERT_FILE: Path to the database client certificate file. No default
  • WORDPRESS_DATABASE_SSL_KEY_FILE: Path to the database client certificate key file. No default
  • WORDPRESS_DATABASE_SSL_CA_FILE: Path to the database server CA bundle file. No default
  • ALLOW_EMPTY_PASSWORD: It can be used to allow blank passwords. Default: no

SMTP Configuration

  • WORDPRESS_SMTP_HOST: SMTP host.
  • WORDPRESS_SMTP_PORT: SMTP port.
  • WORDPRESS_SMTP_USER: SMTP account user.
  • WORDPRESS_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-wordpress/docker-compose.yml with a text editor and find the following snippet:

  wordpress:
    image: docker.io/bitnami/wordpress:6
    ports:
      - '80:8080'
      - '443:8443'
    volumes:
      - '/opt/wordpress/data:/bitnami/wordpress'

Edit it so it looks like this:

  wordpress:
    image: docker.io/bitnami/wordpress:6
    ports:
      - '80:8080'
      - '443:8443'
    volumes:
      - '/opt/wordpress/data:/bitnami/wordpress'
      - '/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-wordpress/
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-wordpress-wordpress-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-wordpress/docker-compose.yml with a text editor and find the following snippet:

  wordpress:
    image: docker.io/bitnami/wordpress:6
    ports:
      - '80:8080'
      - '443:8443'
    volumes:
      - '/opt/wordpress/data/:/bitnami/wordpress'

Edit it so it looks like this:

  wordpress:
    image: docker.io/bitnami/wordpress:6
    ports:
      - '80:8080'
      - '443:8443'
    volumes:
      - '/opt/wordpress/data/:/bitnami/wordpress'
      - '/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-wordpress/
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-wordpress-wordpress-1' --post-hook 'chown 1001:1001 /etc/letsencrypt/archive/example.com/ -R; docker start docker-wordpress-wordpress-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 Wordpress itself, along with the rest of the software, can be done in two ways:

  1. By restarting the entire virtual machine
  2. 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-wordpress/
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-wordpress/
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:

  1. Get the application name that you can see in the NAMES column from the output of the docker ps -a command. View the logs with the docker logs <NAME> command, where is the name of the container.

Changing settings

The settings in 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 wordpress. Each configuration option must be described on a new line with a dash in front, as in the following example:

    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - WORDPRESS_DATABASE_HOST=mariadb
      - WORDPRESS_DATABASE_PORT_NUMBER=3306
      - WORDPRESS_DATABASE_USER=wordpress
      - WORDPRESS_DATABASE_NAME=wordpress
      - WORDPRESS_USERNAME=admin
      - WORDPRESS_PASSWORD=P@ssw0rd!
      - WORDPRESS_EMAIL=admin@example.com
      - WORDPRESS_PLUGINS=woocommerce

Please note that the correct indentation (number of spaces) must also be observed, as this is important for yaml configuration files.