Linux Format

WHAT ABOUT AWS?

-

The one-line explanatio­n of a Virtual Private Server is pretty simple. It’s a virtual machine running on a physical machine, alongside other people’s virtual machines. You are responsibl­e for the virtual machine, its uptime, its security updates and so on. Your VPS provider isn’t going to be interested if your VPS gets hacked, it won’t provide security or even updates for you. Case in point, my VPS required downloadin­g around 900MB in updates immediatel­y after initialisi­ng the VPS on DigitalOce­an. Your resources are strictly limited to what you’ve paid for and if you max out the RAM on your VPS, it will crash.

Amazon Web Services is slightly different. It is virtual cloud computing – a phrase which means a lot more than the three words would suggest. Virtual cloud computing means that you won’t have root access to the system, but security and updates are handled on your behalf. It’s also infinitely scaleable, and if your computing needs outgrow what you’ve paid for, Amazon will still allow you to access more and more resources – meaning that your monthly bill can quickly grow out of hand. Thousands of pounds out of hand in some cases, so be careful…

Photoprism Do you like being able to back up, sync and view your photos automagica­lly, but don’t trust Google and Apple not to check out your personals? You need a self-hosted photo manager hosted on a VPS. Photoprism is our choice. Other people may have strong feelings on other software.

The Fediverse The social network you’ve probably never heard of. It has millions of users and thousands of private servers which federate together to create a distribute­d social platform which is surprising­ly usable. If you want to be part of it without signing up to yet another monolith administer­ed and moderated by other people, you’ll need to set up an instance of your own using Pleroma, Mastodon or Soapbox. A VPS is the perfect place to do it!

There are many more potential uses for a VPS, but space necessitat­es brevity. We’ll be coming back to the software I’ve mentioned (and more!) in coming issues.

Choosing the right VPS

With great power comes great responsibi­lity. So said Spider-Man, or possibly Voltaire. When choosing a VPS, the adage shifts slightly to “With great power comes great cost”, so it’s important to know roughly what resources you need your remote virtual machine to have, and an idea of what you want to spend on it.

To have an idea of the specs you require, make a list of the services you’d like to try out then check out the project GitHub pages to see the minimum requiremen­ts. You’ll also want to read about other users’ experience­s to see how the software performs in the real world. While Nextcloud will run happily (albeit slowly) on a VPS with an ARM processor and 512K of RAM, Photoprism demands a minimum of 4GB of RAM in order to index your epic 20GB collection of holiday photos amassed on the beaches of Europe over the last three decades.

It’s a good idea to start small with a low-cost VPS and then add in more memory, storage space and processing power as the need arises.

Being the cheapskate­s we are, we chose a $5 per month DigitalOce­an droplet with an allotted 1GB RAM, a 25GB share of an SSD, and a 1TB monthly data transfer limit. Naturally, this is scaleable and we can upgrade at any time. At the top end of the scale, DigitalOce­an offers a VPS with a staggering 256GB RAM, 32 virtual CPUs, 7TB storage and 10TB transfer limit. At $2,480 per month, this is probably not the VPS you are looking for.

Get up and running

Virtual Private Servers provided by DigitalOce­an are called droplets. It’s a pun: your computing requiremen­ts are a mere droplet in their digital ocean. It hints at their limitless resources and your insignific­ance as both a human being (I feel insignific­ant enough, thanks–Ed) and as a user of their services However, as this section can be broadly applied to providers other than DigitalOce­an, I’ll be referring to the droplet simply as a VPS.

After account creation, which involves verifying your identity by way of adding a $5 balance to your account, you’ll be presented with an array of options, including deploying a web app, hosting a website or static site, deploying a container-based app or deploying a database. The option you want, of course, is ‘Deploy a Virtual Machine.’ This allows you to set up a VPS, from inside which you can do all of the other stuff anyway.

Clicking through to the next screen enables you to configure the specs of your new VPS, and you can choose from a selection of Ubuntu, FreeBSD, Fedora, Debian, CentOS and Rocky Linux. Each of these distros has a range of recent versions available.

‘bunt it up

We chose Ubuntu 20.04 LTS because it’s what we use at home and because it’s the most popular Linux distro, while there is excellent support available from a range of sources. We stayed with the basic single CPU configurat­ion and selected a datacentre in London – a closer datacentre means less latency. The next choice you’ll need to make is whether to use SSH keys or simply a username and password. SSH keys are considerab­ly more secure, but the choice, as always, is yours.

Finally, you will be asked to choose a hostname. By default this will be long, complicate­d and nonsensica­l. We chose something long, complicate­d and sensible:

the-awesome-lxf-virtual-private-server.

With that, it’s time to click Create Droplet or the equivalent button for your VPS provider, and go and make a cup of tea.

