Deployment Overview of Joomla on Server¶
Prerequisites and Basic Requirements¶
The deployment requires a Linux-based operating system with Docker installed and configured. The following components are necessary for the system to function:
- Root privileges or
sudoaccess to manage Docker containers and system directories. - A valid domain name configured to point to the server's IP address.
- Port
80and443must be open for web traffic and SSL certificate management. - Port
3306is exposed for the MySQL database service. - Port
8080is used internally for the proxy pass configuration.
File and Directory Structure¶
The application and its supporting services utilize specific directories for configuration, data storage, and certificates:
/root/nginx: Contains the Docker Compose configuration file for the proxy server./root/nginx/compose.yml: The main orchestration file for the Nginx and Certbot services./data/nginx/user_conf.d: Stores custom Nginx configuration files, including host-specific settings./data/nginx/nginx-certbot.env: Environment file containing configuration variables for the Nginx-Certbot service./etc/letsencrypt: Mount point for SSL certificates managed by Certbot./var/www/html: The internal volume mount point for Joomla application files within the container./var/lib/mysql: The internal volume mount point for MySQL database files within the container.
Application Installation Process¶
The Joomla application and its dependencies are deployed using Docker containers. The installation involves pulling specific images and starting containers with defined environment variables and volume mappings.
- MySQL Container:
- Image:
mysql(version defined by themysql_imagevariable). - Container Name: Defined by the
mysql_container_namevariable. - Configuration:
- Root password set via
MYSQL_ROOT_PASSWORD. - Database name set via
MYSQL_DATABASE. - Application user set via
MYSQL_USERandMYSQL_PASSWORD.
- Root password set via
- Data Persistence: Uses a named volume
mysql_datamounted to/var/lib/mysql. -
Restart Policy: Set to
always. -
Joomla Container:
- Image:
joomla(version defined by thejoomla_imagevariable). - Container Name: Defined by the
joomla_container_namevariable. - Configuration:
- Database Host: Linked to the MySQL container name.
- Database Name: Matches the
MYSQL_DATABASEvariable. - Database User: Matches the
MYSQL_USERvariable. - Database Password: Matches the
MYSQL_PASSWORDvariable.
- Data Persistence: Uses a named volume
joomla_datamounted to/var/www/html. - Port Mapping: Host port
{{ joomla_port }}maps to container port80. - Restart Policy: Set to
always.
Docker Containers and Their Deployment¶
The system utilizes Docker to run the application stack. The deployment process involves starting the MySQL and Joomla containers with specific environment variables and volume mounts.
- MySQL Deployment:
- The container is started with the
mysqlimage. - Environment variables are passed to configure the database root password, database name, and user credentials.
- The container exposes port
3306on the host. -
A named volume
mysql_dataensures database persistence. -
Joomla Deployment:
- The container is started with the
joomlaimage. - Environment variables
JOOMLA_DB_HOST,JOOMLA_DB_NAME,JOOMLA_DB_USER, andJOOMLA_DB_PASSWORDare configured to connect to the MySQL container. - The container is linked to the MySQL container using the alias
mysql. - A named volume
joomla_dataensures application file persistence. - The container maps the host port
{{ joomla_port }}to the internal port80.
Proxy Servers¶
A reverse proxy is deployed using Nginx and Certbot to handle incoming web traffic and manage SSL certificates.
- Service Image:
jonasal/nginx-certbot:latest. - Restart Policy:
unless-stopped. - Network Mode:
host. - Configuration:
- The service uses an environment file located at
/data/nginx/nginx-certbot.env. - The
CERTBOT_EMAILis set to[email protected]for certificate notifications. - The
nginx_secretsvolume is mounted to/etc/letsencryptto store SSL certificates. - The directory
/data/nginx/user_conf.dis mounted to/etc/nginx/user_conf.dfor custom configurations. - Proxy Configuration:
- A custom configuration file is generated at
/data/nginx/user_conf.d/{{ prefix }}{{ server_id }}.hostkey.in.conf. - The
proxy_passdirective is configured to forward requests tohttp://127.0.0.1:8080.
Starting, Stopping, and Updating¶
The proxy services are managed using Docker Compose commands executed from the /root/nginx directory.
- Starting the Proxy:
- Execute the command
docker compose up -dwithin the/root/nginxdirectory to start the Nginx and Certbot containers in detached mode. - Updating the Proxy:
- To apply changes to the configuration, update the
compose.ymlfile or the environment variables, then re-run thedocker compose up -dcommand. - Stopping the Proxy:
- Execute
docker compose downwithin the/root/nginxdirectory to stop and remove the proxy containers.
For the application containers (MySQL and Joomla), standard Docker commands are used:
- Start:
docker start <container_name> - Stop:
docker stop <container_name> - Restart:
docker restart <container_name> - Update: Pull the latest image using
docker pull <image_name>and restart the container.