Beginner's Guide to Linux Web Hosting on a Cloud Platform

Updated on October 16, 2018
Vichet Sen profile image

Vichet Sen is a backend software engineer with keen interest in researching and blogging about technology.

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

Beginner's Guide To Linux Web Hosting
Beginner's Guide To Linux Web Hosting

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
  • Rackspace
  • IBM Cloud
  • DigitalOcean
  • Linode

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

  1. Buy a domain name
  2. Set up a hosting server to handle incoming requests
  3. Create DNS Records
  4. Secure your connections and file transfer

The Typical Cost of Building a Website

Name of Service
Summary
Example
Domain Name Service
An address to access your website from the Internet
www.mywebsite.com
Web & Email Hosting
Host your website & email address
digitalocean, linode, google
Backup Service
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
upwork, freelancer
Advertising
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 "172.217.24.211".

A domain name can have subdomains as subsystems of the primary domain. In short, we can write domain names in the following format:

Subdomain.TopLevelDomain.DomainExtension

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.

Dns Dashboard
Dns 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

A record is a mapping between the domain name and IPv4 address. IPv4 is the address of the server that handles incoming requests.

CNAME record

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 record

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

MX record

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 record

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:

  1. 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
    
  2. Update CentOS and install nginx with following commands:

    sudo yum update
    sudo yum install nginx
  3. 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:

  • Download
  • Upload
  • Move
  • Rename
  • Delete

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

    Comments

      0 of 8192 characters used
      Post Comment

      No comments yet.

      working

      This website uses cookies

      As a user in the EEA, your approval is needed on a few things. To provide a better website experience, turbofuture.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

      For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://turbofuture.com/privacy-policy#gdpr

      Show Details
      Necessary
      HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
      LoginThis is necessary to sign in to the HubPages Service.
      Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
      AkismetThis is used to detect comment spam. (Privacy Policy)
      HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
      HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
      Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
      CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
      Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
      Features
      Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
      Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
      Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
      Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
      Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
      VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
      PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
      Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
      MavenThis supports the Maven widget and search functionality. (Privacy Policy)
      Marketing
      Google AdSenseThis is an ad network. (Privacy Policy)
      Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
      Index ExchangeThis is an ad network. (Privacy Policy)
      SovrnThis is an ad network. (Privacy Policy)
      Facebook AdsThis is an ad network. (Privacy Policy)
      Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
      AppNexusThis is an ad network. (Privacy Policy)
      OpenxThis is an ad network. (Privacy Policy)
      Rubicon ProjectThis is an ad network. (Privacy Policy)
      TripleLiftThis is an ad network. (Privacy Policy)
      Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
      Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
      Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
      Statistics
      Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
      ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
      Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)