Hot brew in hand, you should come back to your machine after ten minutes or so. You’ll see an IP address through which you’ll be able to SSH into your shiny new VPS. Note that you’ll be SSHing as root, eg:

root@159.65.216.202, so the first thing you’ll want to do is to create a new, non-root user with its own home directory skeleton using the useradd command.

useradd -m new_username followed by a new password for your new user using the passwd command:

passwd new_username

Grant your new user sudo powers so you can actually get things done by typing:

usermod -a -G sudo new_username

After this you should log out as root and log back in as your new user. Now you can start using your VPS just like your regular machine at home, update and upgrade the already installed packages using sudo apt update and sudo apt upgrade and start adding packages which will make your VPS journey possible.

As a bare minimum, you should have server software such as Apache or Nginx (always choose Apache because then you can say “It’s a ‘patchy’ server"). You’ll also need PHP and a database such as MariaDB.

You can install Apache by typing sudo apt install apache2 , PHP by typing sudo apt install php , and MariaDB by typing sudo apt install mariadb-server then sudo mysqlsecur­einstallat­ion and following the prompts.

A domain of your own

Finally, you probably want a domain name through which you can access your services from out in the world. As we already own lxf.by, we chose to create a subdomain of that for our first service: vps1.lxf.by.

If you don’t already have a domain name, they can be picked up for a small cost from a provider such as Namecheap, or for free from Freenom.

You need to make sure that the nameserver­s at your registrar are pointed towards the IP address given to you by the VPS provider. Fortunatel­y, this is as simple as changing the standard registrar nameserver to those of, in our case, DigitalOce­an. From within your registrar’s website, find the option for nameserver and change it from standard to custom. In the resulting field, you will want to add something like ns1.digitaloce­an.com, ns2. digitaloce­an.com and ns3.digitaloce­an.com. Your VPS provider will handle the rest.

There is no point in us going into the exact details here as the location of the nameserver settings will vary from registrar to registrar. Most will have a help document available.

After the DNS changes have propagated (you can check this using dnschecker.org), you should be ready to go. Typing in the address of your new domain into your browser should result in you seeing the Apache2 Ubuntu Default Page.

Take a sip of your cooling tea and wipe your brow. The hardest part is over. You have a working virtual machine which you can access through an IP address.

Deploying VPS services

There’s no point having a VPS if all you’re going to do with it is host a static webpage – especially if that static webpage is the most boring and ubiquitous in existence.

A VPS is all about useful services. Search Google (other search engines are available) for ‘Awesome self hosted’ and you should end up on a curated GitHub page with a list of highly rated self-hosted FOSS software. Have a browse and see if there’s anything you fancy. You’ll come across some which require or use Docker and docker-compose. These are outside the scope of this article, but you’ll find plenty of Docker tutorials in previous issues, the most recent in LXF272.

As a super-quick demonstrat­ion piece, I chose Sharlii (https://github.com/shaarli/Shaarli) which is a ‘personal, minimalist, super-fast, database free, bookmarkin­g service.’

To install it, download the package into your VPS home directory using:

wget

Unzip by typing: unzip shaarli-v0.11.1-full.zip

(Sidenote: you’ll need to actually install unzip first with sudo apt install unzip .) cd into Shaarli, them move the contents of the directory to where it can be seen by Apache. cd Shaarli

sudo mv \* /var/www/html/ remove the original Apache index page: sudo rm /var/www/html/index.html

lastly give ownership of the html directory to apache: sudo chown -R www–data:www-data /var/www/html

That’s it. You’ve installed your first web service on your very own VPS. Have a hunt round and find some more – it’s addictive, and before you know it, you’ll be wanting to upgrade your server.

 ??  ?? Every machine needs an awesome hostname – even virtual ones.
Every machine needs an awesome hostname – even virtual ones.
 ??  ?? The first thing you’ll want to do is set up a user who isn’t root – trashing the system by accident is a very real risk. Then again, it’s only a virtual system.
The first thing you’ll want to do is set up a user who isn’t root – trashing the system by accident is a very real risk. Then again, it’s only a virtual system.
 ??  ?? It’s tempting to deploy a web app without setting up your VPS first, but this will only lead to tears. Select the middle option on the bottom row instead.
It’s tempting to deploy a web app without setting up your VPS first, but this will only lead to tears. Select the middle option on the bottom row instead.
 ??  ?? Congratula­tions! You’ve deployed your first web app on your very own VPS. Awesome Self Hosted has plenty of other great suggestion­s.
Congratula­tions! You’ve deployed your first web app on your very own VPS. Awesome Self Hosted has plenty of other great suggestion­s.
 ??  ?? This is where you set custom nameserver­s using Namecheap. The exact location will vary according to your own registrar.
This is where you set custom nameserver­s using Namecheap. The exact location will vary according to your own registrar.

Newspapers in English

Newspapers from Australia