featured image

Host your Website on a Linux VPS Server

By

This tutorial will show you the shortest and easiest method that you can follow to host your website(s) or install WordPress in your newly bought VPS / droplet. This will start from the beginning and assume that you have a domain name for your website and a VPS / droplet server ready to host that website.

Pre-requisites

  • A droplet / VPS server running in CentOS 7 (x64) Linux Distribution (minimum 1GB RAM is recommended and 4GB+ RAM would be great).
    Don’t you have a VPS server with your??
    Having a DigitalOcean droplet is same as having a VPS server. Therefore see my post on First Connection to your Droplet and redeem free $100 in credit over 60 days to test DigitalOcean platform.
  • Root access to your server is essential.
  • A domain name to access your website: If you don’t have a domain name with you, you can first try to SETUP your server and later (once you have a domain name) you can proceed with the website hosting.

Note: No extra knowledge of Apache configurations, PHP configurations, DNS configurations etc. are necessary. All hard configurations parts would be covered by an Open-Source web-hosting control panel that I am going to install.

Each and every simple configurations would be illustrated to you as simple as possible, and for that purpose, I am going to work with you step-by-step with my own VPS server (newly bought by Vultr.com) and domain (from Freenom.com).

My VPS: Centos 7 (x64) server with 1GB RAM and root access
My domain: hostmyweb.ml

(Note that, above server and domain are only for illustrating purposes and they would be destroyed once I finished writing this tutorial. Therefore you won’t able to access those resources at this moment).

Point you Domain to the VPS Server

This is the most initial step that you should perform before host website on your VPS so that anyone can access your server (website hosted in your VPS) with your domain name.
(If you don’t have a domain name with you, you can proceed with the next step and setup your server as a Web-Host)

1. Login to your domain provider account and go to the page which allows you to manage DNS for you domain.

The DNS configuring interface will look something like follows (Example from Godaddy)

How a DNS manage panel looks

2. Next add following two records. If the records with same Type and Name are available, just change their values.

Record – 1
Type: A
Name: @ OR blank
Value / Target: YOUR-SERVER-IP_ADDRESS
TTL: 3600

Record – 2
Type: A
Name: www
Value / Target: YOUR-SERVER-IP_ADDRESS
TTL: 3600

DNS records for hostmyweb.ml
DNS records for hostmyweb.ml

3. Finally, save the changes.

4. Then you have to check whether your newly added DNS record has propagated successfully. For that;

  • Visit https://www.whatsmydns.net
  • Type your domain name, select the record type as A and click on “Search”
  • If DNS records are not propagated successfully, you’ll get an output as follows (red – cross). Don’t worry, DNS would take about 2-3 hours (maximum 48 hours) to propagate and in the meantime we can consider on setting up our server.
  • If DNS records are propagated successfully, you’ll get an output as above (green -tick).

Connect to your VPS using a SSH Client

If necessary, you can follow my tutorial on “Make First Connection to your Droplet” or “Make First Connection to your VPS Server“.

Install an Open-Source Web Hosting CPanel

This step assumes that, you have connected to your server as root user using an SSH client (like PuTTY). Here I am going to install CentOS Web Panel (CWP) to manage my server to host websites in it.

Firstly setup the hostname of your server:

hostname panel.youdomain.com
Setup hostname

Note that hostname has to be a sub-domain of your main domain. If possible, it is good to change the hostname via your VPS provider’s dashboard rather than from command line.

Next install required packages to proceed forward:

yum -y install wget

Then update server packages to latest versions:

yum -y update

Reboot the server, so that all updates can take effect:

reboot

Connect to server again using SSH client.

Issue following command to see whether your hostname has updated:

hostname

See whether the hostname is similar to one that you have set earlier. If not, we’ll change that once we have installed CWP.


Now your server is ready to proceed with CWP installation. The installation may take about 30 minutes as all the required setups would be done automatically.

Change directory to /usr/local/src:

cd /usr/local/src

Then fetch the CWP installation script:

wget http://centos-webpanel.com/cwp-el7-latest

Note: If the download link doesn’t work try to use following command.
wget http://dl1.centos-webpanel.com/files/cwp-el7-latest

After that, run the installation script:

sh cwp-el7-latest

On the successful installation of CWP, you’ll get an output as follows.

CWP Installation Done

Finally, reboot your server so that all updates can take effect and CWP gets started.

reboot

Basic configurations of CentOS Web Panel

Login to CWP admin panel

Go to http://YOUR-SERVER-IP_ADDRESS:2030/


The browser will automatically redirected to HTTPs and since we haven’t still configured SSL certificated for CWP, you’ll get and error message as follows.

In Google Chrome: Click on “Advance” and then on “Proceed to YOUR-SERVER-IP_ADDRESS (unsafe)”

Google Chrome: Connection is not private

In Firefox: Click on “Advance” and then “Accept the Risk and Continue”.

Firefox: Connection is not private

Note: In older versions of Firefox, you may need to add an Exceptions and Confirm that Security Exception.


And login by providing username / password combination.

CWP admin login

Admin Username: root
Admin Password: YOUR_ROOT_PASSWORD

CWP admin dashboard

Change server hostname

