On my way to start Zend Framework development, I found that I have to create the virtual host in my windows vista machine. I Googled for this thing and finally got my virtual host ‘zf.local’ working with it document root set to ‘D:/htdocs/zf/public’ Directory (Usually, I create my document host D:/htdocs).
The steps needed to accomplish this task are listed below:
As I decided to have my virtual host name as ‘zf.local’, It was neccessary that I put an entry of the same domain the hosts file, otherwise my browser might have requested my ISP’s DNS server to locate ‘zf.local’. So what I did is I opened my hosts file which is located at ‘C:\windows\system32\drivers\etc\’ folder. I double clicked on that file, I added the line
127.0.0.1 zf.local
I pressed Ctrl+s to save. But to my surprise, notepad gave an error that the file is opened in read-only mode; so changes cannot be saved. What now??
Then the funda of vista permissions came to my mind and then I opened the notepad as administrator (see pic)
So, I opened the notepad as administrator and then browsed to my hosts file which was located at “c:\windows\system32\drivers\etc\” folder. When the file got loaded in the notepad, I added one entry for new hostname as
127.0.0.1 zf.local
Saved and quit the notepad. Till this time, I am ready with “http://zf.local” showing my localhost listing in apache. Next, its time to add the different document root for this server name. For this, I had to edit two files
- c:\amp\apache\conf\httpd.conf : in this file, the inclusion of vhosts file is commented by default. So I uncommented that line to become “Include conf/extra/httpd-vhosts.conf”
- c:\amp\apache\conf\extra\httpd-vhosts.conf : this is the actual file where we will add the virtual hosts entries. I opened the file and put the following para in it
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot “d:/htdocs”
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName zf.local
ServerAdmin webmaster@dummy-host.localhost
DocumentRoot “d:/htdocs/zf/public”
</VirtualHost>
Saved the file and restarted my apache server. And that’s it, I am done. When I browse “http://localhost”, I am getting the listing of localhost and when I am browsing “http://zf.local”, I am getting the spash screen of Zend Framework which means I am once again successful.
Remember that the first virtual host entry is quite important coz without it, “http://zf.local” will show you the zend framework splash screen only and you will never get the “http://localhost” listing.
Thanks to google
Keep PHPing
