Hosting websites in GNU / Linux. Primer

Want to host your own website on your hosting? Is there a spare computer, even a very old one, that you can use? This article will show you how to host a website on Linux operating system using Nginx web server!

Now, three points we’re going to give:

  • This article will go almost entirely from the command line. We personally find it much easier and less time consuming to do it in the terminal, plus it’s a good practice for anyone looking to work with remote servers in the future when website creation in Rostov and placing it off the site.
  • This tutorial will not secure, install SSL certificates, use advanced HTML / CSS / Javascript, nor additional DNS work. Here we are just going to show you how to put a website on a server so you can start developing it further!
  • This guide serves as a test. If there is a good reception, we will cover more advanced topics related to server operation, web hosting, email server, etc. If you, as a reader, are interested in a higher level than the “home user”, read our articles on servers and their settings!

For this we will use an Nginx based web server. There are several web servers available at the moment, but the two most common are Apache and Nginx. Our production servers use Nginx, and while that shouldn’t concern you why, we refer to them as the “Best Performance Server”.

This article assumes that you are running Debian, Ubuntu, or one of their derivatives; as they are the most common Linux based systems and the Debian operating system is one of the most popular server operating systems due to its stability.

Website hosting: process

Note: The first thing we need to do is make sure that our system has the latest updates:

sudo apt update
sudo apt upgrade

If you have any updates, agree to them and continue on.

Next, we will install the Nginx web server:

sudo apt install nginx

Installing Nginx takes only a few minutes, it is very little. Once this is done, you must ensure that Nginx is working:

sudo systemctl status nginx

or if not using Systemd:

sudo service nginx status

You should get some text telling you something like this:

  • nginx start / running, process 5142 <- If you are using sysinit
  • and for systemd: Active: active (running) since XXX XXXXX XXXX (Today’s date and time)

Testing Nginx

A good way to test Nginx and confirm that it works is to visit the test page! (That’s right, from the moment you installed Nginx, you are showing a test page on the internet!)

First, we need to figure out what our IP address is. If you are connected to the Internet via Ethernet, you can try this command:

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's//.*$//'

Or, you can use a command called curl used to pass URL data, it can be used to check the https://andreyex.com website:

curl -4 https://andreyex.ru/

Now that we have an IP address, enter it into a web browser using a device other than the machine you are running Nginx on:

http://11.111.11.11 (ваш IP - адрес)

You should see the default nginx welcome page!

Directories and additional customization tips

The last part of this very simple tutorial is to know the important Nginx directories.

  • / var / www / html or / var / www / <- - Where your site is stored. If you like, you can replace “index.html” with your own file index / your home page!
  • / etc / nginx <- The main Nginx configuration directory, where all important files that you may one day edit and save, such as nginx.conf
  • / etc / nginx / sites-available
  • / etc / nginx / sites-enabled <- files from "Sites Availble" links to sites in Nginx should be given here and they will serve the page on the Internet.

These are the main directories hosted in Nginx.

Domain names and final thoughts

With Nginx installed and working fine, you’ll need a domain name!

You can register a domain name for use on your website! You will need to understand the basic way to specify the domain name for your use using DNS.

Once that’s done, people can go to http://yournamehere.ru (replace with your domain name) and visit your site.

Sidebar