Setup Unmanaged VPS

GETTING STARTED


In the previous chapter, you have learnt about Virtual Private Server, dedicated server and Shared hosting. It's about time to start talking about selecting VPS hosting provider and setup your un-managed Virtual Private Server. Again, if you are going for managed VPS hosting service, most of the server software will be installed by the service provider.


Here, You will select and signup with VPS hosting provide of your choice, deploy Linux distribution, and perform some basic system administration tasks, host the website, perform backup and monitor and troubleshoot. The tasks will be as such listed below -
  1. Sign up with VPS hosting provider and setup account
    1.1 Deploying a Linux Distribution (OS installation)
    1.2 Connecting to VPS Server (Remote)
    1.3 Setting Hostname
    1.4 Setting up Time Zone
    1.5 Installing software updates
  2. Securing your Server
    2.1 Add a user
    2.2 Disable Root Login
    2.3 Creating a Firewall
    2.4 Installing and configuring Fail2Ban
  3. Hosting a Website
    3.1 Web Server (installation Apache, optimizing and virtual hosting)
    3.1.1 Optimizing Apache
    3.1.2 Configuring Name-based Virtual Hosts
    3.2 Database (installation, optimizing, creating database and importing db)
    3.2.1 Installing MySQL
    3.2.2 Optimizing MySQL
    3.2.3 Creating a Database
    3.2.4 Importing a Database
    3.3 PHP (Installation and optimization)
    3.3.1 Installing PHP
    3.3.2 Optimizing PHP
    3.4 Uploading Files
    3.5 Testing
    3.6 Adding DNS Records
    3.7 Setting Reverse DNS
  4. Backup Your Server
  5. Monitoring and Maintaining Your Server
    5.1 Performance Monitoring
    5.2 Managing Logs
    5.3 Updating software
  6. Troubleshooting

1. Sign up with VPS hosting provider and setup account:
What you need here is a VPS Hosting company. Top of the mind - I can say Linode or licehost but there are many other out there. I would recommend do some research and signup with them. Once you have signed up the service, follow their guide to do the initial setup.

1.1 Deploying a Linux Distribution
As this is unmanaged VPS hosting service, you are required to deploy your own version of Linux. It can be any of following - CentOS, Ubuntu, Fedora etc and that again depends on the hosting service provider. Once you have decided what OS you are going to install, Select the Linux distribution,  type the size of the disk image and Swap disk, and then apply. Deployment of OS will vary from one hosting provider to another based on the design of their interface but bare minimum you will have to perform these steps.

1.2 Connecting to VPS Server
Once the deployment of OS is complete, you will need to find out the IP address. Once you know the IP address of your VPS server, you can connect to it using SSH (i.e Secure Shell). If you are using Linux computer, use Terminal; and use PuTTY in WIndows

1.3 Setting Hostname
After you are able to connect to your newly set VPS server from your remote computer, first thing you need to do is to set up the hostname.

1.4 Setting up Time Zone
After hostname is setup for your Linux VPS Server, set the appropriate time zone.

1.5 Installing software updates
Now that hostname and time zone is setup, it is highly advised to update the Operating system. Restart the server after all the updates are installed. You are now ready to install your custom software.

2. Securing your Server
After deploying Linux OS and some system administration task, now time has come to secure the VPS server and protect it from unauthorized access.

2.1 Add a user

User "root" is the most powerful user in any Linux OS. Having said powerful means - it can be exploited as it can execute any command and can break the server accidently too. Considering that - create a new user and use that user to perform administrative task inconjunction with Sudo command.

2.2 Disable "Root Login" via SSH
User "root" is very powerful and widely known user in any Linux OS. Having said that it is highly advised to disable the user "root" to provent anybody login to your system as root.

2.3 Creating a Firewall
Linux system comes with IPTABLE based firewall. If you already know IPTABLE, you can set your firewall or you can get firewall scripts from Internet site. There are many free scripts available online. You will be required to modify few things in the scripts such as IP address etc..

2.4 Installing and configuring Fail2Ban
Attacks are common now a days so Fail2Ban is advised for prevention from dictionary attack. It creates temp firewall rules and block traffic from attempted IP address.

3. Hosting a Website
As you have successfully installed and secured your Linux Server, now is the time to prepare the server for hosting website. We need to install Apache, mySQL and PHP. This is part of LAMP stack. LAMP stands for Linux, Apache, MySQL and PHP. Then you will have to create a database or upload the existing database / files and add DNS records.

3.1 Web Server (Installation apache, optimizing and virtual hosting)
Webserver is required to host any website. Apache is the most popular web server.

3.1.1 Optimizing Apache
If you don't optimze the Apache and leave it running with its default setting, your server could run out of memory pretty quick.
a]. sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.backup.conf : Take backup of the configuration file just incase something goes bad
b]. sudo nano /etc/apache2/apache2.conf : Open the Apache config file for editing
c]. Make the following changes and then save the file by Pressing Control+x and Y

StartServers 1
MinSpareServers 3
MaxSpareServers 6
MaxClients 24
MaxRequestsPerChild 3000
d]. sudo service apache2 restart : Restart Apache to get the new setting

3.1.2 Configuring Name-based Virtual Hosts
At this point, your web server should be ready to serve the web pages. But it is better to use Virtual host
configuration. Configure your name-based Virtual Hosts here.

3.2 Database (installation of MySQL, optimizing, creating database and importing db)

3.2.1 Installing MySQL
Install the MySql which is your database server. M

3.2.3 Creating a Database
After you have installed the MySQL server, you need to create a database for your website

3.2.4 Importing a Database
If you are migrating your website from some other hosting server, you should import your database.

3.3 PHP (Installation and optimization)
3.3.1 Installing PHP
a]. sudo apt-get install php5 php-pear : Install the base PHP package
b]. sudo apt-get install php5-mysql : Add MySQL support
c]. sudo apt-get install php5-suhosin : Secure PHP with Suhosin

3.3.2 Optimizing PHP
After you install PHP, you'll need to enable logging and tune PHP for better performance.

3.4 Uploading Files
Now, you are ready to upload files.

3.5 Testing
It is always better to be sure than sorry. Test your website before you add the DNS record - Type the address of your VPS server in the address bar of your browser.

3.6 Adding DNS Records
After the test is successful, point your site to the IP of your VPS Server.

3.7 Setting Reverse DNS
Setting reverse DNS is also very important as it maps the name of your website to the IP address.

4. Backup Your Server
After everything is setup, it's time now to setup back for any unforeseen issue.

5. Monitoring and Maintaining Your Server
Bingo! Now I guess your site is up and running. But it doesn't stop here. Now the real work starts.

5.1 Performance Monitoring: Monitor the performance of the server periodically.

5.2 Managing Logs: It is good to check logs periodically.

5.3 Updating software: Always check the Server software for update them as and when available.

6. Troubleshooting
Troubleshoot as and when you have problem.

No comments:

Post a Comment

Commonly Used Abbreviations Used Daily

Although, we tend to use short form of long words in daily life but there are many abbreviations which we don't remember. Below is the l...