There are various answers to this question, and it all depends what you want. I’m going to break this up into two segments: Local and Remote. As in, do you want to use it on your computer/internal network, or do you want to give everyone access.
Keep in mind, no one’s saying you can’t do both. There are ways to run an internal web server and expose it to the internet. And if you’re brave you can do that. But I’m personally too paranoid to do it, and especially too paranoid to recommend it.
What is a web server, and why would I want one?
Good questions, both of them.
A web server is a program running on a computer. And the program and computer are both interchangeable. It’s a vague definition but there are just so many varied ways to approach this so bear with me.
The “server” moniker means that it’s sitting there waiting for request and will handle those requests and do something with them and usually give you responses.
The website you’re viewing this blog on now is using a web server like Apache or NGINX, two very common pieces of software for large scale web applications and is serving you an HTML page, which is just text, which is then rendered by your browser.
This interaction of you making a request, then the web server sending you a response is really the main dynamic of web serving/servers/services. And it’s the dynamic on which the entire modern web is built. Everything from blogging, to e-commerce, to YouTube is nothing more than requests and responses back and forth with these interactions. Of course there’s more complexities and intricacies than that. But that’s enough to get us started.
Why would you want one?
Because what I’ve just described is very powerful. It allows you not just to make websites, but also interfaces which can communicate with the “back-end” of your web server. In other words your web server can allow you to do more than just interact with the website. It can facilitate behaviors on the computer it’s running on.
For instance you could run a web server on a Raspberry Pi, plug that Raspberry Pi in to several other electronics or hardware and then use it to manage those devices with an interface. And this kind of thing is done a lot.
Another good reason is to run your own website, whether internally or externally and serve it up to the wider internet. You can always use a DNS service like Free DNS and even get your own free subdomain which links to your server’s IP address wherever it is and get up and running right now today, provided you take all the right steps.
Going hand in hand with that is learning web, networking and general internet knowledge and technologies. As someone who has made a career of managing web servers professionally, I can tell you that it’s a field of both breadth and depth where there is always more to learn.
You’ll often hear reference to the “stack” of programs a web server runs. Because these days no one is just serving up static websites, but dynamic websites that require the ‘back-end’ to process and perform actions.
For instance there is the LAMP stack, in which you have the programming language PHP running side by side with Relational Database MySQL to store data, served by Apache running on the Linux operation system or Linux, Apache, MySQL, PHP.
Or…LAMP
And none of this is to mention things like learning how DNS or domain names work, or cyber security. All tales for another time.
I bring all of these terms up not to bombard you with jargon, but to demonstrate what a powerful, and pragmatic place to start learning some general computer technical skill is. It’s a great jumping off point to cyber security, networking, systems administration, programming or hell, even Linux.
It’s a great place to start learning.
Local
XAMPP and variants
XAMPP stands for X (where x is Windows/Linux/Mac) and Apache + MariaDB (MySQL) + PHP + Perl.
I want to mention XAMPP and its alternatives first and foremost. The reason being that I think these are the lowest barrier to entry. Basically you install a program and that program manages running all of these services for you.
As you can see, this package comes with a lot, a web server, a database, and two programming languages. It saves you the headache of having to set these up and manage them on your own and getting them to play together nicely. I’ve done this on my own PC before knowing these options existed (and some of them didn’t) and I hated myself for it.
Also note that I mentioned alternatives because alternatives are plentiful. And these alternatives. WAMP, MAMP, Laragon, yada yada…the list goes on. These simulate the exact kind of environments similar to the one this blog runs on. I’ll make a post on how to set that and other PHP software up soon too.
Bare Metal
Or in other words, installing directly on your hardware, like your PC or laptop (and there are even servers for your smart phone which are more practical in their own way and less in the spirit of this paragraph here). I mentioned this in the XAMPP section and it’s just not the way to go. Out of everything I outline in the doc this is probably the thing I recommend the least.
For one getting everything to work together takes some time. And it will probably take some time and research if you can’t figure out why any one service in your ‘stack’ isn’t working. Or why it may not be playing nice with any other piece.
And it just doesn’t make sense from a server standpoint or from a “this is my computer and I don’t want to break it” standpoint. It just makes more sense to keep these worlds separated. I feel like software also just inevitably corrupts your OS, particularly on Windows. I always say on my next install I’m going to install nothing that isn’t necessary and do all my work through VM’s and Docker containers built for their purposes. What’s nice is when you’re done you can just turn them off. And you can allocate as much resources to them as you want like memory and processing power. And that does lead me to the next point
Virtual Machines
This is a step up from the XAMPP options. If you’re not aware of virtualization, well you’re missing out. Virtual machines or VMs are one of the coolest innovations of the past few decades.
These are software packages that allow you to run virtualized operating machines on your computer. These might sound like simulations or emulations, but they work directly with your hardware and have such little overhead that they run almost as fast as directly booting the operating system. Of course little isn’t no overhead, but what you’ll find is they’re going to perform well.
Like I also said in the previous paragraph, you can allocate how much processing and memory resources these VM’s have. What network adapters and hardware they have access to etc…
These probably sound like they take a lot of configuration but they’re not too bad to get started with. For starters there’s tons of operating system ISO files out there that you can download and use to install an operating system to get started.
Then again there usually is one barrier, which is you’ll have to restart your computer and enable virtualization in the BIOS.
And you have sites like Turnkey Linux that have ISOs that are ready to go for a million things you may need, including, of course, all of the most popular web servers and stacks.
These are a little more advanced than something like XAMPP. But this is often my go-to when I need a web server, depending on exactly what I need.
The main go to-software for this are Virtual Box, VMWare and Windows even has their own built-in solution called Hyper-V. I’ve used all of them to varying degrees and often when one fails me in some way, another is there to pick up the slack.
Docker
Docker is similar to virtualization. But that is, of course, selling it short.
Docker is only similar in concept but is vastly different in actual technological execution. Docker is built with ‘containers’.
A container is essentially a self contained Linux operating system (though this isn’t strictly true, but it helps to conceptualize).
Generally, each container has one purpose or few purposes and they can be deployed together in their own virtual network.
For instance in our LAMP stack often we’ll have an Apache container, a MySQL container and a PHP container which all communicate with each other, simulating a multi-server environment.
There are several advantages to this approach. For instance, if you found you needed more MySQL servers for performance reasons you could deploy more of them with a simple “dockerfile”
Your dockerfile has all of the instructions on how to configure your container.
And the huge advantage to this is that whatever runs on your docker container will work everywhere assuming the same docker file and data. It handles a very serious problem of keeping your configuration lined up. VM’s can work this way too, but when you want to transfer a VM it’s usually quite large, where with Docker you need only share a dockerfile and download the components to their destination.
This technology is equally as remote as it is local, but Docker definitely gives you a portable way to not just run, but also to share, a webserver.
The worst thing I can say about it is that it can be quite the resource-hog.
As far as local deployment is concerned it’s nice, but it’s definitely a bit advanced, and Docker has a bit of a learning curve. But if you’re feeling adventurous I recommend learning how to deploy your own web server. It may surprise you in its ease.
Honorable Mentions
Here I just want to mention literal development servers. These are things like the live server extension in VS Code. Or PHP framework Laravel‘s ‘artisan serve’. Or PHP’s built in web server.
These are even easier than a lot of the solutions I’ve mentioned, but the catch is they don’t have the full fledged features of most web servers. But they’re certainly handy to use for development purposes.
Remote
Remote is where you’ll want to be when you’re actually allowing access to your deployed website. Now there’s no rules that you can’t use a local server for this. But configuration of that is beyond the scope of this particular article, though if there’s interest I can always walk through that process.
A lot of this ‘remote’ web serving is what’s usually known as web hosting.
Web Hosting
There are countless of these web hosts. There are in fact too many to name. Just search web hosting and see what I mean. Hell, me and my friends provide web hosting (shameless plug).
These come in various features and flavors using various technologies, so it’s usually important to know what you want going in.
There are different options depending on how much bandwidth, disk space and other bells and whistles you may want to use.
They usually offer an FTP or SSH so you can access your files. And usually a control panel so you can access some of the more esoteric features of your web server.
These come in both “dedicated” and “shared” webhosting. Meaning is your server all yours or do you share it with some other jerks.
Now the thing is, your only barrier to having your own dedicated server as cheap or cheaper than shared webhosting is your knowledge, and here’s why:
Cloud Services
Cloud services are a great alternative to traditional webhosts. They not only provide web server hosting through various means, but also far more advanced services. They’re generally pay as you go and you tend to only pay for what you use. This can add up fast in the wrong circumstance, but if you’re just using these services as a hobbyist, there isn’t a huge risk of that.
Examples of these cloud services include Amazon Web Services, Google Cloud and Microsoft Azure.
AWS is actually completely free to start provided you don’t use up the initial resources they give you. Mine lasted months before that happened, and when I worked with it was free up to a year. Not sure what it is now though, but definitely worth checking out.
Wrapping It Up
This is a pretty surface level of what’s out there. But I wanted to write this article because installing a web server is a great first step to all kinds of tech knowledge and there are just so many things that can be done with it. Some of those articles soon to come.
No Responses