Tag Archive: Linux


How to install Xen on CentOS

I have just finished installing CentOS 5 on my PC ,next i am going to test Xen Virtualization on my new CentOS 5 machine. When doing a fresh install of CentOS 5, you can specify if Xen should be installed by selecting Xen in the base Group installer. But I missed selecting Xen software and tools during my CentOS 5 installation, not a big deal i don’t have to reinstall CentOS 5 just because i missed selecting Xen packages, I can install Xen software and tools later on.

Xen is the open source Virtualization environment available for Linux kernel only that means Xen cannot run on windows platform. I have installed Xen latest release 3.1 on my CentOS 5 machine. Xen allows you to install “virtual servers” on your base operating system. Xen allows you to create and run several instances of any Linux utilizing your single server hardware resources. Here is my attempt to document step by step instructions for installing Xen on CentOS:

1. Xen installation Preparation in CentOS 5:

First check on your CentOS 5 machine if you have Xen installed:

xenserver# rpm -qa |grep xen

xen-libs-3.1.0-13.el5

xen-3.1.0-13.el5

xenserver #rpm -qa |grep kernel-xen

kernel-xen-2.6.21-2950.el5

If you have Xen and kernel-xen packages installed then you probably have Xen already installed on your RHEL5 or CentOS 5 machine. Check if you have Xen virtual machine manager installed (GUI):

xenserver-dev #rpm –qa |fgrep virt-manager

virt-manager-0.5.2-2.el5

If you don’t have Xen packages installed on your CentOS 5 machine then installed the packages.Install Xen packages in CentOS 5 using yum

xenserver# yum install xen

xenserver # yum install kernel-xen

xenserver # yum install virt-manager

kernel-xen package contains the Xen-enabled kernel for both the host and guest operating systems as well as the hypervisor. The Xen package contains the user-space tools for interacting with the hypervisor.

2. Enabling Xen on CentOS 5

Once you have all Xen and Xen kernel packages installed on your centOS 5 linux server, edit your /boot/grub/grub.conf file to add an entry for booting Xen kernel. Remember installing Xen and Xen kernel packages wouldn’t enable Xen kernel by default. To enable Xen kernel as default boot kernel, change default line in /boot/grub/grub.conf to from default=0 to default 1

Add entries for Xen kernel in /boot/grub/grub.conf file as listed below, my CentOS 5 /boot/grub/grub.conf configured to boot into Xen hypervisor

default=1

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS (2.6.20-1.2944.fc6)

root (hd0,0)

kernel /vmlinuz-2.6.20-1.2944.fc6 ro root=/dev/vg00/lvroot rhgb quiet

initrd /initrd-2.6.20-1.2944.fc6.img

title CentOS (Xen enabled)

root (hd0,0)

kernel /xen.gz-2.6.21-2950.fc8

module /vmlinuz-2.6.21-2950.fc8xen ro root=/dev/vg00/lvroot rhgb quiet

module /initrd-2.6.21-2950.fc8xen.img

Next reboot you CentOS 5 linux machine to test Xen kernel

[root@xenserver]# init 6

Once CentOS 5 machine boot completes, make sure you are running new Xen kernel and xen service is running. Once the system is booted using the Xen kernel, check to verify the kernel and that Xen is running:

[root@xenserver]# uname -r

2.6.21-2950.el5xen

To check if Xen is running use xm from command line:

[root@xensever]# xm list

Name ID Mem VCPUs State Time(s)

Domain-0 0 925 1 r—– 566.4

The above output should show that the xen kernel is loaded and that Domain-0 (the host operating system) is running. If Xen is not running this how you can start the xend daemon:

[root@xenserver]#/etc/init.d/xend start

Starting xen daemons: xenstored blktapctrl xenconsoled xend[ OK ]

If you want to run xend every time you reboot your CentOS 5 machine, make sure xend service is set to autostart for your default runlevel:

[root@xenserver]# chkconfig –list xend

xend 0:off 1:off 2:on 3:on 4:on 5:on 6:off

On my CentOS 5 machine xend is enabled to autostart for runlevel 2,3,4 and 5.

3. Running Xen GUI in CentOS 5 :

Now you can create Xen virtual machines using Xen command lines or xen GUI (virt-manager):

[xenserver@ldev ~]# virt-manager

I am going to add some documentation on how to create virtual machines on Xen in CentOS 5.

Enjoy !

How to install Xen on CentOS

