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/ https://ftp.openvz.org/openvz.repo
rpm –import https://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.
i /etc/sysctl.conf
# 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.
vi /etc/sysconfig/selinux
“SELINUX=disabled”
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:
cd /vz/template/cache/
Lets download centos 6 template
wget https://download.openvz.org/template/precreated/centos-6-x86_64-minimal.tar.gz
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 33.54.2.2 –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 8.8.8.8 –save
vzctl set 123 –nameserver 8.8.4.4—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.
cd /root
wget -N https://httpsupdate.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.
Http://youripadress:2086 , https://yourip/whm , https://yourip/whm
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)
- Linux or Windows Dedicated Server? Which one is better? - August 29, 2024
- How a Bad Hosting Service Could Ruin Your Business - August 21, 2024
- Are Bandwidth Offers Confusing? - April 19, 2024