Virtual Host

What is virtual host?

According to Wikipedia: Virtual hosting is a method for hosting multiple domain names on a computer using a single IP address. This allows one machine to share its resources, such as memory and processor cycles, to use its resources more efficiently.

Setup for Windows Platform

At first let me tell you my setup, I have windows in my C: drive and I have installed XAMPP in my D: drive. For windows platform (with XAMPP) you need to do 3 things. Thing 1: go to your XAMPP installation drive then in my case it is D:, and open the httpd-xampp.conf file. In my case it is located here D:\xampp\apache\conf\extra. Thing 2: Add these lines of code in the httpd-xampp.conf

<VirtualHost *:80>
	DocumentRoot "D:/xampp/htdocs/project/path"
	ServerName yourhostname.local

NOTE: One thing to note here is, the default host (localhost) must be the last host defined in this file, Otherwise worlds will be at WAR!!!. So your final look of the httpd-vhosts.conf file should be something similar to this

NameVirtualHost *:80

<VirtualHost *:80>
	DocumentRoot "D:/xampp/htdocs/project/path"
	ServerName yourhostname.local

<VirtualHost *:80>
	DocumentRoot "D:/xampp/htdocs"
	ServerName localhost

NOTE: If you have installed xampp in your windows root directory then you might be unable to save the edited file. In that case open the notepad in admin mood (Run as administrator) by right clicking on its icon. Then open the file from within notepad by selecting File > Open... Thing 3: You need to register your custom domain (in my case it is yourhostname.local) in the window’s host file. As I have my windows in C: drive so my host file locates here C:\Windows\System32\drivers\etc. Now read again what I said in my last NOTE point and then open the host file using notepad by following that instruction. In that host file, add this line, DON’T delete any existing lines in that file (yeah that’s common sense!).        yourhostname.local

and Save the file. and One More Thing: OK I admit it is now becoming 4 things, so Just restart your apache server very quickly by selecting XAMPP control panel. If it fails to restart for some unknown reason just restart your PC.

Setup for Linux Platform

For Linux, it is quite straight forward. Step 1: Add a sites entry in this directory /etc/apache2/sites-available. If you don’t know how just copy the default as yourhostname.local

$ sudo cp default yourhostname.local

Step 2: Open your newly created site file (In this case it is yourhostname.local) with any linux editor, I’ll use VIM.

$ sudo vi yourhostname.local

Then add the following lines of code then save and close.

<VirtualHost *:80>
    ServerName yourhostname.local
    DocumentRoot /home/username/yourproject/path
   <Directory /var/username/yourproject/path>
       DirectoryIndex index.php
       AllowOverride All
       Order allow,deny
       allow from all

Step 3: Register the host in the /etc/host file

$ sudo vi /etc/host

Step 4: Enable the new host with this command

$sudo a2ensite yourhostname.local

Step 5: Restart apache server. Command for this is

$ sudo /etc/init.d/apache2 restart


$ sudo service apache reload

That’s it for now. Thanks.

enabling shadow effect in ubuntu (inside virtualbox)

Ubuntu has impressive graphical effects. But while running inside virutalbox i was little upset that ubuntu can’t detect any graphics hardware inside virtualbox. I was just thinking how can i enable those nice effects in ubuntu while running inside virtualbox. I was searching in google and i endup with a solution, here i am sharing it.

step1: after logging in ubuntu press alt+f2 (it will open a run application popup)

step2: type gconf-editor in there (it will open configuration editor).

step3: in configuration editor find app->metacity->general->compositing_manager (mark compositing manager checked and it will enable the shadow effect)

enjoy 😉

Installing VirtualBox Guest Additions in Ubuntu

Step 1: After starting the ubuntu in VirtualBox Select Device->Install Guest Additions… from VirtualBox menu.

Step 2: Now in ubuntu open terminal and type the following bash command to install the VirtualBox guest addition

cd /media/cdrom
sudo bash ./

Then it will ask for the password, type your password and just after that you will have VirtualBox guest addition installed in your ubuntu. If you have older version of Ubuntu then it might require to upgrade your Linux kernel.

Here is the file name of my VirtualBox guest addition.

Basic Shell Commands

To speak about the truth, I actually don’t dislike Linux, but i don’t feel comfortable on it. But i am feeling it is going to be important day by day specially in developer society (I don’t know, home user will ever choose Linux for their every day computing). I am learning some shell commands (they are not many but TOO many!!) here i listed some basic commands (just for me):

cd—Changes directories
chmod—Changes file access permissions
cp—Copies files
du—Prints disk usage
find—Finds files by searching
grep—Searches for a string in input
less—Filter for paging through output
ln—Creates links between files
locate—Finds files from an index
ls—Lists files in the current directory
make—Compiles and installs programs
man—The manual page reader
mkdir—Makes directories
mv—Moves files
ps—Lists processes
rm—Deletes files and directories
ssh—Connects to other machines
tail—Prints the last lines of a file
top—Prints resource usage
which—Prints the location of a command