As a response to the instruction β
How to make a simple web site in one hour, β I decided to publish my own, consisting of five simple and foreseeable five-minute steps.
Step 1. Install
the Node.js engine in accordance with the instructions available
on the wiki for each of the supported operating systems. (For Windows, just download and run the
MSI file, for CentOS, use the system package manager, and so on.)
Step 2. Create an empty directory and place in it the
β site.js β file
with the following content:
')
You can change the
staticSiteOptions settings to your liking.
Step 3. In the same directory, issue the
β npm install express β command
, which will automatically create the
β node_modules β subdirectory and install
Express there by downloading from the Internet.
Step 4. In the same directory, create a
β static β subdirectory and place the static site files in it. This subdirectory will be the site root. Files with the names
β index.html β will be used
as index files. In other words, when a server responds to a request with an address containing only the name of a certain directory (whether it is the site root or one of its subdirectories), a file with the name
β index.html β from the specified directory (if any) will be displayed.
Step 5. In the same directory, issue the
β node site β command
, which will start the server. Convinced of its efficiency, ensure that this command is automatically run in this directory after each reboot of the operating system. (For example,
on CentOS 6.2, you can
use upstart for this purpose.)
Everything.
Under habrakat, it is appropriate to mention (and mention) that simply starting the server on some computer may not be enough: this computer should also have some name known to readers of the site, and requests sent to the external port that it listens should reach the server.
But the task of how to assign a name to the computer on which the server is running, I leave at the discretion of the reader, because it has several well-known solutions.
(You can buy a VPS with a fixed
IP address, start a
web server on it
, then buy a domain, buy
DNS servers or pick up
free ones to taste, report their names to the domain trader, and then associate the
IP address with the desired name in the primary control panel
DNS server. You can run a
web server on your home computer and buy a fixed
IP address from an Internet provider. You can use a dynamic DNS, you can do without a fixed
IP address. Or it may turn out that you donβt need to have an external
IP address if
a web server is needed for Intranet ).
And the task of how to forward through the firewall the port that the server listens to, I also leave at the discretion of the reader. Its solution is usually described in the firewall instructions.