Ever wanted to host your own website? Have a spare PC laying around (even REALLY old) that you can use? This tutorial is going to show you how!
Now, three disclaimers I am going to give:
For this, we will be using the Nginx webserver. There are multiple webservers available, but the two most common are Apache and Nginx. My production servers all use Nginx, and without drowning you with information about why, I’ll summarize it as, “Better performance.”
This tutorial will assume you are running Debian, Ubuntu, or one of their derivatives; as they are the most common distributions, and Debian is one of the most popular server operating systems anyway due to it’s rock solid stability.
Note: The first thing we want to do is ensure that our system has the latest updates:
If you have any updates to do, agree to them and let it happen.
Next, we want to install nginx:
Nginx should only take a few moments to install, it’s very small. Once that is done, you’ll want to make sure that nginx is running:
OR if not using systemd:
You should receive some text, telling you something like:
A good way to test nginx and reconfirm that it’s running, is to visit the test page! (That’s right, from the moment nginx installed itself, you have been broadcasting a test page to the internet!)
First, we need to find out what our IP address is. If you are connected to the internet via ethernet, you can try this command:
Or, you can use a command called curl, used to transfer URL data, to check on a website called http://icanhazip.com:
Now that we have our IP address, enter it into your webbrowser using a different device than the machine you are running nginx on:
You should find the default nginx welcome page!
The last part of this very simple tutorial, is knowing the important nginx directories.
This is the absolute barebones basic of nginx hosting.
Having nginx installed and running is fine and dandy, but we need a domain name!
Freenom is an amazing little website offering year long subscriptions without the need for registration, to free domain names, such as myfreetestsite.tk or Miketurcotteisawesome.tk
Feel free to register a domain name to use for your website! You will need a basic understand of how to point your domain name to your sever using DNS. I found a handy little website specifically using freenom, showing how to do that in about 30 seconds.
Once that is done, people can then enter http://yournamehere.tk (or whatever your domain name is) and visit your website.
What are your thoughts? Ever had the desire to put something up on the internet? Would tutorials like this be of interest? Give me some feedback in the comments!
Please click on the following link to open the newsletter signup page: Ghacks Newsletter Sign up
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.
Yes, tutorials are always nice. This one is very basic, but it’s a good start. As more and more developers (and normal users) are heading towards VPS’es or dedicated servers due to their flexibility – there is and will be demand for such topics as hardening, SSL configuration (e.g. using Let’s Encrypt), DNS, http server setups, load balancing and so on. Using command line tools is very good choice as this is natural way of working in Linux based hosting solutions.
+1 from me :)
Next in the series, Nginx setup on Windows
You can copy and paste most this article already
You can copy and paste all the commands in this article too if you enable SSH on your Debian or Ubuntu server and connect to it with Putty
Write and folks will read Mike. I have an Odroid C2 I run nginx as reverse proxy for an express server with a Wit blog and a Gitea git repo inside my lan using ssl only. Never have put it on the net. I harden it enough for what I am doing with it behind my router. Production mode, helmet, and a few file configs on express for security. Fail2ban and a few configs for ssh. Part of html5-boilerplates server-configs on nginx, pieces of those are deprecated. I keep my config files, node apps, and write ups in the git repo so I can get access from a PC I may be working on to get at the files. Had the thought several times to open at least the git repo out on the net so I could get at it from somewhere besides home and just haven’t had the need as yet. Write away Mike I might learn something and I always have room for that.
Please keep publishing intermediate articles like this! I work as a junior sys admin and this type of stuff helps get me through the boring night shifts.
Huh, No kidding, just earlier this week, I was wondering how to do exactly this.
This is virgin territory to me so and looking forward learning more.
I am really hoping these Linux articles flourish.
Thanks for reading my mind!!!
if running centos this helps too if not using a web admin panel
http://centminmod.com/
Thanks for the tutorial. This is something I already know how to do, but I think it is very useful for others nevertheless.
What I think that you should cover in more detail when it comes to self hosting is the private/public IP issue, because not everyone has a public IP address, and they risk publishing their site without realizing that it won’t be visible to anyone on the internet.
“from the moment nginx installed itself, you have been broadcasting a test page to the internet!”
Please, PLEASE revise the article to remove that ridiculous “broadcasting” claim (and, in followup, delete this comment)
I for one am always looking forward to reading these tutorials here at gHacks. Started playing around with linux just a few years ago an as of a couple weeks ago, after installing the creators update, linux became my sole OS. Linux in general is so versatile wish i had done that years ago.
I definitely want to put up a website or two. It is a bit intimidating and I have to figure out if copying and pasting from an article is a practical way of using the command line or if learning it properly is a realistic option for me. I’m interested in reading about these things in any case.
Yes, I would love a series on this and others like it. Please.