I have just finished installing CentOS 5 on my PC ,next i am going to test Xen Virtualization on my new CentOS 5 machine. When doing a fresh install of CentOS 5, you can specify if Xen should be installed by selecting Xen in the base Group installer. But I missed selecting Xen software and tools during my CentOS 5 installation, not a big deal i don’t have to reinstall CentOS 5 just because i missed selecting Xen packages, I can install Xen software and tools later on.

Xen is the open source Virtualization environment available for Linux kernel only that means Xen cannot run on windows platform. I have installed Xen latest release 3.1 on my CentOS 5 machine. Xen allows you to install “virtual servers” on your base operating system. Xen allows you to create and run several instances of any Linux utilizing your single server hardware resources. Here is my attempt to document step by step instructions for installing Xen on CentOS:

1. Xen installation Preparation in CentOS 5:

First check on your CentOS 5 machine if you have Xen installed:

xenserver# rpm -qa |grep xen

xen-libs-3.1.0-13.el5

xen-3.1.0-13.el5

xenserver #rpm -qa |grep kernel-xen

kernel-xen-2.6.21-2950.el5

If you have Xen and kernel-xen packages installed then you probably have Xen already installed on your RHEL5 or CentOS 5 machine. Check if you have Xen virtual machine manager installed (GUI):

xenserver-dev #rpm –qa |fgrep virt-manager

virt-manager-0.5.2-2.el5

If you don’t have Xen packages installed on your CentOS 5 machine then installed the packages.Install Xen packages in CentOS 5 using yum

xenserver# yum install xen

xenserver # yum install kernel-xen

xenserver # yum install virt-manager

kernel-xen package contains the Xen-enabled kernel for both the host and guest operating systems as well as the hypervisor. The Xen package contains the user-space tools for interacting with the hypervisor.

2. Enabling Xen on CentOS 5

Once you have all Xen and Xen kernel packages installed on your centOS 5 linux server, edit your /boot/grub/grub.conf file to add an entry for booting Xen kernel. Remember installing Xen and Xen kernel packages wouldn’t enable Xen kernel by default. To enable Xen kernel as default boot kernel, change default line in /boot/grub/grub.conf to from default=0 to default 1

Add entries for Xen kernel in /boot/grub/grub.conf file as listed below, my CentOS 5 /boot/grub/grub.conf configured to boot into Xen hypervisor

default=1

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS (2.6.20-1.2944.fc6)

root (hd0,0)

kernel /vmlinuz-2.6.20-1.2944.fc6 ro root=/dev/vg00/lvroot rhgb quiet

initrd /initrd-2.6.20-1.2944.fc6.img

title CentOS (Xen enabled)

root (hd0,0)

kernel /xen.gz-2.6.21-2950.fc8

module /vmlinuz-2.6.21-2950.fc8xen ro root=/dev/vg00/lvroot rhgb quiet

module /initrd-2.6.21-2950.fc8xen.img

Next reboot you CentOS 5 linux machine to test Xen kernel

[root@xenserver]# init 6

Once CentOS 5 machine boot completes, make sure you are running new Xen kernel and xen service is running. Once the system is booted using the Xen kernel, check to verify the kernel and that Xen is running:

[root@xenserver]# uname -r

2.6.21-2950.el5xen

To check if Xen is running use xm from command line:

[root@xensever]# xm list

Name ID Mem VCPUs State Time(s)

Domain-0 0 925 1 r—– 566.4

The above output should show that the xen kernel is loaded and that Domain-0 (the host operating system) is running. If Xen is not running this how you can start the xend daemon:

[root@xenserver]#/etc/init.d/xend start

Starting xen daemons: xenstored blktapctrl xenconsoled xend[ OK ]

If you want to run xend every time you reboot your CentOS 5 machine, make sure xend service is set to autostart for your default runlevel:

[root@xenserver]# chkconfig –list xend

xend 0:off 1:off 2:on 3:on 4:on 5:on 6:off

On my CentOS 5 machine xend is enabled to autostart for runlevel 2,3,4 and 5.

3. Running Xen GUI in CentOS 5 :

Now you can create Xen virtual machines using Xen command lines or xen GUI (virt-manager):

[xenserver@ldev ~]# virt-manager

I am going to add some documentation on how to create virtual machines on Xen in CentOS 5.

Enjoy !

Life without SEO Tools

My blog is a big bag of bullshit. And I don’t promote it much. People who read my blog often know that very well. I write complete bullshit. Nobody cares. I know that. But my blog does manage to get visitors once in a while because of the few tech stuff that I have in here. Linux buffs like my blog. Select posts if not the whole blog.

Well, Im not the worst. I do know a lot of people who write more bullshit that I do, and keep their blog on the top of the searches. How is that done? SEO. Search Engine Optimization.

Doing it manually is a tough job. It would take a lifetime to optimize one blog manually. And I have 27 blogs, and only 1 life. How do I still stay in business? I have a huge array of seo tools installed in my computer and servers, without which I would have been just another stupid software engineer working at some stupid company making a few hundred thousand rupees a year.

Ubuntu for the servers

I have been using ubuntu for my desktops since late 2006, and have never moved back to windows. Unix, the operating system made when the hippies walked the earth is THE os, and all its derivatives are just too good. I love Linux, and bsd at times, and I just hate windows. Windows ia a big black mark on mankind. Atleast in the desktop world since most of the server world still rely on unix and its derivatives.

I did have a few windows servers, which I maintained for a few insufferable clients I had, and the rest of the clients were happy with the linux servers I had. I have been enthusiastic at managing my linux servers and I just hated working on my Windows servers.

Well, till April 2008, I thought CentOS was the best ever operating system for servers. It is simple, it is powerful, It is made from RedHat, and its free. Redhat comes with a $20 license fee per month.

CentOS is geared up for the server environment. Set it up, harden it, and you are ready to roll. And managing it through shell is never easier. But still I missed ubuntu on my server. Ubuntu has got its repositories, you could install debian packages on it, and you get to go with the cool factor. Whats your server’s OS? Its Ubuntu 8-)

In 2007, I installed ubuntu 6.06 LTS on one of the idle servers I had. And I wasn’t really convinced. CentOS was really better. It supported cPanel for gods sake, and I felt that Drapper is really Draking. I never bothered to try out Hardy Heron untill Intrepid Ibex came out. And when I tried it, I was overwhelmed. What an OS!

It does a lot of things with ease that CentOS takes a lot of time to finish. For example setting up a firewall. I could never do it right, and I got my server hacked once.

The only problem now is that cPanel/WHM doesnt support ubuntu yet. They used to support debian, but they have withdrawn that now. God knows why. Maybe they don’t want to extend into ubuntu. Well, Ubuntu is supported now by Plesk, and I just hate plesk. They store sites under the /var/www/ folder which is the default apache folder and not at /home/user like cpanel. I hate this setting. And folder permissions and tweaking other settings are not as easy as doing it with cPanel. And bloody plesk charges $40 a month for its license while cPanel charges only 25.

I really hope that cPanel would start supporting ubuntu soon.

Unless you are a web hosting company, that sells hosting for single domain accounts and reseller accounts with multiple users accessing your server, you do not need a control panel. If you run a huge number of websites or a massive resource consuming script that needs a vps or a dedicated server, I don’t really think that you should spend $25 a month on a control panel. Working from shell is a lot easier than working with control panels once you get the hang of it.

I have always loved Linux servers. They are stable and are rock steady, and are not buggy like Windows. And, all, they are not prone to viruses. Managing them is quite easy once you step out of the windows circle and get a hang of Linux.

And for the past 2 years, I have been using Ubuntu for my desktop too. I have never gone back to Windows again. When I am so desperate to run a windows application that doesn’t have a Linux equivalent, I use Wine. This has really annoyed me. How have I abandoned windows for so long? It has helped me operate my computer for several years untill 2 years ago. This has made me install windows again, and there is no single time that I have used it for more than 24 hours and rolled back to ubuntu. I would either get the Blue Screen of death, or some driver wouldn’t install properly, or something or the other would piss me off. People who are used to working in Windows will look at these as common problems and would say that wasting time on tweaking such stupid errors are included in the process of the installation of the motherfucking proprietary operating system. Well, there are two ways to look at anything, and it is hard to tell which is right and which is wrong. The terrorists say that terrorism is right, and the rest of the world says its wrong. Microsoft and its users say Windows rocks, and the rest of us say Windows Sucks.

