How to set up a web server on the cloud for less than SGD$10

Due to COVID, the world is in economic malady.

While a slew of measures are being used to save jobs, it is likely that many people will be made unemployed.

Having been made redundant before, I have known the sense and loss of financial security, esteem, helplessness and guilt when one loses his or her job, especially if they had remained in the same company or position for some time.

Given the grim economic outlook for the next few years, some will consider starting up their own businesses to tide over this period. If so, one of primary concerns will be to have an online presence, often accompanied with a domain name and email addresses.

Having learnt web and server administration, I would like to share my personal interest openly to benefit those who may need to kickstart their online presence at minimal cost. As time permits, I will write about how to set up a mail server, make servers more secure from unauthorised access and share how free web templates can be used to create responsive and interactive websites.

If you find the article useful, please give a like and forward it with those whom you think will find it useful too.

Thank you and stay safe. We will get through this together.

Alwin

How to Set Up a Web Server for Less than SGD$10

I will be using namecheap.com, cloudflare.com and cloud.google.com as these 3 companies provide the necessary services which are either free or at low cost to set up the server. If you want to look for alternatives, you can google "domain name registrars", "content delivery networks" and "cloud providers".

Step 1: Create your account on namecheap.com or any domain name registrars (DNRs)

Most DNRs have ongoing promotions, so you should be able to find a domain name that you like. This is the only cost that I have incurred for the setup of my previous servers. Sometimes you can even get a domain name for free.

After you register your domain name (eg. mydomain.com), search for and change the domain's nameservers to ara.ns.cloudflare.com* and pablo.ns.cloudflare.com*.

* If you see different nameservers in step 3, use those stated in the cloudflare account instead

Step 2: Create your Google Cloud Platform Account to create your web server

Sign up for the free trial - Google will give you $300 free credits that should last you for a year if you only use the Compute Engine for the web server. You can either use your personal gmail account or create a new one. You will need a credit card but there won't be any charge (if I recall, it will be at most $1 to verify your card).

After your GCP account has been created, create a new project. After the new project has been created, click on the navigation menu (3 bars) to create a new VM instance using Compute Engine -> VM instances -> Create.

Under Machine type, create a f1-micro, g1-small or n1-standard Machine type with either a Ubuntu or Debian Boot disk image. Enable web traffic to reach your future website by checking "Allow HTTP traffic", "Allow HTTPS traffic" under Firewall and assign the server with a static external IP address (under Networking, click the pencil on Network interfaces and change the "External IP" from "Ephemeral" to "Create IP address"). Choose "Standard" Network Service Tier" and click "Reserve". Click on "Create" at the bottom of the page to create your server.

After a VM has been created, note down the External IP address and go into your machine by clicking on the "SSH". When you see the cursor ready, type in the following (without the quote-marks):

  • "sudo apt update" to update the machine's list of software packages;
  • "sudo apt upgrade" to install the latest software packages; and
  • "sudo apt install apache2” to install the Apache web server package

Type "exit" to close the window.

Step 3: Create a Cloudflare account to add domain information that will link your domain name and web server

Add your site by clicking on "Add a Site", filling in your domain name and "Add site". Select the "Free" plan and click "Confirm Plan".

Add an A record with the external IP address that you obtained from Step 2. You can optionally add a CNAME record with “www” so that people can reach your site when they type www.mydomain.com.

If the nameservers were not correctly entered in Step 1, cloudflare will ask you to replace them with their own. If so, log into your namecheap account and change them. When you've done so, click on "Done, check nameservers". Do note that it may take a while for the servers to activate.

To enable https (secure browsing) on your web server, click on "SSL/TLS" and change the encryption mode to "Flexible". Click on "Edge Certificates" and switch "Always Use HTTPS" to "On".

Step 4: Visit your new domain website (mydomain.com)

Using your favourite browser, you should see Apache2’s default page if everything goes well. If SSL/TLS was activated, you will notice that the browser will show https instead of http.

Step 5: Generate ssh keys and add them to the VM

To access your web server, you will need have a SSH key pair (private and public). My recommendation is to use PuTTYgen to generate this key pair and upload the public key into your server. To generate your key pair, you will need to download PuTTYgen (For more details, go to https://www.ssh.com/ssh/putty/windows/puttygen).

Once you have obtained the key pair, log into your Google Console and go to your server instance (Navigation -> Compute Engine -> VM instances). Click on the server name and click on the pencil to 'Edit' the server.

Scroll down to "SSH Keys" and click on "Show and edit". Copy and paste the public key generated in PuTTYgen into the box. Click on the "Save" to enable the SSH key pair for use on the server.

Once the SSH public key is enabled on your server, you can download any file client that can use SSH keys. My favourite client is WinSCP and you can find the instructions of how to use the keys on https://winscp.net/forum/viewtopic.php?t=11709.

When you're done, you can continue to set up your mail server here.

Disclaimer: Please note that this server set-up has minimal cybersecurity measures (i.e. SSH log-in, only ports 22, 80 and 443 are open) against hacking. As such, please get professional advice if you wish to have enhanced cyber measures. All information provided here on an “as is” and “as available” basis and you agree that you use such information entirely at your own risk.

PS: If you have any suggestions to improve on this article, please drop me a comment. Appreciate your kindness and patience as this is also my first Linkedin article :)

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics