Beginner's Guide to Linux Web Hosting on a Cloud Platform
Linux is an open source operating system. There are cloud service providers that sell Linux virtual machines on their platforms. Those providers create specialized tools to manage the hosting.
After reading this Linux hosting guide, you should be able to host your website by using DigitalOcean cloud platform. The following topics are discussed:
- What is a cloud platform?
- An overview of Linux web hosting
- The basics of domain management
- Configuring a Linux server for web hosting
- Securing your server from external attacks
- Installing a nginx web server
- Setting up Letsencrypt SSL Certificate
- Setting up an FTP server for file transfer
What Is a Cloud Platform?
A cloud platform is a managed environment that focuses on providing cloud services to the public. The platform has a robust infrastructure to scale application processing on demand, location independence and reduce IT costs.
Here is a list of some cloud computing providers
- Google Cloud Platform
- Amazon AWS
- Microsoft Azure
- Alibaba Cloud
- IBM Cloud
The service providers supply the resources, both hardware and software to their customers. The cloud platform has virtualized infrastructure on top of the hardware. Server virtualization enables quick system provisioning and deployment.
Examples of cloud services include web hosting, database service, online data storage & backup solutions and more.
Unlike traditional shared/dedicated web hosting plans, cloud hosting can scale horizontally on demand. Setting up a custom app infrastructure and architecture in multiple countries is much easier on a cloud platform.
Overview of Linux Web Hosting
After developing a website, hosting is needed to make it accessible to the Internet. Web hosting is a recurring payment. When the website gets more traffic, it needs more resources (RAM, CPU and disk space) to process. With that said, a well-optimized website can serve more traffic and reduce the hosting cost.
Common Methods of Linux Web Hosting
- Buy a domain name
- Set up a hosting server to handle incoming requests
- Create DNS Records
- Secure your connections and file transfer
The Typical Cost of Building a Website
Name of Service
Domain Name Service
An address to access your website from the Internet
Web & Email Hosting
Host your website & email address
digitalocean, linode, google
Prevent data loss
come with your hosting provider
Web Design & Development
How the website looks and how it works
Look for a web development company
Digital Asset License
License for software, photos, fonts, videos, ...
Evanto, Office365, Stock photo
Hire staff / outsourcing
people to work for you
promote your website to target audiences
Facebook ads, Linkedin ads, Google Adwords
The Basics of Domain Management
A domain name represents an identity of a website on the Internet. It is bound to a public IP address of a host server. For example, a domain name "www.mywebsite.com" is bound to a public IP address "184.108.40.206".
A domain name can have subdomains as subsystems of the primary domain. In short, we can write domain names in the following format:
From the example above, we could say:
- www is a subdomain.
- mywebsite is a top level domain (TLD).
- com is a domain extension.
The Internet Corporation for Assigned Names and Numbers (ICANN) authorizes domain name registrars. The domain name is managed by creating DNS records from a registrar dashboard.
Changing DNS records can take upto 24 hours to see the updates. In most cases, the changes take less than 1 hour.
Different Types of DNS Records
DNS records have different types. A webmaster needs to create those records properly by using the registrar dashboard.
A record is a mapping between the domain name and IPv4 address. IPv4 is the address of the server that handles incoming requests.
A CNAME record is an alias of another domain rather than pointing to IP address. Usually, the "www" record is created as a CNAME of the primary domain.
Ns records are used to delegate DNS management to another host. For example, a domain name from Namecheap can be managed by digitalocean dashboard after changing NS records at Namecheap dashboard as below:
mywebsite.com 3600 IN NS ns1.digitalocean.com mywebsite.com 3600 IN NS ns2.digitalocean.com mywebsite.com 3600 IN NS ns3.digitalocean.com
Mail Exchange (MX) records are DNS records for delivering email to a domain name. MX records point to mail servers that accept incoming mail for your domain and where emails should be routed to.
TXT records are used to supplies additional information for third-party services such as Google search console. That information can be used for verification of domain ownership, SSL certification registration and so on.
Configuring a Linux Server for Web Hosting
Before setting up a Linux server, we need to secure our connections from the local machine to the remote server. We can do this by generating RSA key and add it to the cloud platform. It ensures that only the computer that has your private key file can access the remote server.
After that, we need to install a repository and some packages, create an admin account and disable root login.
I have created a beginner tutorial video about web hosting. This video shows how to configure CentOS 7 server, install nginx web server with Letsencrypt SSL certificate and set up a secure FTP server for file transfer.
How to Install a Nginx Web Server
Nginx is an open source web server written in C programming language. Some of the features include reverse proxy, caching, load balancing, virtual host support, logging, video streaming, CGI support, geolocation and much more.
There are two kinds of releases. Mainline version has the latest updates. The stable version is made for production. To install nginx stable version on CentOS 7 Linux, follow the steps below:
Create a file named "nginx.repo" in "/etc/yum.repos.d/nginx.repo" and supply the configuration as shown below:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1
Update CentOS and install nginx with following commands:
sudo yum update sudo yum install nginx
Enable nginx on startup and start it with following commands:
sudo systemctl enable nginx sudo systemctl start nginx
Now nginx is running in its default configuration.
Integrate Letsencrypt SSL Certificate with Nginx
Letsencrypt offers free SSL certificates. These certificates are needed for configuring HTTPS. By default, https runs on port 443. Https also improves website ranking, so it is good to have.
There is a tool called "certbot" ACME client, which automate certificate issuance and installation with no downtime. After we have integrated Letsencrypt, we need to configure redirection.
The tutorial video on top shows you how to use certbot and make a working https website.
Setting up a Secure FTP Server
File Transfer Protocol (FTP) is a protocol to manage remote files and folders. The common FTP commands are:
To execute these commands securely, the FTP server requires FTP clients to connect with an authorized certificate file. On CentOS 7, vsftp is a free package for FTP server. FileZilla and WinSCP are free FTP clients.
The tutorial video on top shows how to install and configure secure FTP (SFTP) correctly.
Questions & Answers
© 2018 Vichet Sen