Tuesday, March 3, 2009

Codechef- Online Programming Competition

CodeChef.com is India’s first, non-commercial, multi-platform online programming competition. CodeChef features monthly contests, practice problems and discussion boards, all geared towards helping students and professionals improve their software development skills. The judging system accepts solutions in over 35 different programming languages (like Haskell, Ruby, Python, PHP, Perl, C, C++, C#, Java, Pascal… ) allowing users to test their skills against their peers as well as experiment with new technologies.

About CodeChef

CodeChef was created by Directi as a way to continuously challenge and engage the developer community. The site’s goals are to provide a platform for practice, competition and improvement, as well as enable developers to benchmark their skills against their peers. The first online contest begins March 1st through March 15th, and prizes include an Asus Eee PC, a Nokia 5800 and an iPod Touch.

So visit codechef.com and solve problems.

Best of luck.
:Devendra

Monday, January 19, 2009

Create name based virtual host in apache unix/wamp/xampp

To create name based virtual host in unix/wamp/xampp follow the following steps

1) Open httpd.conf (The configuration file of your apache)

2) Add following at the end of the httpd.conf file (assume 0.20 as my local IP address)
NameVirtualHost *

<virtualhost>
ServerName 192.168.0.20
DocumentRoot /www/ or c:/wamp/www
</virtualhost>

<virtualhost>
ServerName newsite.com
DocumentRoot /www/new_site or c:/wamp/www/new_site
</virtualhost>
3)Add following line in host file (See bellow to find host file) or point newsite.com to your IP by DNS server.
192.168.0.20 newsite.com

4) Restart apache/DNS and you are done .....


I spend all my day doing this. It is not so hard but I spend all my day. :( To know why continue reading..

The situation is like I have wamp server running and I am running my project like 192.168.0.20/myprojectname or localhost/myprojectname

This is my development area where I develop web apps and test it. After this the final code is uploaded to the live server.

Normally project contains .htaccess file and RewriteRule

So I face problem like, I have to change the rewrite base each time I upload the .htaccess to the live server.

like from RewriteBase /myprojectname

to RewriteBase /

I can do php codeing that will load setting depend on the server by checking the hostname or serverip but you can not do that in .htaccess

Thats why I made a descision to make a virtual host. Now my RewriteBase will be / for both live server and my development area.

So i made a virtual host. like bellow
<virtualhost>
ServerName newsite.com
DocumentRoot /www/new_site
</virtualhost>
you need to point this newsite.com to your ip. You can do it in DNS if you have or you can add this in host file

for unix it is in the /etc/hosts
for win 2k and xp it is in c:\WINNT\system32\drivers\etc (for win2k), or c:\WINDOWS\system32\drivers\etc (for winxp)
add following line in host file
192.168.0.20 newsite.com

Note: If you you are not using DNS and want your site to be accessible from other system add above entry in host file of all other systems. Then those systems can open newsite.com directly.

this worked for me .... :)

but my other applications like phpmyadmin and joomla are in documentroot of apache.

I was unable to access those ...

All request were going to the virtual host ..

<span style="font-weight: bold;">So the solution for this is when u r adding virtual host to an existing apache(default setting) you have to create virtual host for the default system.</span>

So if you want to add virtual (The very first virtual host to the apache). You have to create two virtual hosts. One will point to your default apache and the another that will point to your new_site

So you have to add two virtual hosts as bellow
<virtualhost>
ServerName 192.168.0.20
DocumentRoot /www
</virtualhost>

<virtualhost>
ServerName newsite.com
DocumentRoot /www/new_site
</virtualhost>
So this will work cool .... ;)

Do not forget to crate the first virtual host that will point to default doc root(if you are using it ....)

read this http://httpd.apache.org/docs/1.3/vhosts/name-based.html for more information

Feel free to ask me if you have any questions

mail me on devendra( dot )in( at )gmail( dot )com


Thanks
:Devendra Jadhav