Creating A Private Development Website For An Existing Repository (Ubuntu 20.10)

This tutorial is written by completing the actual scenario I have at the time I'm writing it.

First you need to have a private development VirtualBox web server created before you start this process. The web server in my case has a public domain name of:

webserver4.mattifesto.com

The domain for the development website in my case is:

devs.webserver4.mattifesto.com

Your website domain should have a DNS CNAME record that points to the main web server domain.

Notes

  • Because of the way development websites are set up you may need to manually restart the Apache process after you boot because its automated start may be cancelled because the network shares are not yet available soon enough after the boot process.

Create Website Directory On Host Machine

  • Navigate to the folder the contains all your website directories.

  • I use the reverse domain name for my website directories, but you can use whatever naming scheme you like.

  • $ mkdir -p com_mattifesto_webserver4_devs/logs

  • $ cd com_mattifesto_webserver4_devs

Option 1: If you are creating a fresh website instance:

  • $ git clone git@github.com:mattifesto/com_mattifesto_devs.git document_root

  • $ cd document_root

  • $ git submodule update --init --recursive

Option 2: If you are copying another website instance:

  • 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.

  • $ cp -r ../copied_website_document_root document_root

Create Database On Web Server

One of the principles of the Mattifesto Method is using unique identifiers which makes searching and potentially replacing much easier. The database is named "com_mattifesto_webserver4_devs_database" because naming it "devs" or even "devs_mattifesto" would create a name overlap in many places.

  • $ ssh webserver4

  • $ sudo mysql

  • mysql> create database com_mattifesto_webserver4_devs_database;

  • mysql> create user 'web'@'localhost' identified with mysql_native_password BY '********';

  • mysql> grant all on com_mattifesto_webserver4_devs_database.* to 'web'@'localhost';

  • mysql> exit;

  • $ mysql -u web -p

  • mysql> show databases;

  • mysql> exit;

Share The Website Folder With The Web Server

  • Open the VirtualBox Manager window.

  • Select the web server virtual machine.

  • Click the "Settings" button in the toolbar.

  • Click the "Shared Folders" button in the toolbar.

  • Click the small folder icon with a green plus on the right side of the panel.

  • Folder Path:
    Select the com_mattifesto_webserver4_devs folder you just created.

  • Check the "Auto-mount" check box.

  • Mount Point:
    /home/mattcalkins/www/com_mattifesto_webserver4_devs

  • Check the "Make Permanent" check box.

  • Click the "OK" button.

  • Click the "OK" button.

  • Verify the the shared folder is present on the web server.

Create Virtual Host On Web Server

  • $ sudo vi /etc/apache2/sites-available/com_mattifesto_webserver4_devs.conf

    <VirtualHost *:80>
    
        ServerName      devs.webserver4.mattifesto.com
    
        ServerAdmin     matt@mattifesto.com
        DocumentRoot    /home/mattcalkins/www/com_mattifesto_webserver4_devs/document_root
        ErrorLog        /home/mattcalkins/www/com_mattifesto_webserver4_devs/logs/error.log
        CustomLog       /home/mattcalkins/www/com_mattifesto_webserver4_devs/logs/access.log combined
    
        <Directory "/home/mattcalkins/www/com_mattifesto_webserver4_devs/document_root">
            AllowOverride   all
            Require         all granted
        </Directory>
    
    </VirtualHost>
    
    
    <VirtualHost *:443>
    
        ServerName      devs.webserver4.mattifesto.com
    
        ServerAdmin     matt@mattifesto.com
        DocumentRoot    /home/mattcalkins/www/com_mattifesto_webserver4_devs/document_root
        ErrorLog        /home/mattcalkins/www/com_mattifesto_webserver4_devs/logs/error.log
        CustomLog       /home/mattcalkins/www/com_mattifesto_webserver4_devs/logs/access.log combined
    
        SSLEngine               on
        SSLCertificateFile      /home/mattcalkins/.acme.sh/webserver4.mattifesto.com/webserver4.mattifesto.com.cer
        SSLCertificateKeyFile   /home/mattcalkins/.acme.sh/webserver4.mattifesto.com/webserver4.mattifesto.com.key
    
        <Directory "/home/mattcalkins/www/com_mattifesto_webserver4_devs/document_root">
            AllowOverride   all
            Require         all granted
        </Directory>
    
    </VirtualHost>
    
  • $ sudo a2ensite com_mattifesto_webserver4_devs

    $ sudo apache2ctl configtest

    $ sudo systemctl restart apache2

    Set Up The Website

    Option 1: If you are creating a fresh website instance:

    • On your workstation browser, navigate to:

      https://devs.webserver4.mattifesto.com/colby/setup/

    • MySQL Host: localhost

    • MySQL Username: web

    • MySQL Password: <password>

    • MySQL Database: com_mattifesto_webserver4_devs_database

    • Developer Email Address: Use the email address you want to use for your user account on this specific website.

    • Developer Password: Enter the password you want to use for this specific website.

    • Confirm Developer Password: re-enter password

    The website will point out a few more steps you will want to take. You will also want to setup an email account so that email services can be used.

    Option 2: If you are copying another website instance:

    On webserver4:

    • $ cd www/com_mattifesto_webserver4_mattifesto/document_root/

    • $ cp tmp/database-backups/<most recent backup file> tmp/database-backups/import.sql

    • $ vi tmp/database-backups/import.sql

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

      This moment is where it really helps if the database names are unique like we mentioned at the beginning of this document.

    • $ mysql -u web -p < tmp/database-backups/import.sql

    • $ vi colby-configuration.php

    • Manually update the constant values for for the new website.

    • On your workstation browser, navigate to:

      https://devs.webserver4.mattifesto.com/admin/

      Your password is the same as it was for the copied site.

      Go to the update admin page for the website you are copying and click on the "Update Site" button to create the tables that aren't exported in database backups.