adikos.net

On Self-Hosting: some thoughts

Last updated 26 May 2024: various updates, caveats about WordPress

Prolegomena

So I've been self-hosting for a few years now (since August 2020), and it's been an interesting time. I've really enjoyed it, but also had a lot of learning experiences along the way. I wanted to share my experience and give some insights about what I've learned over this time. I'm learning all the time, and I've barely scratched the surface.

Prerequisites

I was surprised to find that it's actually, for the most part, not super cost-prohibitive to self-host, if you play your cards right and find a good domain name registrar and hosting solution.

So what do you need to get started?

Really, just two ingredients. We'll dive into your many options for those two ingredients, though; sometimes these two are one and the same, depending on how you do it.

The Domain Name

Of course, this is the first thing your site's visitors will see: the URL or web address of the site. So pick something snappy, interesting, whatever you like... make it yours! As I've mentioned on the front page, I've always liked the Greek adjective ἄδικος (adikos), "unjust," so I went with it; this is a much later iteration of a site I started out with ca. 2005.

Once you've picked your name, or a slate of possible contenders, you'll need to decide on the suffix: .com, .net, .org, .biz, or a plethora of other possibilities. There are a lot more these days than there used to be. Mine used to be .org since I liked the sound of it.

Now you need to find a domain registrar who can sell you the domain name of your choice. There are tons of these around as well (GoDaddy and such; I can't really think of any others at the moment). I previously used Gandi, but am now using Porkbun and find it really great.

Picking a hosting provider

Herein lie the more difficult choices. You have a number of options for this, which can be paralyzing at times.

All-in-ones

Do you want a one-size-fits-all, all-in-one solution? Try something like Squarespace, where they'll sell you hosting, blogging/web page creation, and domain name all at once. I used Squarespace for awhile, and while it was nice, it wasn't ultimately for me. I wanted more control over my site and what I did with it, and what apps &c. I could install.

Shared hosting

Do you want someone to take care of hosting, webspace, and any apps (WordPress, &c.) for you, but have a little more choice in what apps you want to use? You might think about shared hosting.

Shared hosting offers you webspace on someone's server, and you can point your domain name at it, but ultimately they administer the server, keep it updated, and keep it working.

I used to use DreamHost, which offers not only shared hosting, but I think they also offer VPSes (about which I'll talk a bit below, my preference these days). I ran into some of the same obstacles as Squarespace presented, so I ultimately switched. But it may be wonderful for you, so look into it. There are plenty of shared hosting providers.

Virtual Private Servers (VPS)

Another option, which I found out about after much trial and error, is a Virtual Private Server (VPS). The company gives you "root" (admin) access to a virtual machine, complete with shell access, and you basically completely control the machine. You can restart it, shut it down, and turn it back on, and treat it like your own personal computer. The company will give you a certain amount of disk space, bandwidth, RAM, and processing power (you can usually pay more to upgrade this space in future if desired).

In my personal experience thus far, I've enjoyed having a VPS the best of all the options I've mentioned. But I am pretty techy, and don't mind getting my hands dirty, so to speak.

I really enjoy my provider, Contabo. Their VPS's are affordable and they have had rock-solid uptime. I really can't recommend them enough. Their servers are based in Germany but they also have some US-based servers; I think the former is an asset, though, honestly.

Dedicated Server

This is the type I know the least about. Dedicated servers are literally your own physical machine, as far as I understand it. This is by far the most expensive way to do hosting if you're going to pay someone else (like $100+ USD/month at least, if not more).

Completely self-hosting

You also have the option of self-hosting on your own machine, in your own home. Many people do this with a Raspberry Pi or a spare machine (if you happen to have one lying around), and it's relatively inexpensive if you have the tech already. It's certainly an option, but not in my household, where I don't have a permanent place for a machine to live, and besides, one of my kitties would eat its cables (!).

Pros and Cons / Comparison

A VPS gives you near-complete control over the system, even down to what OS you install, and thus gives you the greatest freedom over what you run on your server. You can pretty much run whatever you want, provided you have the disk space and processing power to handle it. Those are the pros of a VPS.

The cons of a VPS? You manage the entire machine yourself. It breaks? You have to fix it. Keep good backups in case you lose files. You have to keep everything up-to-date. You have to secure the server against hackers, who are constantly trying to break into your server, as long as it's connected to the internet. Believe me, I get an email digest from the program logwatch every day, and most days there are 50+ attempts to ssh into my server and exploit something. You have to harden its security and keep bad actors from getting in. And that's difficult, but we can talk about some ways to do that.

So the pros of shared hosting or all-in-one solutions are that they take care of the hard stuff for you: maintenance, security, perhaps even backup solutions. And that works just great for most people -- if that is your style, go for it! Knock yourself out and enjoy it! You want to make it your space, and if all you care about is the blogging, writing, or whatever you're trying to do, and don't want to waste time on anything else, I totally get that.

Personally I really enjoy having a VPS because it's my own little space in the "cloud." My own "cloud," and I don't have to trust others with my data. Well, I do have to trust the VPS provider to a certain extent, since they ultimately control the machine, but that won't be an issue with any reputable company. There is no such thing as no-risk unless you're hosting it entirely on your own.

And again, you can certainly host entirely on your own, if you run your own machine at home, connected to the internet. Part of the issue with that is that most ISPs don't take too kindly to that; most of the time they frown upon having FTP servers in the household, but most are not super OK with people self-hosting in their home. Make sure to check your ISP's rules.

Dedicated servers also sound nice, but I don't really 100% see the advantage of that over a VPS, honestly. I don't see the point for the extra cost. If there's an argument to be made, I am all ears, but it's not worth the money for me.

What's all this going to cost me?

Good question. And not an easy one to answer, since it depends on your chosen hosting and domain name solution. I can only really speak to my own experience.

Hosting Solutions

Domain Name Registration

This could be widely variable as well, depending on your domain. Currently my domain is $11 USD/year. But it really depends on your registrar, and they pretty much charge whatever they please.

Totals

So what is the total cost for you depending on the hosting provider and domain name together?

What's next?

Well... you've got the domain name of your dreams, you've got your hosting sorted. Where do you go from here?

If you're doing shared or all-in-one hosting, see what apps are available to install on your site, and install them. They should make it pretty easy to do whatever you like, at least within their framework. WordPress is a great start if you want to make easy webpages and write blog entries without thinking about it too much. You can pretty much just get going and do your thing, no major hurdles.

But what if I'm going the big bad VPS route?

Well, therein lies most of my (recent) expertise. It's funny, since most of my expertise in the past involved shared hosting, but I'm happy to be learning more about VPS's and their quirks, their problems and their solutions.

Choosing your OS

So you're installing your OS from scratch on the VPS. Many providers will give you an option of what to install, and sometimes even give you a one-click solution to install it.

I installed Debian on mine, since Debian is utterly reliable and great for servers. But you can pretty much go with whatever you want. Some people love the idea of Windows on a server, but I really prefer Linux.

The Webserver

Now I don't know about you, but I didn't really want to set everything up from scratch... not entirely. You can go with LAMP (Linux, Apache, MySQL, PHP), a fun acronym for a collection of powerful tools to run a webserver: some variety of Linux for the OS, Apache for the webserver software, MySQL for database software, and PHP for running apps (WordPress runs on PHP, for example, with a MySQL database). I'm not sure how to get that set up on Debian, but I'm sure there are plenty of tutorials out there.

YunoHost

I am not sure where I heard about it, but YunoHost was my gateway to running my server easily and efficiently. Named after a meme ("Y U NO..."), their suggestion is that self-hosting should be easy to do and accessible to everyone. YunoHost is a layer that runs on top of Debian, and allows you to administer your server easily and efficiently. It has a great web administration interface, but you can also use the command-line interface (CLI) through SSH if you want to get more under the hood. Of course, you can also edit a number of things yourself in the shell if desired.

Go to the YunoHost website for instructions on how to bootstrap/set up your YunoHost installation after you've installed Debian. It's really pretty easy to set up and they provide very clear instructions.

YunoHost Domains

It's easy to add a domain in YunoHost. Let's say you want a subdomain off of your main site (wordpress.yourwebsite.com or whatever). You can add it in the Domains section of the web administration. You'll also have to set up the DNS records in your hosting provider to point at that subdomain. YunoHost gives some suggestions on how to set up DNS records, something which I'd never done before, so that was really helpful knowledge. If the DNS records are not set up correctly, the subdomain won't work, or won't point to the right place.

YunoHost Apps

YunoHost makes it very easy to install whatever apps you like. For example, I have WordPress, NextCloud, Synapse (Matrix chat server), Searx (metasearch provider), and Bitwarden (password manager) installed on my server. You tell YunoHost what domain it should live on, what its URL should be, and some other settings.

You can also easily back up whatever apps you want, and upgrade them easily. YunoHost lets you run Debian updates (`apt upgrade') and also upgrade YunoHost apps easily. I try to check for updates a couple of times a week at least.

In terms of CMS (content management systems), you've got a lot of choices for imparting information to your visitors:

There are lots of other CMS's out there I'm not mentioning here, but I thought these three were well worth mentioning here.

Security Hardening

This is an important step with your VPS. YunoHost has a good guide to security hardening. Of course, it applies mostly if you're running YunoHost, but these are some good suggestions in general:

I am sure there are more suggestions, but those two are a good start and I am quite happy after doing both.

Stray thoughts

Make sure your server is something you can reach wherever, whenever. I am not entirely following this rule, since I don't carry around a copy of my SSH key. (This is a good thing; if I am away, like when visiting family or whatever, I administer my server through the webadmin).

If you're not using YunoHost, find a way to access and administer your server remotely. VNC is an option, too, at least with my hosting provider. It's kinda slow and not ideal, but it'll get the job done in a pinch. I had to VNC in when I upgraded my storage/server so I could log in to the rescue disk and grow the filesystem. That was a scary situation but I was able to figure it out!

So those are my thoughts on self-hosting so far. I might update this with more detail later, but this is a good start. I've had a great experience with it thus far and I am really enjoying it. It's not perfect always, but what is? If you have questions, especially on YunoHost, I'm happy to (try to) help. Cheers.