Create An Internet Web Server Virtual Machine Using Parallels And Ubuntu 20.04
An internet server is a server that can be accessed from the internet. And internet server is used for:
-
a production server
-
a staging server
Each Colby website should have instances on at least four web servers. The development process is a continual repetition of the following process:
-
Changes are made on a local network development server and after testing are eventually pushed to your git repository with a new version number.
-
Changes are installed on a local network test server and tests are run.
-
Changes are installed on an internet staging server and tests are run.
-
Changes are installed on an internet production server and tests are run.
So you will have at least two internet servers, potentially more.
Create A Server
Create a Digital Ocean droplet using Ubuntu 20.04 (LTS) x64
Digital Ocean Recommended Initial Droplet Configuration
Don't create a Cloud Firewall, we will set up UFW on the server to match what we do with local servers.
Create A Domain
Create a unique once in a lifetime domain name for this web server. This is just the domain name for the web server, not any website. In my case this will be something like is8.mtfs.us (staging) or ip8.mtfs.us (production).
Create a DNS A record pointing to the IPv4 address that DigitalOcean assigned to this droplet.
SSH To Your Server
Using terminal app on your workstation, ssh into your server.
$ ssh <username>@<server_domain>
$ sudo apt update
$ sudo apt upgrade
$ sudo reboot
Install Software
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/apache2
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt install
ack
apache2
certbot
libapache2-mod-php8.0
mysql-server
php8.0
php8.0-curl
php8.0-imagick
php8.0-mysql
php8.0-gd
php8.0-mbstring
php8.0-xml
python3-certbot-apache
$ sudo apt update
$ sudo apt upgrade
$ sudo update-alternatives --config php
Select PHP version 8.0
Install Composer
The DigitalOcean website has good instructions for this task here.
Setup Firewall
From: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-20-04
-
$ sudo ufw allow OpenSSH
-
$ sudo ufw enable
-
$ sudo ufw status
Setup Apache
-
$ sudo vi /etc/ufw/applications.d/apache2-server
[Apache Full] title=<title> description=<description> ports=80/tcp|443/tcp
-
$ sudo ufw allow in "Apache Full"
-
$ sudo a2enmod ssl
-
$ sudo a2enmod rewrite
-
DON'T DO THIS STEP UNLESS NOT USING ITK
$ sudo vi /etc/apache2/envvars
We are going to place the document roots for all the websites in your home directory and the only user with websites on this machine is you.
Change:
export APACHE_RUN_USER=www-data
to:
export APACHE_RUN_USER=mattcalkins
:wq
-
$ sudo vi /etc/apache2/conf-available/servername.conf
This file should have a single line:
ServerName <server_domain>
:wq
-
$ sudo a2enconf servername
-
Fix issue that makes Apache stop
Note: Appears to be related to using SSL on Ubuntu. More information not available. Update if more is discovered.
Reference: https://stackoverflow.com/questions/50652808/apache-shutdown-couldnt-grab-mutex
-
$ sudo vi /etc/apache2/conf-available/mutex-file.conf
-
This file should contain a single line:
Mutex file:${APACHE_LOCK_DIR} default
-
$ sudo a2enconf mutex-file
-
-
$ sudo apache2ctl configtest
If there are any unclear issues with the configtest, this command can help you find out exactly what is causing them:
$ sudo apache2ctl -t -D DUMP_INCLUDES
-
$ sudo systemctl restart apache2
-
Go to http://<server_domain> to make sure apache is working.
Setup MySQL
-
$ sudo mysql_secure_installation
Basically answer yes to everything.
Configure PHP
-
webserver$ sudo cp /etc/php/8.0/apache2/php.ini /etc/php/8.0/apache2/php.ini.<today's date>
-
webserver$ sudo vi /etc/php/8.0/apache2/php.ini
-
post_max_size = 65M upload_max_filesize = 64M date.timezone = 'UTC'
Set these properties to these values.
-
:wq
-
webserver$ sudo systemctl restart apache2