Steps
- log into AWS Lightsail and click on Create instance
- note the zone by the Country flag (e.g. US flag zone:
oregon); change if need be
- select Linux/Unix, OS Only, Latest Ubuntu (22.04 LTS
as of this writing)
- scroll down and select an instance plan (I picked the
least expensive since upscaling is easier)
- name the instance (e.g. example-com-oregon and click
Create instance
- once created, click on the instance name to get to the
instance's dashboard
- click on the Networking tab and then click on Attach
static IP (under the Publc IPV4)
- give the IP a name (e.g. experiment-com-ip) and click
Create and attach
- go to your DNS register and add records to connect
your custom ip name to this static IP:
Hostname | Type | TTL | Data |
@ | A | 3600 | 55.55.555.555 |
www | A | 3600 | 55.55.555.555 |
@ | AAAA | 3600 | 5555:1f55:2e7:1700:76c9:d672:4dd6:5555 |
www | AAAA | 3600 | 5555:1f55:2e7:1700:76c9:d672:4dd6:5555 |
- get ssh credentials by going to the Connect tab and
click on Download default key
- save it in your ~/.ssh directory
(LightsailDefaultKey-us-west-2.pem)
- chmod 600 ~/.ssh/LightsailDefaultKey-us-west-2.pem
- create an alias to ssh to your machine, replacing
55.55.555.555 with your static ip:
alias sshExampleCom='cd $HOME;ssh -i
./.ssh/LightsailDefaultKey-us-east-2.pem
[email protected]'
or create sshExampleCom.bat
:: sshExampleCom.bat -- ssh to example.com
@echo off
ssh -i ~/.ssh/LightsailDefaultKey-us-west-2.pem
[email protected]
- if you want to copy local files to the remote machibe,
use this one-liner (changing the paths):
rsync --chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r --exclude={'*~','#*#','.#*'} --rsync-path="sudo /usr/bin/rsync"
-avze "ssh -i
/cygdrive/c/rcg/.ssh/LightsailDefaultKey-us-west-2.pem"
/cygdrive/c/rcg/src/projects/www/www.example.com/public/
[email protected]:/var/www/public
or create rsyncExampleCom.bat
:: rsyncExampleCom.bat -- sync local to server
@echo off
set params=--chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r --exclude={'*~','#*#','.#*'} --rsync-path="sudo /usr/bin/rsync" -avze
set key="ssh -i
/cygdrive/c/rcg/.ssh/LightsailDefaultKey-us-west-2.pem"
set from=
/cygdrive/c/rcg/src/projects/www/www.example.com/public/
set to=
[email protected]:/var/www/public
On the remote linux machine run the commands:
sudo apt update
sudo apt dist-upgrade
sudo apt autoclean
sudo apt autoremove
sudo reboot
ssh to the rebooted instance, then
sudo apt install unzip
sudo apt install emacs-nox
back on your local machine copy your .emacs.d to the remote:
zip ~/.emacs.d
rsync -avze "ssh -i
~/.ssh/LightsailDefaultKey-us-west-2.pem"
~/.emacs.d.zip
[email protected]:~/emacsConfig.zip
Then back on the remote machine:
unzip emacsConfig.zip
(creating ~/.emacs.d directory)
- Then, for example, I edited my .bashrc
emacs .bashrc
#turn off color
export TERM=xterm-mono
export EDITOR=emacs
export PATH=~/bin:$PATH
# set the prompt
PS1='${debian_chroot:+($debian_chroot)}\u:\w\$ '
alias cls='clear'
alias cup='find . -type f -name "*~" -delete -or -name "#*#" -delete; ls -al'
alias ls='ls -al'
alias ll='ls -alt'
alias md='mkdir'
## maybe do these
#set the ls colors
#eval "`dircolors -b ~/.dircolors`"
alias ls='ls --color=auto'
LS_COLORS=$LS_COLORS:'di=01;32:ln=01;32:ex=00;36:' ; export LS_COLORS
alias cup='find . -type f -name "*~" -delete -or -name "#*#" -delete; ls -al --color'
alias ls='ls -al --color'
alias ll='ls -al --color'
To prepare for a web server:
- In the browser, on the AWS Lightsail dashboard for the
instance, click on the Networking tab
- scroll to the firewall rules and add HTTPS TCP 443 for
both IPV4 and IPV6
- Add apache, node, or
see
How To Set Up the Caddy Web Server
You might also want to learn more about
setting up a cost budget.
References
- An overview on Windows Terminal
- Domain registration in Lightsail
- How to control your AWS costs with the Free Tier and Budgets