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.
- 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 $200 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)
2. Next add following two records. If the records with same Type and Name are available, just change their values.
Record – 1
Name: @ OR blank
Value / Target: YOUR-SERVER-IP_ADDRESS
Record – 2
Value / Target: YOUR-SERVER-IP_ADDRESS
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
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:
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:
Connect to server again using SSH client.
Issue following command to see whether your hostname has updated:
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:
Then fetch the CWP installation script:
Note: If the download link doesn’t work try to use following command.
After that, run the installation script:
On the successful installation of CWP, you’ll get an output as follows.
Finally, reboot your server so that all updates can take effect and CWP gets started.
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)”
In Firefox: Click on “Advance” and then “Accept the Risk and Continue”.
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.
Admin Username: root
Admin Password: YOUR_ROOT_PASSWORD
Change server hostname
1. Click on “Change Hostname” under “Server Settings“ in Left Navigation Panel.
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.
Setup your web server
1. Click on “Select WebServers” under “WebServer Settings“ in Left Navigation Panel.
2. Select the required Web Server(s). In this tutorial, I am going to select “Apache Only”.
3. Click on “Save & Rebuild Configuration” button underneath.
Increase PHP limits
1. Click on “PHP Simple Editor” under “PHP Settings“ in Left Navigation Panel.
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
Create new user account
1. Click on “New Account” under “User Accounts” in Left Navigation Panel.
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.
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.
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.
Now it’s time to host your Website on the VPS
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”
- Fill the form appropriately and click on “Create New Database”
- CWP will create a new Database and Database user; both PANEL-USERNAME_DATABASE-NAME
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
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
- Go to public_html directory to which your web-files has to be uploaded
- Delete the default index.html file inside public_html directory
- Click on “Upload” and then File Uploader will appear
- 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
- Then extract the zip.
Now I have successfully uploaded my Web Site using the Web-Based File Manager of CWP.
Install WordPress in CWP
- Go to Addons > WordPress in Left Navigation Panel.
- Choose the protocol out of http:// ; http://www. ; https:// ; https://www. from the drop-down list.
- Choose the domain you are willing to use for your WordPress Site.
- 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.
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 🙂