lunasqu.ee-nuxt/content/blog/Self-hosting-Part-1.md

115 lines
9.6 KiB
Markdown
Raw Normal View History

2022-10-16 09:37:13 +00:00
---
title: Self-hosting, Part 1
tags:
- linux
- tutorial
date: 2019-02-23 23:17:18
---
Today I will be describing to you my experiences with self-hosting and how you can get started as well.
Im not going to go into detail in this article about how to install and configure anything, but the websites for respective pieces of software have great documentation and you can always look for more information online. Followup blog posts may come in the future describing setups that Ive created.
## 1. Hardware
Believe it or not, you dont actually need a server computer to host your websites, email or other networked software. You can use pretty much any old computer to do what you want. I know a guy who uses a laptop without a screen as a server, and quite successfully so. Your server could be anything, from an old Android phone to a router to an actual server computer, just as long as you have it connected to a network.
I have personally been using [Raspberry Pi](https://www.raspberrypi.org/) computers for my personal servers. What you might learn the hard way, though, that you really dont want to do many write operations on a simple SD card, instead, I recommend getting a 2.5” Hard Disk Drive or a even a Solid State Drive with a simple USB to SATA converter, which you can get cheap off [eBay](https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=usb+to+sata&_sacat=0) or [AliExpress](https://www.aliexpress.com/wholesale?SearchText=usb+to+sata). Ive had quite a few corrupted SD cards on my Raspberry Pis due to high amount of concurrent writes.
### 1.1. Hosting services
For most of the heavy-lifting, though, I recommend using Virtual Private Servers for online services. I use a 10€/month cloud server from [Hetzner](https://www.hetzner.com/cloud) to host most of my websites, databases and email. I can only really recommend Hetzner and [OVH](https://www.ovh.com/) because Ive had the best experiences with them, but you can search around the web for VPS hosting. Be sure to look at reviews and make sure to read the Terms of Service notices!
If you have more money to spend, you can also look for hosted dedicated servers.
With hosting services, you also avoid the problem of having to expose your IP address or open ports on your local network. If you dont like your IP address being public or you simply are unable to open ports on your network, I strongly recommend that you get a low cost virtual private server instead of any local computer.
## 2. Operating System
What youre looking for here is an operating system based on the [Linux kernel](https://en.wikipedia.org/wiki/Linux_kernel). I can recommend [Debian](https://www.debian.org/intro/about), [CentOS](https://www.centos.org/) and [Arch Linux](https://www.archlinux.org/). Linux systems are (mostly, there are paid enterprise solutions) completely free, in every sense of the word, and open source.
If you run into any issues with Linux systems, or just want to know how to configure or use a certain program, an absolutely wonderful online resource is the [Arch Linux Wiki](https://wiki.archlinux.org/), and you dont even have to use Arch Linux in order for it to be useful to you.
## 3. Software
Theres _a lot_ of things you can run on your own server computer, so in this section, Im going to tell you about some of the more common and more useful services.
### 3.1. Website hosting
Of course everybody wants to have a website. What would a self-hosted server be without a website?
The first thing you need in order to run a website is a web server. For beginners and simple setups, the most popular choice is the [Apache HTTP Server](https://httpd.apache.org/), however for more versatility and better (in my opinion) configuration and proxying, I recommend [nginx](http://nginx.org/) as well.
For the actual content of the website, you also have _a lot_ of options. A very good and popular free platform you can use is [WordPress](https://wordpress.org/). Of course, theres the possibility of writing a website yourself, either in PHP and HTML or just HTML and CSS.
### 3.2. Private File Cloud
If youre like me and dont like having your files on **someone elses computer**, hosting a “file cloud” yourself is a good bet. The best software to do this (by far) is [NextCloud](https://nextcloud.com/). It allows you to easily synchronize files between your computers and mobile phones and you always know that your files are safe in your own hands.
Be warned though, this application server takes a good chunk of your computer resources, so you might need something more powerful than a Raspberry Pi for this one.
#### 3.2.1. Online Documents
NextCloud can very easily help you transfer documents between your devices, but theres also the option to integrate an Office platform, such as [Collabora Online](https://nextcloud.com/collaboraonline/), which allows you to view and edit your Office documents on the go, just like Google Docs or Office 356 Online, but youre in control!
Be warned again, these applications are also a significant load on your server.
### 3.3. Mail Server
Okay, so youve got it in your head that you also want to host a mail server for yourself, but let me stop you right there. Setting up a mail server is **a really tedious and time consuming task** and youll probably end up giving up and using Gmail or Outlook in the end anyway. A misconfigured email server could also do a lot of harm, so please be careful with what you configure and always read the documentation if you really do plan on hosting your own mail server.
If that didnt scare you, you may proceed. Just know that you should **NEVER** host an open email relay unless you really know what youre doing.
#### 3.3.1. Mail Transfer Agent (MTA)
The MTA is the program used to send emails. It does not necessarily let you read/manage inboxes on its own.
One of the more popular MTAs, and the one I use, is [Postfix](http://www.postfix.org/). Creating the perfect configuration to meet your needs is, again, a tedious task. You can look for example configurations online and try them out yourself.
#### 3.3.2. Mail access (IMAP, POP3)
This is the application that actually allows you to access and store your emails on your server.
The most popular software for this is [Dovecot](https://www.dovecot.org/). Dovecot is really good at doing what it does and it allows you to set up mailboxes and can even do message sorting ([pigeonhole](https://wiki2.dovecot.org/Pigeonhole) sieve).
#### 3.3.3. Mail filtering
Mail filtering is what you would use to combat spam.
A great free software for combating spam is [SpamAssassin](https://spamassassin.apache.org/) and you can use [ClamAV](https://www.clamav.net/) to detect viruses in incoming mail.
### 3.4. Database
If you need a database, your own server is also a good place for that. For SQL databases, I recommend using [MariaDB](https://mariadb.org/). For NoSQL, you could use [MongoDB](https://www.mongodb.com/). Youll need a MariaDB database if youre going to host WordPress on your server.
## 4. Communication
Communication is an important part of society. Did you know that there are free and open source solutions that you can put on your own server that allows you to communicate with your friends? Here are some that I have personally come in contact with and can recommend.
**1. An aging, historical solution: IRC**
IRC (Internet Relay Chat) is an old text-based protocol used in ages old chat rooms. Believe it or not, it is still used to this day. IRC is a quick and easy way to communicate in text. A popular IRC server application is [inspIRCd](http://www.inspircd.org/).
I personally still host an IRC server for me and my friends.
**2. Purely for voice chatting: Mumble**
[Mumble](https://wiki.mumble.info/wiki/Main_Page) is a free and open source low latency voice chatting application. In order to host your own server for Mumble, you need [Murmur](https://wiki.mumble.info/wiki/Running_Murmur) (mumble-server).
**3. Up-and-coming communication standard: Matrix**
[Matrix](https://matrix.org/blog/home/) is a free and open source decentralized communication protocol. Anyone can host a server (called a homeserver) and people from different servers are able to communicate with each-other. The current go-to homeserver solution is [Synapse](https://matrix.org/docs/guides/installing-synapse), however more options are coming in the future.
As a disclaimer Id like to say that Synapse is a large application and it might not be plausible for you to host it on your machine.
**4. Simple and modern: Rocket.Chat**
[Rocket.Chat](https://rocket.chat/) is a free and open source communication platform aimed for teams. Despite being aimed for teams, its also a great solution for chatting with your friends. It allows you to create rooms and also provides end-to-end encryption for messages.
Ive personally hosted a Rocket.Chat instance and can say that it is a good platform, however me and my buddies are old-school and like our IRC server more.
### 4.1. Your own social network!
Have you ever thought about running a Twitter-like platform that you had full control over? Well, now you can! With [Mastodon](https://joinmastodon.org/), you can create your own social networking platform, called an instance. Instances are joined together in a global federated network called the [Fediverse](https://en.wikipedia.org/wiki/Fediverse), which allows you to communicate with anyone on any Mastodon (or other platform on the Fediverse) server without making multiple accounts.
## Conculsion, for now..
Theres a lot of things you can do with your own server. Hopefully this blog post was of any use to you.