Skip to content

How to Install DigitalCourse on an Ubuntu VPS with Nginx and MySQL

  • by

This guide explains how to deploy DigitalCourse on a fresh Ubuntu 22.04 VPS using Nginx and MySQL. It is suitable for VPS providers such as DigitalOcean, Linode, Hetzner, and similar hosting platforms.

Prerequisites

Before installing DigitalCourse, make sure you have:

  • An Ubuntu 22.04 VPS with root or sudo access
  • A domain name pointed to your server’s IP address
  • PHP 8.1 or newer
  • Nginx
  • MySQL
  • Composer
  • Git
  • SSH access

Step 1 — Install Server Dependencies

Update the Ubuntu server and install the packages required by DigitalCourse:

sudo apt update && sudo apt upgrade -y
sudo apt install -y nginx mysql-server php8.2-fpm php8.2-cli php8.2-mbstring \
  php8.2-xml php8.2-curl php8.2-zip php8.2-mysql php8.2-sqlite3 unzip curl git

Install Composer:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Verify the required software:

php -v
nginx -v
mysql --version
composer --version

Step 2 — Download DigitalCourse

Navigate to the web directory:

cd /var/www

Clone the DigitalCourse project:

sudo git clone https://github.com/youruser/digitalcourse.git

Set the correct ownership:

sudo chown -R www-data:www-data digitalcourse

Enter the DigitalCourse directory:

cd digitalcourse

Step 3 — Configure DigitalCourse

Create the environment file:

cp .env.example .env

Generate the DigitalCourse application key:

php artisan key:generate

Edit the .env file and configure your production settings:

APP_URL=https://yourdomain.com

DB_CONNECTION=mysql
DB_DATABASE=digitalcourse
DB_USERNAME=dcuser
DB_PASSWORD=strongpassword

STRIPE_KEY=pk_live_...
STRIPE_SECRET=sk_live_...

OPENAI_API_KEY=sk-...

Configure the database, mail service, payment gateways, OpenAI integration, and any other services required by your DigitalCourse installation.

Step 4 — Install DigitalCourse Dependencies and Initialize the Database

Install the production Composer dependencies:

composer install --no-dev --optimize-autoloader

Run the DigitalCourse database migrations and seed the initial data:

php artisan migrate --seed

Create the storage link:

php artisan storage:link

Cache the DigitalCourse configuration and routes:

php artisan config:cache
php artisan route:cache

Step 5 — Configure Nginx for DigitalCourse

Create the Nginx configuration for DigitalCourse:

sudo nano /etc/nginx/sites-available/digitalcourse

Add:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    root /var/www/digitalcourse/public;

    index index.php;
    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }
}

Enable the DigitalCourse site:

sudo ln -s /etc/nginx/sites-available/digitalcourse /etc/nginx/sites-enabled/

Test the configuration:

sudo nginx -t

Reload Nginx:

sudo systemctl reload nginx

Step 6 — Enable HTTPS for DigitalCourse

Install Certbot:

sudo apt install certbot python3-certbot-nginx -y

Request an SSL certificate for your DigitalCourse domain:

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Follow the prompts to complete HTTPS configuration.

Step 7 — Set DigitalCourse File Permissions

Make sure the DigitalCourse writable directories are owned by the web server:

sudo chown -R www-data:www-data storage bootstrap/cache

Set the required permissions:

sudo chmod -R 775 storage bootstrap/cache

Your DigitalCourse installation should now be available at:

https://yourdomain.com

Log in using the seeded administrator credentials provided in the DigitalCourse documentation.