Learn how to build a web server in about 10 minutes costing only $ 5 / month.
See how cheap and simple it is to build a web site hosting server with cloud computing platforms.
This is not a sponsored post. The software and services mentioned here are really excellent, recognized and used worldwide.
The purpose here is to share some of the knowledge and benefits gained over the years, after suffering with poor hosting and deciding to administer the web server myself.
How to build a web server
In this tutorial, we will use state-of-the-art open source technologies:
Linux, Nginx (pronounced Engine X), with MySQL database, and PHP-FPM processor.
This set of softwares is also known as LEMP stack in contrast to LAMP, which uses Apache instead of Nginx.
For your convenience, we will use Digital Ocean to create a web server on Linux in the cloud.
However, this tutorial on how to set up a web server can be followed for other cloud or VPS infrastructure vendors such as AWS, Linode, etc.
The choice was also strongly influenced by the most in value of the first. Although the dollar price is unfavorable, the value remains quite competitive compared to other competitors.
There are servers for (USD) $ 5/month , which can easily support 40,000 requests per day hosting a WordPress site.
Building a hosting web server in Linux
The Droplet is the Digital Ocean virtual machine, where we will install the entire web environment. Costs are counted per hour for each Droplet.
Create a Digital Ocean account through this link and earn $ 50 of credit. So you can create your web server and test the service before deciding on the cloud computing company.
Access the control panel, and click the green button at the top of the page: “Create> Droplets”.
For our step by step, we will use Linux distribution Ubuntu 22.04 LTS, selecting the image of the operating system to be installed on the virtual machine. And also the Standard plan, with machines for general use.
In this example we will choose the $ 5/month one, without backup, but that can be resized at any time to other plans and activate the backup.
The server with 1GB of RAM and 1 CPU is enough to easily withstand 20,000 visits per day with proper optimisations, cache usage and free CDN Cloudflare.
Select the Data Center where the server will be located. In the example, New York.
Add options such as IPv6 and Monitoring for your instance. The other options will be left out in this example.
Give a name for your Droplet as the domain name and click the “Create” button.
Accessing the Droplet
Use the following command in a Terminal window (Linux or Mac) using the putty (Windows):
Anyone who has ventured to configure this stack of software knows that often the procedure presents errors that the tutorials did not address, and end up spending the whole day at Google seeking solutions.
So we’ll use O EasyEngine, an open-source script to install LEMP (Linux, Nginx, Mysql and PHP) without headaches, provided by RtCamp.com, a company specialised in WordPress and high-performance Nginx servers.
In addition, the script installs these services into Docker containers, a way to isolate the environment for each site and the LEMP stack.
If you’ve never heard of Docker, do not worry, the script does it all automatically.
Use the following commands on your terminal, or putty, to install Easy Engine on your server:
wget -qO ee rt.cx/ee4 && sudo bash ee
Wait a few minutes and see how to build a web server can be very straightforward.
The following command installs a WordPress site with caching in Redis software and LetsEncrypt’s free SSL digital certificate.
ee site create exemple.com --type=wp --cache --locale=en_US --ssl=le
Follow the wizard to install a WordPress site with caching in Redis software and LetsEncrypt’s free SSL digital certificate.
Creating a web server snapshot
Let’s create a snapshot of the server already configured to use it as a base for future installations.
Click the name of the Droplet, and go to the “Snapshots” menu, and then enter the name of the image and click the “Take Snapshot” button.
After the snapshot is finished, you can restore this web server whenever you want, at this exact point that it is found, configured and cleaned up.
Using CDN and Cloudflare in your web server
To make the web server safer, we’ll use Cloudflare’s free plan, which protects against DDoS (denial of service) attacks and other threats.
It also hides your server’s IP through a proxy and provides free CDN to your site’s files, easing the load and processing of your machine
How to build a linux web server with cache and CDN
Create an account if you do not already have it, and add the desired domain in the free plan.
How to build a web server – Load charts
Updating DNS Servers in your domain Registrar
After you add the domain to Cloudflare, it will provide the names of your own DNS servers to update on the dashboard where the domain was registered.
Once these settings are configured and propagated, you will receive an email stating that the domain was correctly added in Cloudflare.
Now that the server is ready to receive the requests, it is necessary to point the DNS records of type A to the IP of the newly created server.
Go to the Cloudflare control panel, click the DNS button:
Select type A record, enter the name of your domain (example.com) in the “Name” field, the IP of your newly created linux server and click the “Add Record” button.
In case the DNS record already exists, edit the record of type A by clicking on the old IP to make it editable.
The propagation of the DNS record can take from a few minutes to hours, and can be verified through the following sites: whatsmydns.net e dnschecker.org
Accessing the web site hosted on your web server
After the DNS registration is properly configured and propagated, simply access your site through a web browser, eg:
What do you think of this tutorial on how to create a web server? Leave your comments, criticisms and suggestions below.
How to Build a Web Server – Next Steps
Wait for the next articles with new administration, security and optimization tips for your web server.