Create An Internet Test Website (DigitalOcean / Ubuntu 21.04)

Tutorial

Complete Website Domain Tasks

Website Domain Tasks >

Create A Colby Website Project On The Web Server

  • workstation$ ssh <webserver>

  • webserver$ cd <colby_projects_directory>

  • webserver$ mkdir <reverse_server_specific_domain>

  • webserver$ cd <reverse_server_specific_domain>

  • webserver$ curl -s https://mattifesto.com/install/ > install.php && php install.php

Scenario 1: Create A New Website Instance Using An Existing Git Repository

  • choose option 1) create a website using an existing Git repository

Scenario 2a: Copy/Move Another Website Instance On This Web Server

  • choose option 2) create directories for a website

  • Go to the update admin page for the website you are copying and click on the "Backup Database" button. We will import this backup into the database for this site later.

  • webserver$ rm -rf document_root

  • webserver$ cp -r <source_website_project_directory>/document_root document_root

    NOTE: No ending slash on either document_root directory.

Scenario 2b: Copy/Move Another Website Instance On Another Workstation or Web Server

At the heart of this scenario we are just copying the document_root directory from one computer to another. You can accomplish this task using any method you like. This is the method that we most often use.

  • choose option 2) create directories for a website

  • Go to the update admin page for the website you are copying and click on the "Backup Database" button. We will import this backup into the database for this site later.

  • webserver$ rm -rf document_root

  • Determine the source host name or IP address.

    If you are copying from another local server you can use its hostname.

    If you are copying between two DigitalOcean droplets you will want to use the source droplet's PRIVATE IP address which is available on the DigitalOcean admin page.

  • You may need to set up SSH keys to access the previous server from the new server.

    Reference

  • webserver$ rsync -a --info=progress2 <username>@<source_hostname_or_ipaddress>:~/<document_root_path>/ document_root

    IMPORTANT: A slash is placed after the source document root path, but no slash is placed after the destination path.

Configure The Project

webserver$ php document_root/colby/bin/cbt update-configuration

Create Database On The Web Server

webserver$ php document_root/colby/bin/cbt create-database

webserver$ sudo mysql < create_database.sql

Scenario 2: Import The Database From The Copied Website Instance

This step is only necessary if you are copying/moving another website instance.

  • webserver$ cp document_root/tmp/database-backups/<most_recent_backup_file> import.sql

  • webserver$ vi import.sql

  • :%s/<old_database_name>/<new_database_name>/gc

    The new database name is in the cb_configuration.json file.

    This moment is where it really helps if the database names are globally unique.

  • webserver$ mysql -u <username> -p < import.sql

    The username and password are in the cb_configuration.json file.

  • If document_root/colby-configuration.php exists delete it.

Create And Enable Virtual Hosts On The Web Server

webserver$ php document_root/colby/bin/cbt create-apache-conf

webserver$ sudo cp *.conf /etc/apache2/sites-available/

webserver$ sudo a2ensite <conf_file_1> <conf_file_2> ...

webserver$ sudo apache2ctl configtest

webserver$ sudo systemctl reload apache2

Create SSL Certificates

  • You can tell that your virtual host is working by executing the following command:

    $ curl http://<web_server_specific_website_domain>

    If your virtual host is set up property curl will return either the default page or a 301 redirect to the https URL.

  • certbot should already be installed

    Reference: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04

  • $ sudo certbot --apache

    Follow instructions.

  • You can tell that your was installed correctly by executing the following command:

    $ curl https://<web_server_specific_website_domain>

    If your certificate was installed property curl will return a web page.

Set Up The Website

$ php document_root/colby/bin/cbt setup

If a user doesn't exist for the email address you entered when you configured the site, one will be created and you will be asked for that user's password.

After this step is complete you can navigate to the home page or the /admin/ page to log in.