Notes on web development.
Uberspace
Notes on the webspace provider.Uberspace is the webhost of my choice for almost all of my web projects.
Setting up a Subdomain
Connect with the your asteroid through SSH and create a directory with the subdomain name:
mkdir /var/www/virtual/username/sub.domain.com
Then use the uberspace tool to set up the subdomain:
uberspace web domain add sub.domain.com
Place your files in the newly created directory load them in the browser using the sub domain.
Ssh
How to setup and use SSH to connect with other computers.SSH is a useful protocol that allows you to connect to servers. You can use it to automate file synchronisation using rsync.
It requires two components, a private and a public key. To set up SSH with a server, you need to upload the public key to the server and configure your computer to check it agains the local, private key.
Generating a keypair
ssh-keygen -t ed25519 -a 100 -f ~/.ssh/keyname
Adding a passphrase is not required, but it's more secure. If you do, make sure to store it in a safe location.
Adding the key to the configuration
Create a config file in the .ssh directory:
touch ~/.ssh/config
Add the following configuration settings to the file:
Host servername
Replace servername with a name that you can remember, change domain.com to the actual domain name as well as username and keyname.
The AddKeysToAgent yes is only necessary if you created a passphrase.
Copying the Public Key to the Server
ssh-copy-id -i ~/.ssh/keyname.pub servername
Now you should be able to access the webserver with
ssh servername
If you created a passphrase you will need to enter it when connecting to the server for the first time.
Cron
Running a command in regular intervals.Connect to your server through ssh and enter
crontab -e
Now you can enter a command to run in the following format:
minute hour day month weekday command
For example:
0 2,18 * /usr/bin/lua /path/script.lua >> /path/script.log 2>&1
Will run the lua script script.lua every day at 2am and 6pm and log it's output to script.log.
incoming(1) | rsync