It seems there’s a service for everything, but sometimes you simply learn more by doing it yourself. If y’all haven’t enjoyed the somewhat anachronistic pleasures of running your own server and hosting your own darn website, well, today y’all’re in luck!
Yes, we’re going to take an quondam computer of some sort and turn it into a web server for hosting all of your projects at abode. You could just as easily apply a Raspberry Pi –fifty-fifty a Zero West would work — or really annihilation that’ll run Linux, but be aware that not all calculating platforms are created as as we’ll discuss before long.
Aye, we’re going to roll our own in this article series. There are a lot of moving parts, so we’re going to have to cover a lot of fabric. Don’t worry- it’s not incredibly complicated. And you lot don’t
to do things the way nosotros say. There’s flexibility at every plow, and you lot’re encouraged to forge your ain path. That’southward function of the fun!
Note: For the sake of infinite we’re going to skip over some of the about bones details such as installing Linux and focus on those that have the greatest impact on the project. This article gives a high level overview of what it takes to host your projection website at dwelling house. It intentionally glosses over the deeper details and makes some necessary assumptions.
Cocky Hosting 101
We all know what a website is. You lot’re looking at i. How practice you
a website? You likely have an idea. Some HTML is presented to the world by some kind of spider web server software. But how does the web server know which HTML files to display? And how do people go from a proper noun that they can type in their browser to your web server? How are IP’southward involved, and is this something that can exist done using your habitation Internet connection?
First, let’s talk about a web server. It’southward simply a computer that has software for serving websites. The virtually common server software is called Apache, and information technology’southward compatible with simply virtually whatever kind of website yous may desire to run. Information technology handles the task of associating website requests with the drove of files that brand upwardly a website.
To run Apache nosotros demand a computer and an Os. Nosotros’re going to catch an old laptop and install Linux Mint on it. Linux Mint is a descendant of Ubuntu, and then most Ubuntu tutorials will work fine with it.
For hardware we’re using a Vista-era laptop with a 64 bit dual core AMD Turion processor, 2GB retentivity and an former 120GB difficult deejay. Yes, we actually should spend a few bucks and switch information technology to SSD. But this is merely a thrown together project for the fun of information technology, and there’due south no demand to spend coin on a simple experiment. Of course you don’t have to use an onetime laptop. A desktop computer would piece of work fine, or a small class factor- anything really.
If you’re like me and want the server squirreled away on a shelf, keep in mind that yous volition need a monitor and keyboard to diagnose it when there are bug. A laptop has the benefit of having monitor and keyboard built in! This can come up in very handy when it’s offline and you lot can’t figure out why.
An important annotation about the computer y’all choose: Information technology needs to take a supported Bone. In the x86 world, this means a 64 fleck processor. Most mod Linux distributions don’t support 32 fleck processors well or fifty-fifty at all. Without a supported Os, your projection volition lack current software. This will limit features, but likewise security. You wouldn’t run Windows XP on the Cyberspace, then don’t settle on aboriginal versions of Linux.
First Step: Connect To Internet
A server deserves a wired connection when possible, but wireless is fine likewise as long as it’south reliable. Our ancient laptop doesn’t take a Wi-Fi adapter, so it is hard wired to our Internet service provider provided modem/router/telephone thingy. We also recommend that you lot configure the laptop for a static IP address then that its IP on your network never changes. You lot can do this in the router, or you tin can exercise it in the Ethernet configuration in Linux.
Configuring The Server
Next on our list is installing some basic tools for Linux such as the nano text editor for the control line and the SSH (Secure Beat out) server software. SSH will allow y’all to connect to the server from another calculator, and once SSH is installed, you can stuff the laptop on the shelf next to your router and forget most it. Don’t leave the laptop airtight though- it needs ventilation, so at least leave the screen partially open. To save space, sit down the laptop on its side with the vents facing up.
To log into the server you’ll need a terminal program. Most operating systems come with an SSH Final program such as Windows Terminal or the Terminal in Mac OS. I have been using MobaXterm on Windows for many years and I find it much more user-friendly. Some people prefer bare-bones SSH terminal programs such as PuTTY. Employ what works for you, and get connected to your server by SSH’ing to its IP address.
Next, yous’re going to demand to install the Apache web server software. There are numerous tutorials online for doing this, but watch out: Many of them will take you practice the basic install of Apache, MariaDB, and PHP, and so have y’all host your files in
equally the root user.
Do not do this!
You need to create what’southward called an Apache Virtual Host and a new arrangement user to acquaintance it with.
Master Of Your Domain
Lastly, you need a domain name and a style to associate information technology with your Linux server. In that location are a big number of domain registrars to choose from, and you lot can get a .com domain name for under $10 USD/year. Common geek-approved registrars are Cloudflare or Namecheap.
These are not endorsements
, just a nudge in the right direction if yous’ve never done this before. (Feel gratis to drop your reviews in the comments.)
To associate that domain to your server, yous demand the services of a Domain Proper noun System (DNS) provider. DNS is what maps your domain name to an IP address through what’s called an address (A) record.
That’south one Dynamic IP you’ve got there, Mister
Many domain registrars provide free DNS services, simply they aren’t optimized for hosting at home. Why not? If your server were sitting in a information heart somewhere, it would be assigned a permanent IP accost. Only because you’re hosting it at home, the public IP of your network connection will change from time to fourth dimension and your website will go offline until the IP is updated worldwide. You demand a DNS provider that can detect the change and then update the A record of your domain accordingly.
In that location are many providers of such services and it’s fifty-fifty possible to brand your own. But for simplicity, we are going to recommend running DNS at Cloudflare. Cloudflare provides a Content Delivery Network (CDN) for free that adds a layer between The World and your server. This is convenient because Cloudflare’s IP’s never alter. When your server gets a new IP, it tin communicate this to Cloudflare and they volition route all traffic accordingly without having to update DNS around the world. This is a huge advantage. They also cache your website in their CDN then that when your website hits the front folio of Hackaday, it can survive the onslaught of traffic!
Hiding your public IP from the world is some other reason to utilize Cloudflare. The only IPs exposed to the world will be owned by Cloudflare, and they volition forward web requests to your server while at the same time keeping the bad guys out. This gives another layer of protection to your home server and your home network in general. And the best part is that information technology’s completely gratuitous.
Their excellent documentation describes how to prepare dynamic DNS with their service.
From Spider web Browser to Web Server And Back
Once you’ve got DNS and your web server configured, yous need to tell your router at dwelling house to accept traffic on ports 80 and 443 (the ports for http and https traffic) and route them to your Linux Laptop. Some routers will let y’all set up upwards a DMZ that will directly betrayal the unabridged server to the Internet, but this is non recommended or required. You’ll also want to configure the firewall on your server to accept traffic on port 80 and 443. And since we have 443 open, Let’s Encrypt our HTTP traffic, shall we?
Whether in that location is a technical advantage or not is debatable, but your website is going to need an SSL certificate. If nothing else, this will make your website more palatable to modern browsers who show warnings if there is no SSL certificate present. In the past, y’all’d need a static IP and to spend a good amount of money on the SSL Certificate. Neither of these things are the case now. The SSL Certificate tin can be provided by Let’due south Encrypt, a free SSL/TLS certificate provider that uses software called Certbot to get the certificate and even configure Apache for you. Slick!
What else can you do?
What else can yous practice with your new dwelling server? The possibilities are about endless! Even if you lot take fast internet, yous tin can put your new server to work to speed things up fifty-fifty more. Running your own resolving DNS server locally means that you lot can cache DNS lookups on your ain network, which speeds up DNS resolution. This tin give a snappier feel to your web browsing experience. You can besides use the Pi-Hole software to cake all advertisers so that your devices practice not need a separate advertizing blocker.
A home server also makes an excellent data drove point for your IOT projects and gives yous a playground for experimentation. At that place are many hackers running abode built servers, and some of them have fifty-fifty gone so far equally to make their server run solely on solar, such as https://solar.lowtechmagazine.com/
We’ve outlined all of the moving pieces that you need. Y’all should know though that only as in that location are countless ways to build any other projection, at that place are a huge number of alternate routes y’all could have.
Instead of the Apache web server, you could use NGINX (pronounced ‘engine ex’). Instead of dynamic DNS, you could order a business class Cyberspace connection with static IP’s. Instead of Linux, you could use BSD, Windows, MacOS, or any other number of Operating Systems. Instead of a laptop, you could utilise an old desktop, a Raspberry Pi of any flavour, a surplus rack mountain server from your local Internet garage sale, or fifty-fifty an ESP8266 with a simple web server script on it.
Is that information technology?
Whatever yous do, brand certain to accept fun with the projection, and if you’ve never washed such a thing, we recommend starting down the easiest route and working your way up to the more esoteric methods.
There remain many, many,many
questions to be answered: What software should I use to create my project site? How deep down the rabbit hole should I go when it comes to documenting the project? What toppings do I want on my something-to-eat-while-hacking pizza? Stay tuned for the side by side installment, coming shortly to a Hackaday near you lot!