Before starting the installation process, make sure your domain’s nameservers and DNS settings are correctly configured. Otherwise, you will not be able to access the website.

Learn how to configure your domain nameservers/DNS here.

Prerequisites

Before proceeding with the installation, ensure you have the following:

  • A server with Docker and Docker Compose installed.
  • A valid domain name with properly configured DNS settings.
  • Basic knowledge of Linux and command-line usage.
  • An active LeaderOS license.

Step 1: Download the LeaderOS Docker Files

Clone the LeaderOS Docker repository from GitHub:

git clone https://github.com/leaderos-net/docker.git leaderos-docker
cd leaderos-docker

About the LeaderOS Docker repository structure:

  • .env: The environment file for configuring the LeaderOS setup.
  • nginx: Contains the Nginx configuration files.
  • leaderos: Contains the LeaderOS software files.
  • certbot: Contains the Certbot configuration files for SSL certificates.
  • docker-compose.yml: The main Docker Compose file for setting up the LeaderOS environment.

Step 2: Download LeaderOS Software

  1. Log in to the LeaderOS website.
  2. Navigate to My Account > Licenses.
  3. Click the Download button to obtain the .zip file.

Step 3: Upload LeaderOS Software to Your Server

  1. Upload the downloaded .zip file to your server.
  2. Extract the contents into the /leaderos directory:

Step 4: Configure the .env File

Before building the Docker environment, configure the .env file according to your setup.

DOMAIN=yourdomain.com
SQL_USER=leaderos_user
SQL_PASSWORD=change_this_password
SQL_DATABASE=leaderos_database

Step 5: Build and Start Docker Containers

Run the following command to build and start the required containers:

docker compose --env-file .env up -d --build

This process will set up the LeaderOS environment using the configurations from the .env file.

Step 6: Obtain an SSL Certificate with Certbot

To secure your website with SSL, run the following command (replace YOUR_DOMAIN.com with your actual domain name):

docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d YOUR_DOMAIN.com

This command will generate an SSL certificate for your domain using Let’s Encrypt.

Step 7: Configure Nginx for SSL

Modify the Nginx configuration file to enable SSL. Edit nginx/templates/default.conf.template and add the following lines:

server {
    listen 443 ssl;

    ssl_certificate     /etc/letsencrypt/live/${SERVER_NAME}/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/${SERVER_NAME}/privkey.pem;

    server_name ${SERVER_NAME};

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_pass http://localhost:80;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_pass_header Server;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
    }
}

Step 8: Restart Nginx

After configuring Nginx, restart the service to apply the changes:

docker restart nginx

Step 9: Set Up Automatic SSL Certificate Renewal

To ensure your SSL certificate is automatically renewed, add a cron job by running:

crontab -e

Then, add the following line to the crontab file:

0 2 * * * docker compose run --rm certbot renew --webroot --webroot-path /var/www/certbot/

This schedules Certbot to renew your SSL certificate every day at 2 AM.

Step 10: Visit Your Website and Complete the Setup

Once you have completed the above steps, visit your domain in a web browser to access the LeaderOS setup wizard. Follow the on-screen instructions to complete the installation.

Your database host should be set to mariadb in the Database Settings step, which is the name of the MySQL container in the Docker environment.

Troubleshooting

If you encounter issues during installation or operation, consider the following solutions:

Permission issues when using docker commands

If you receive a permission error when running docker commands, add your user to the Docker group:

sudo usermod -aG docker $USER
newgrp docker

This will allow you to run Docker commands without requiring sudo.

File permissions error on the setup wizard.

File Permissions: not writable:

If you encounter this error during the LeaderOS setup wizard, you need to adjust the permissions of the leaderos directory:

sudo chown -R www-data:www-data ENTER_YOUR_LEADEROS_DIRECTORY

Example: chown -R www-data:www-data /home/myuser/leaderos-docker/leaderos

Database connection issues

SQLSTATE[HY000] [2002] No such file or directory:

If LeaderOS fails to connect to the database, you need to set the database host to mariadb in the Database Settings step. Docker uses internal networking, so referring to the database service by its container name (mariadb) is required.

Conclusion

Your LeaderOS installation on Docker is now complete! Your server should be running with a secure, properly configured environment. If you encounter any issues, refer to the official LeaderOS Documentation or contact the LeaderOS support team for assistance.