This tutorial will guide you how to install and configure your own VPS (virtual private server) machine on a physical Linux server. As a common practice, the physical server comes up with the minimum Operating System installed on it. Try to order a server with Centos 5 or the latest version.
We assume that you have a server with Centos 6 minimal operating system on it. We will be using OpenVZ for virtualization to create virtual servers. The server machine should have at least 2 Gbs or better memory to handle the virtual machines on it. The machine with more memory and CPU can handle more virtual servers on it. Typically the server is sliced on the bases of the memory installed on it. For example a server machine with 16 GBs of RAM could be sliced upto 8 to 16 virtual boxes.
OpenVZ is free under the GNU open-source license. It is a container based virtualization system, where each container executes separately and independently of the Linux box with its own file system and control management system. OpenVZ is widely used by the VPS companies to share the memory and other resources economically .
Step 1: Adding Repository
First of all we will add the OpenVZ repository to our physical machine to install the important software’s.
wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
rpm –import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ
Step 2: Installation of OpenVZ Kernel
Install a the OpenVZ kernel to support virtual boxes using the repository.
yum install vzkernel
Step 3: Kernel Configuration
Configure kernel parameters to support virtualization by editing the sysct.conf file.
# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0
# Enables source route verification
net.ipv4.conf.all.rp_filter = 1
# Enables the magic-sysrq key
kernel.sysrq = 1
# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
We will disable Selinux to avoid any surprises.
Install necessary OpenVZ tools via yum before rebooting the machine.
yum install vzctl vzquota ploop
Reboot the machine to load OpenVZ kernel
Now you have loaded the virtualization environment, you are ready to create virtual machines.
Download the ready-made templates from the OpenVZ repository to create the virtual machines. You can download the precreated OS templates from download.openvz.org/template/precreated the path to templates:
Lets download centos 6 template
Step 4: Create Our First VPS
we will use the below command to create our first virtual machine.
vzctl create [ID number] –ostemplate [template name] –config basic
ID number : any number from 1- 100
ostemplate: Precreated Operating system
template name: The name of downloaded precreted OS template
config: give the configuration file name
OpenVZ comes up with sample configuration files to give you a kick-start found in /etc/vz/conf
You can use basic , bight or unlimited sample configuration to create your first virtual machine.
We will use basic configuration to create our first container.
vzctlcreate 123 –ostemplate centos-6-x86 –config basic
Step 5: Necessary VPS Configuration
Now we will configure the virtual server for necessary settings to make it online.
Configure the VPS
Give a name to the virtual machine.
vzctl set 123 –hostname vps1.linuxbox.com –save
Give it an IP address
vzctl set 123 –ipadd 184.108.40.206 –save
Set the VPS to become online automagically on the reboot:
vzctl set 123 –onboot yes –save
It is important to add working name server to to make it online:
vzctl set 123 –nameserver 220.127.116.11 –save
vzctl set 123 –nameserver 18.104.22.168—save
Here we go, we are almost ready to take our newly created VPS online.
Assign Root Password to the machine.
vzctl exec 123 passwd
You will be prompted to set the root password.
Start OpenVZ VPS
We will run the below command to start our VPS:
vzlist -a It will list down the number of virtual machines
vzctl start 123
Installation of Cpanel on Newly Created VPS
Since the new container has the precreated Centos OS 6. We will install cpanel on the virtual machine.
Login to the machine:
vzctl enter 123
Enter the root password to log in.
wget -N http://httpupdate.cpanel.net/latest
sh latest & it will take some time to complete. Once the cpanel is installed, you can access it using the Ip address and the port.
Voila, we are ready with our first virtual private server. You can create more vps using the same processes.
Some Helpful Commands
vzlist -a (list all virtual servers)
vzlist start/stop/restart ID ( start/stop/restart a server)
vzctl set [ID] –diskspace [soft limit]:[hard limit] (change disk space)
vzctl set [ID] –cpulimit 4 –save ( assign cpu cores)
vzctl destroy CTID ( destroy/delete the virtual machine)
Latest posts by Rounak Jain (see all)
- Massive Launch, AMD EPYC 32/64 Core, Intel Xeon SP, 36TB RAID, E3 w/12TB HDD, Titan X GPU SRV - June 25, 2018
- Optimizing Your Website with Some Holiday Cheer SEO - December 12, 2017
- Why Your Website Should Always Be A Good Host - October 30, 2017