1. Click on “Change Hostname” under “Server Settings“ in Left Navigation Panel.

Server Settings

2. Scroll down and see whether, your hostname is similar to the one that you have set before CWP installation. If not, type a new hostname and click on “Change Hostname” button.

CWP: New hostname

Setup your web server

1. Click on “Select WebServers” under “WebServer Settings“ in Left Navigation Panel.

Select Web Servers

2. Select the required Web Server(s). In this tutorial, I am going to select “Apache Only”.

Select Apache Only

3. Click on “Save & Rebuild Configuration” button underneath.

Save & Rebuild the Configurations

Increase PHP limits

1. Click on “PHP Simple Editor” under “PHP Settings“ in Left Navigation Panel.

PHP Simple editor

2. Change the following directives:
Note: Click on “Save” with each change of a directive.

  • upload_max_filesize = 100M
  • post_max_size = 20M
  • max_execution_time = 300
Change PHP directives

Create new user account

1. Click on “New Account” under “User Accounts” in Left Navigation Panel.

New Account

2. Then you’ll direct to Create a New Account form.

  • Domain name: Give the domain name you are willing to user for your website.
    Don’t use www. in front of your domain when creating an account as www. sub-domain will be automatically added.
  • Username: The username you’ll be using to access User Control Panel.
  • Password: Provide a strong password.
  • Admin Email: Give an appropriate admin email.
Create new account form

Finally, click on “Create” Button; Then CWP will create your new user account.

If the DNS propagation is complete, you can access your newly created hosting account using your domain name. You’ll see the default index.html added by CWP.

Work on Website Hosting

Go to “List Accounts” under “User Accounts” in Left Navigation Panel.

List Accounts

Then Click on “Settings-like” symbol (see image) to access User Control Panel.

Type the username and password that you have mentioned in account creation, and Login to the system.

CWP user login

Now it’s time to host your Website on the VPS

CWP website host control panel

You can upload your website, set up MYSQL databases and users, and create backups etc. by using CWP User Control Panel.

If you are willing to host a WordPress website, there is an Auto installer provided by CWP which will make your life easier.

Hosting a Normal Website

1. Create databases and database users.

Your website may require a MYSQL database to function properly. CWP allows you to achieve this with few clicks.

  • Select “SQL Services” in Left Navigation Panel
  • Then go to “Mysql Manager
  • Click on “Create Database and User
Add a Database
  • Fill the form appropriately and click on “Create New Database
Database create form
  • CWP will create a new Database and Database user; both PANEL-USERNAME_DATABASE-NAME
List Databases

2. Access phpMyAdmin to manage your databases.

  • Select “SQL Services” in Left Navigation Panel
  • Then go to phpMyAdmin
  • phpMyAdmin will open in a new tab and you can manage your databases from there
phpMyAdmin

3. Upload your Web-Files

CWP provides you a Web-Based File Manager which allows you to upload, edit, delete, copy, move, extract, compress and set permissions etc. If you have a large website (in size), then you can create a FTP account (File Management > FTP accounts) and upload your web site using a FTP client like FileZilla.

In order to demonstrate the File Upload using CWP, I am going to upload a simple website which is zipped and extract it.

  • Go to File Management > File Manager in Left Navigation Panel
  • File Manger will open in a new tab
CWP File Manager
  • Go to public_html directory to which your web-files has to be uploaded
  • Delete the default index.html file inside public_html directory
Delete index.php
  • Click on “Upload” and then File Uploader will appear
Upload File
File Uploader
  • I am going to select / drag-and-drop my website zip file so that CWP will upload it
  • Once status change to Upload Complete, close the File Uploader
Website zip file is uploaded successfully
  • Then extract the zip.
Zip extraction

Now I have successfully uploaded my Web Site using the Web-Based File Manager of CWP.

Install WordPress in CWP

  1. Go to Addons > WordPress in Left Navigation Panel.
  2. Choose the protocol out of http:// ; http://www. ; https:// ; https://www. from the drop-down list.
  3. Choose the domain you are willing to use for your WordPress Site.
  4. If necessary give an In Directory.

Note: The directory is relative to your domain and should not exist. e.g. To install at http://mydomain/dir/ just type dir. To install only in http://mydomain/ leave this empty. Then click on “Install”.

After successful installation, you can see the new installation is appeared under WordPress Installations in right side.

WordPress Installed

Click on the link of new WordPress installation (arrow).

Proceed with next few steps of WordPress installation like selecting the Site Language, Specifying the Site Title, Setting up WordPress administrator account and finalize your WordPress installation.

That’s it. Now you have successfully host your website on the VPS server. When you fire up your domain name on the browser, you should be taken to your website’s homepage.

Thank You 🙂

1 Comment
  1. Zoe Allen 5 months ago
    Reply

    “Host your Website on a Linux VPS Server” your article really made it easy for me to understand. Hats off. Beautifully explained the topic with infographics giving strength to your words. Just to add one thing, for the DNS Propagation, as an alternative to whatsmydns.net, for DNS lookup on 100+ public servers, you should also check https://dnschecker.org/. The addition of that tool will definitely help the users in getting more detailed propagation results.

Leave a Comment

Your email address will not be published.

You may also like

Hot News