server-guide is a recipe for deploying simple web applications on Amazon Web Services.
- Log in to Amazon EC2.
- Launch a new instance.
- AMI: Ubuntu Server 16.04 LTS (HVM), SSD Volume Type
- Instance Type: t2.micro
- Security Group: SSH, HTTP, and HTTPS enabled
- Log in to Amazon Route 53.
- Create a DNS
A
record for every desired hosted zone pointing to the IP address of the new server created above. - (Recommended) Create a
*.<hosted-zone>
DNSA
alias record for everyA
record created above.
Identity files should be located locally at ~/.ssh/
. Adjust all identity-related steps from here on accordingly if they are located elsewhere or named differently.
-
(Recommended) Create/edit your local SSH configuration at
~/.ssh/config
, i.e.:Host <host-name> HostName <ip-address> User ubuntu IdentityFile ~/.ssh/<key-pair>.pem
-
Perform an initial SSH into the server:
ssh <server-name>
(short, if configured), orssh -i ~/.ssh/<key-pair>.pem ubuntu@<server-name>
(long).
- Change
hostname
:sudo nano /etc/hostname
, with contents<server-name>
; thensudo nano /etc/hosts
, edit thelocalhost
line to read127.0.0.1 localhost <server-name>
; thensudo hostname <server-name>
. - Perform an initial system update:
sudo apt-get update
, thensudo apt-get dist-upgrade
, thensudo reboot
. - (Recommended) Install and enable Byobu (5.106-0ubuntu1):
sudo apt-get install byobu
, thenbyobu-enable
.
-
Install the MySQL APT repository:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb
, thensudo dpkg --install mysql-apt-config_0.8.10-1_all.deb
, thensudo apt-get update
. -
Install MySQL (5.7.22-1ubuntu16.04):
sudo apt-get install mysql-server
. -
Install libmysqlclient-dev (5.7.22-1ubuntu16.04):
sudo apt-get install libmysqlclient-dev
. -
(Recommended) Create/edit the
ubuntu
user's MySQL option file at~/.my.cnf
, i.e.:[client<database>] database='<database>' user='<database>' password='<password>' prompt='<database>> '
-
Install Git (2.7.4-0ubuntu1):
sudo apt-get install git
. -
Use GitHub's guide to set up a read-only deploy key (email and passphrase are not necessary).
-
Set up a SSH config:
nano ~/.ssh/config
, with contents:Host <repository> HostName github.com User git IdentityFile <deploy-key>
then
chmod 644 ~/.ssh/config
. -
Install the repository:
git clone <repository>:<repository-owner>/<repository>.git
.
- Follow the instructions in Vapor's guide to install Vapor (3.1.6).
- See Vapor's example to set up Vapor with Upstart.