There's a lot of different tutorials on hosting a website, setting up Wordpress, or even installing and configuring Nginx (which I think is one of the harder parts of managing a server), but there aren't a lot of people who go over something that must be done before all that; getting a host machine set up to provide web content. And ironically, as much as it's avoided by suggesting webhosts and virtual private servers post and post again, it's not really that difficult. In fact, it's probably the easiest thing you'll ever do on your journey to webmastery. And here are the steps involved. Are you ready?
- Install a server-specific OS (Ubuntu Server, OpenSUSE Headless, Arch Linux btw, Windows Server insert-year-here, Generic Operating System: Lose-Your-Head Edition, etc.) on a dedicated machine.
...That's it. I'm not kidding, you can literally have a webserver nearly completely ready by just installing the OS. Ubuntu Server is usually my go-to because it comes ready and hosting Nginx out of the damn box. I feel like the biggest intimidation about using a headless server OS is two things. One, it's probably based on Linux, and Linux is scaaawy and unfwieeeendwy. And two, it's all command line, no graphic user interface, and typing is scaaawy and unfwieeeendwy. But once you put on your biggie bean pants and dare I say, use one of these specialized OSes, you'll realize it's silly to fear those things, because fearing those things is silly.
For real, I get why it's so unnerving. Seeing a screen where all you have is a mock IRC client from the 1980s is definitely about as descriptive as playing the Legend of Zelda for the first time. It took me about two hours before I realized that black square in the mountains was a cave required to do anything in the game. Your "cave" in the terminal is going to be a list of the following commands (Things in square brackets are optional, things in equality brackets are required):
- ls [directory] - Lists current directory contents
- cd <directory> - Changes directory
- man <command> - Manual for specified command
- nano </path/to/file> - Edit file text
- sudo <command / parameter> - Invoke elevated privileges
That last one is important; it allows you to use most of the other commands on most of the files you need to use most of the other commands on.
Now, depending on what OS you choose for this server, the amount of after-install setup to do may be as much as getting all necessary packages or literally nothing at all. I recommend Ubuntu Server, because you can install it one one machine, and navigate to its hosted webpage on another, and the bare minimum is done. But if you choose something else (OpenSUSE is a good option that may need some setup), here's the basics of what you need:
- A firewall (ufw / iptables)
- A webserver (nginx / apache2 / lighttp)
- Semi-optional: A database (mysql / postgresql / mariadb / sqlite)
- Optional: A CMS (Wordpress / Ghost / Grav / so many others)
A firewall keeps others from seeing things other than what they should (i.e., your website). I put this as required because honestly, it's a security thing. Trust me, I wouldn't risk it. I get at least 20 people a day trying to access a non-existent "/wp-admin/" page, and even if I did have a Wordpress, they wouldn't be able to sign into it unless they were literally in my house.
A webserver is, well, a server of web. Kinda obvious why you need one, and kinda understandable why some server distributions just come with it pre-installed and pre-enabled. A website doesn't host itself.
A database is listed as semi-option, because it really goes with what CMS you choose, if you choose one at all. If you choose something like Wordpress, you must have a database installed. If you choose something like Grav, you don't need one. In fact, you shouldn't need one, because it doesn't have any use for one.
This is just the beginning, and you may have noticed that I didn't actually explain how to hook all of these together. That's because I only want to give you the basic information you need, and a few things you can choose from. All servers only have one thing in common; they're servers. Every server is different in at least one small way. Sure, I can tell you what I'm using to host my website (Ubuntu Studio, Nginx with PHP, MySQL 8.0 with PHP, Ghost), but that could be different than what my friend might use (OpenSUSE, Apache with PHP, PostgreSQL, Wordpress) and different than what my dad might use (Windows Server, Apache without PHP, No SQL, No CMS), but that's the fun in it. Sure, there's a possibility of confusion, frustration, and retracing steps, but when you have all this lab equipment, how could you not experiment?
If you already have a setup in mind, go for it already. Start Googling. Start with the OS. Which one do you want to use? What makes it a better choice for you than another? What challenges come with this that aren't present in another (which is just as valid a reason to choose something as to avoid it if you're feeling adventurous!)? You have a literal world-wide web of stuff to choose from, no need to choose wisely.
Oh, and one more thing. You might want to learn a few other skills, but they vary in importance depending on what you go with:
- HTML/CSS/JS coding
- PHP coding
- CLI proficiency
- A high-school reading level
- A thirst for knowledge
The last one is in all caps. You'll more than likely find out why. Trust me.
Go out and show yourself to the world, friends.