Well, thats besides the point. I love linux servers. And so do 85% of the world’s server users. Not many like Windows servers. It can’t handle too many emails, it can’t handle too many dns requests and it can’t serve a website to too many people at the same time, or handle multiple processes. If you stress a windows server too much, it will just hang in there refusing to work any further. Therefore to reduce the load on a Windows server, you will need parallel servers. If you do too much of mailing, you will need a big bunch of mail servers to work in parallel, and the same goes for DNS as well. And for each server that you add additionally, you have to pay a license fee for the operating system, and a license fee for the virus scanner that you will have to install in each and every one of the servers on which you run Windows. Then there is the firewall. It is far easier to hack a Windows server than a Linux server. I have seen a funny picture somewhere in the past that shows a house with a really short boundary wall, no higher than your ankle, and a huge thick wrought iron gate. So thats windows for everyone. Linux doesn’t have any of these problems. People often don’t go for linux just because they do not know much about it, but it is not an operating system to be ignored just because you are too lazy to learn and step out of the satanic inversions of Windows. Unix used a forward slash while windows use a backward slash to start with.

So if you have a server application that runs on a linux based scripting language like PHP or perl or python, and if it is consuming enough resources that your shared hosting provider is asking you to move your script away, you will need a Linux virtual private server or a dedicated server.

VPSes and Dedicated servers are available in various shapes and sizes from many datacenters across the world. Pick the one that is suitable for you, and ask them to install ubuntu 8.10 LTS on it. I am an ubuntu guy, and have moved away from CentOS and RedHat recently in the server platforms too after the releast of Ubuntu 8.10 server edition. If you prefer some other distro, the steps that I am going to explain below should match your requirements too, with a slight change in the commands and paths to suit your distro here and there. I would be talking about ubuntu here.

I have tried almost all domain registrars in the world and I should say that Directi is the best of them all. Public Doamin Registry and Answerable.com. They offer free DNS for your domains or any product that you buy from them. None of the other add on package that they sell is over priced, and they don’t force packages on you while you register or renew a domain and checkout like godaddy does. Directi doesn’t advertise much, and if I didn’t know better, I would have thought that it is a charitable organization or something.

If you get domains from them and use their free dns service, setting up your domain without a control panel will be far easier.

Once you get your server, you will need to secure it first. The first step would be to change your SSH Port. The port by default is set to 22, and you can change it to anything between 2048 and 65536. Just make sure that you remember the port once you change it, because once the port is changed, there is no other way to get into the SSH of a server. If you forget the port, all your doors will be locked.

Putty is the shell client for Windows. It is available for Linux as well, but if you are using linux for your desktop, you could better be using a terminal.

To login to your server,

ssh root@yourserverip

Once you get into the server, check the repository list. You do not need to know much about repositories. If the repository list has got a lot of text and links to ubuntu.com and not to your datacenter’s domains, then it is fine. Some datacneters install operating systems from hard drive images and they keep their own repositories that are often un-updated to save bandwidth. If you think you have your datacenter’s repository, well, I shall update mine in a while.

To check your repositories,

vi /etc/apt/sources.list

Once you are finished checking, type in :q and hit enter, and you will leave vi. Do not hit any other key on the keyboard, especially I, unless u know what you are doing.

Once you are sure about your repositories,

apt-get update

This will update your repositories and you are ready now to install software from the repositories.

First you need to install nano. Though there is vi and vim, nano is easier to work with when it comes to editing files without mistakes.

To install nano from the repository,

apt-get nano

Once this is finished, you have an editor.

We were about to change the SSH port of the server. We will do that now.

To change your SSH Port

nano /etc/ssh/sshd_config

In the editor, you will see

#Port 22

Change port 22 to any number between 2048 to 65536. And remember this number for ever, unless you want to spend another $25 and have you datacenter reload the OS for you.

Once you alter the port, you need to reload ssh. You do that with

/etc/init.d/ssh reload

If you have filled in an invalid port number, something like 99999 or something, it will throw an error. And if it is under 65536, it will just say OK.

Once the port is set, write out and exit nano, and exit from your shell. Type exit on your shell and login again. The next time you login you will need to set the port as well. If you are using putty, enter the new port number in the appropriate field, and if you are using the linux terminal, use the following line.

ssh -p 2995 root@yourserverip

replace 2995 with your actual port number. If you get an error saying Invalid port or Connection refused, call your Datacenter and order a reload immediately so that we dont waste time.

If you managed to login successfully, read ahead, or if you had to reload your OS, repeat the above steps correctly untill you manage to login.

Once you login, you need to add a new user. If you do not add a new user, and if you think you can run your sites under the user root, a hacker will come along and upload a hacking script and wipe out your entire hard disk and carry all the data away. You should create a user with very limited previlleges that would be required to run a site. If you had a control panel, this is exactly what it does. It creates a new user for each and every domain, so that the files remain completely isolated from one another’s.

