Create A Local Network Development Website (Ubuntu 21.04)
doc id: 99634924efe5cb9fbd203bdf6ec35d93fea3cdc4
Complete Website Domain Tasks
Create A Colby Website Project On Your Development Workstation
-
Start the Terminal app on your workstation.
-
webserver$ cd <colby_projects_directory>
-
workstation$ mkdir <reverse_server_specific_domain>
-
workstation$ cd <reverse_server_specific_domain>
-
workstation$ curl -s https://mattifesto.com/install/ > install.php && php install.php
Scenario 0: Create A New Colby Website Git Repository
In this scenario you have chosen to create a whole new website that is being born in this moment. This only happens when you are creating a website that has never existed before, at least not as a Colby website.
-
choose option 0) create a brand new website
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 Workstation
-
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.
-
workstation$ rm -rf document_root
-
workstation$ 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.
-
workstation$ 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.
-
workstation$ 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.
Share The Website Project Folder With The Development Web Server
-
$ ssh <development_web_server>
-
Create any parent directory structure that you want to place you project in on the server.
-
Your user also needs to belong to the group "vboxsf" to be able to view the shared directory.
First see what groups your user currently belongs to:
$ groups
If the list does not include "vboxsf" then:
$ usermod -a -G vboxsf mattcalkins
If you had to add your user to the group you must log out and then log back in again.
Share Directory
-
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 website project folder you just created. -
Check the "Auto-mount" check box.
-
Mount Point:
/home/<username>/<parent_directories>/<website_project_folder> -
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.
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
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.