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):
ssh [email protected]_IP
through the Digital Ocean control panel itself (click on “Console Access”). The password for the root user of the server is sent to the email registered in the account.
You can reset the root password when necessary.
Creating a new web server user
Root is an administrative user who has unlimited privileges to change everything in the system.
This is why it is not recommended to use it regularly, as these privileges can destroy the environment by accident.
After logging in as root, create a new user account that will be used from now on (change the userex to another one of your liking)
adduser userex
Choose a password and, optionally the other fields. Type “ENTER” to skip the unnecessary fields.
Web Server Root Privileges
We have a new user account created, but we need to provide administrative privileges, making it a “super user”.
To add these privileges to the user, use the following command to add them to the ” “sudo” group:
gpasswd -a userex sudo
To improve security, it is recommended to disable root login by ssh and to use public key authentication instead of passwords.
This good practice provides security against brute-force attacks (Brute force atack), which tries to guess the combination of weak user and password, through many attempts and errors.
Configuring Web Server Firewall
Firewall provides a basic level of security for your server, allowing or denying access to a previously configured port.
Ubuntu already comes with ufw, which can be used to configure your firewall policy.
We will close all ports and enable only those that have a good reason to be open.
sudo ufw default deny incoming
sudo ufw default allow outgoing
Let’s start by releasing the ssh service running on port 22:
sudo ufw allow ssh
We are using the default ports for each service. If you have changed any of the ports, you need to change the command to:
sudo ufw allow PORT/tcp
Next, release the HTTP and HTTPS ports
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
To send e-mails:
sudo ufw allow 25/tcp
Check if everything has been added
sudo ufw show added
Example of opened ports:
Added user rules (see 'ufw status' for running firewall):
ufw allow 22
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 25/tcp
If everything is ok, just enable the firewall:
sudo ufw enable
Configuring Web Server Timezone
Edit the environment variable using the following command:
sudo nano /etc/environment
Add the following lines:
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
Log out and log in again using the exit command.
Now use the following command and select the geographical area in which you are. In the case, America/Sao_Paulo.
sudo dpkg-reconfigure tzdata
Additionally, you can create a swap file so that your server can allocate less-used resources to disk in case of RAM overhead.
And you can also configure automatic security and package updates.
Installing EasyEngine v4
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
Create an account if you do not already have it, and add the desired domain in the free plan.
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:
https://wpplugins.dev
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.