To add a new user

useradd -d /home/username -m username
passwd username

use passwd to set password for the new user.

If you wish to delete this user in the future just replace adduser with deluser in the above command.

Once you have added the user, install apache

To Install Apache

apt-get install apache2

then

MySql

apt-get install mysql-server

then

phpMyAdmin

apt-get install phpmyadmin

For mailing, I guess exim is the simplest of them all.

so,

Install Exim4

apt-get install exim4

You might also want to install ftp to upload files, but I would recommend that you connect with the user that you have created with the port that you set through sftp or ftp over ssh. Almost all ftp clients support sftp as well.

These are the basic installations that you will need to do on your server. After this you can install php, python and anything you like in the similar ways as above.

Next, you will have to host your websites on the server. Like everywhere else, there are two ways to do this. The easy way, and the hard way. Let me explain the easy way first.

The easy way:

You have created a username, lets say ravi, and a folder for the user under home. You can set that as your default folder for hosting sites, and you can add folders under ravi logged in as ravi from shell or sftp. Upload your files into the respective folders and buy domain redirection from answerable.com. Let’s say your server’s hostname is ubuntu.server.com, and you have uploaded a wordpress blog, you will need to redirect your domain to ubuntu.server.com/wordpress. Your domain will be masked and you will see only the domain name in the address bar and nothing else. This is the easy way. Domain redirection costs around $1 a year at answerable, and if you get it from resellerclub.com it costs $0.15. You can always explore the web to find out if youwould get domain redirection for less.

nano /etc/apache2/sites-available/default

You will see

NameVirtualHost *

ServerAdmin webmaster@localhost
DocumentRoot /var/www

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

In this, change /var/www to /home/foldername. I created a new user called ubuntu, so the foldername is ubuntu. Mind the /. No trailing / in the first change and there is one in the 2nd.

NameVirtualHost *

ServerAdmin webmaster@localhost
DocumentRoot /home/ubuntu

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

If you do not wish to waste money on domain forwarder, well, certainly I wouldn’t, you can do it the hard way. It is not exactly hard. Once you create a few domains this way, it will only be as tough as creating a hosting account on cPanel. Every site has its own file like the default file. So all you need to do is to create a new file for each site by copying default, and adding just one line ServerName yourdomain.com in it and setting the path accordingly.

so, lets say you are creating 3 sites, that is ubuntu804.dyndns.com, ubuntu810.dyndns.com, ubuntu904.dyndns.com. For these three sites, you willhave to create 3 separate files. You do this with

cd /etc/apache2/sites-available
cp default ubuntu804.dyndns.com
cp default ubuntu810.dyndns.com
cp default ubuntu904.dyndns.com

Once done with this, you will find 4 files in the sites-available directory including default.

Now edit the files one by one. Start with ubuntu804

nano ubuntu804.dyndns.com

You will see

NameVirtualHost *

ServerAdmin webmaster@localhost
DocumentRoot /var/www

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

Edit /var/www/ the path as required. Mind the trailing / in both instances. Then under ServerAdmin, add a new line with ServerName ubuntu804.dyndns.com. The changes should now look like

NameVirtualHost *

ServerAdmin webmaster@localhost
ServerName ubuntu804.dyndns.com
DocumentRoot /home/ubuntu804

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

Similarly make changes as required for the other two files as well.

Once this is done, you need to let apache know that you have created 2 more sites and make it serve them too. Luckily, unlike any other Linux distro, ubuntu has got a set of simple commands to get apache to do this for you.

All you need to do is pass the name of the file that you have created for a new domain to a2ensite

a2ensite ubuntu804.dyndns.com
a2ensite ubuntu810.dyndns.com
a2ensite ubuntu904.dyndns.com

Once done, you need to restart apache

/etc/init.d/apache2 restart

After apache is restarted successfully, if your dns is configured correctly, your sites should work from the respective folders on the server.

Databases

You have phpMyAdmin to create and manage databases on mysql. you can access that from

yourservername/phpmyadmin

Your scripts can send mails as localhost through exim. in your DNS zone, you can just add MX records of google apps which gives you free email boxes for your domain names. Creating, configuring and using pop3 and imap on a server is an entirely different thing and I guess I will have to make a post on that seperately.

If you had the patience to read till this line, do leave your queries and comments below.

Powered by WordPress. Theme: Motion by 85ideas.
SEO Powered by Platinum SEO from Techblissonline