Create An Internet Production Website (DigitalOcean / Ubuntu 21.04)

Tutorial

Complete Website Domain Tasks

Website Domain Tasks >

Domain Transition Process

In all except the first creation of a website, you are moving a website from another server, at the beginning of this process the primary and secondary website domains will point to the source web server. You will interact with the destination website using the server specific website domain until it is fully working. Then you will alter the primary and secondary domains to point to the destination website.

Prepare The Source Website For Transfer

  • Go to the source website.

  • Go to Develop > Update in the admin area.

  • Click the "Backup Database" button.

  • Option: Do a semi-hot website transfer where the source and destination websites are both running and you are careful not to make changes to the source website during the transition.

  • Option: Shut down the source website or place the site into maintenance mode (future). This will prevent any further significant database changes from occurring during the transition.

  • Set the CBConfiguration_secondaryDomainsShouldRedirectToPrimaryDomain constant to false in the colby-configuration.php file to enable source site access via its server specific website domain.

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 2a: 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.

Enable Virtual Hosts On Web Server

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

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

webserver$ sudo a2ensite <a>.conf <b>.conf

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.