Wednesday, January 03, 2007

Beginning Bioinformatics with MySQL, PHP, phpMyAdmin, PERL (for CGI) on IIS (Quick and Dirty Way!)

Beginning Bioinformatics with MySQL, PHP, phpMyAdmin, PERL (for CGI) on IIS (Quick and Dirty Way!) Guys I need to switch from FreeBSD to Windows for a while and thus I am trying to run MySQL with PHP on Windows IIS (Yes it is possible!).Here are the steps: 0. Make sure IIS is installed and working in your Windows machine. Otherwise follow the instruction. 1. Install MySQL and put the mysql-install-dir/bin/ in the Windows PATH Variable. Instruction available at php site . To test installation open command-prompt and type "telnet localhost 3306" [without quotes]. This should dump something like the following junk in the console: 7 5.0.14-nt#UpU;dh[n,?8i.CJ(&'1_m( Press ENTER and get rid of it, your MYSQL is working!If this fails, then you might need to start the service of mysql by tryping "net start mysql" [without quotes]. Then try telnet as earlier. Remember the password you have set up for the root login of mysql, we will need it in step3. 2. Install PHP in C:/PHP folder by downloading MSI from http://in.php.net/get/php-5.2.0-win32-installer.msi/from/www.php.net/mirror and then download http://in.php.net/get/php-5.2.0-Win32.zip/from/www.php.net/mirror and extract into the C:/php folder as well (Yes it will overwrite many files, let it do, because we need the files in EXT folder). Download and extract the dlls from http://in.php.net/get/pecl-5.2.0-Win32.zip/from/www.php.net/mirror in c:/php/ext if you plan to use those extra PHP Dll's (not needed for our job though).Make sure that C:/PHP/ext directory has the php_mysql.dll otherwise download this specific dll from http://dev.mysql.com/downloads/connector/php/ (Direct link) and extract the dll into C:/PHP/ext .Add PHP to PATH as explained in http://in.php.net/manual/en/faq.installation.php#faq.installation.addtopath . Now to test PHP installation create a file phpinfo.php inside the C:/Inetpub/wwwroot and type just the following one line and save:

Now open the browser and type http://localhost/phpinfo.php and you should see the PHP Version and other details about your PHP Installation. Enjoy :) 3. Now to manage MySQL, there is a cool tool called phpMyAdmin which can be downloaded from this link. You need to extract this in a folder. For me it is C:/phpMyAdmin.Now you need to do certain tweaks to make it work.Create a file config.inc.php inside the C:/phpMyAdmin and type the following: Save the config.inc.php file. Now open the C:/WINDOWS/php.ini file and search for

"extension_dir ". Replace the line with: extension_dir = "C:/PHP/ext/" Also uncomment the line saying extension=php_mysql.dll in the C:/WINDOWS/php.ini . Now save the C:/WINDOWS/php.ini file. You need to give 'web share' access to C:/phpMyAdmin directory by opening it in explorer and right-click on the C:/phpMyAdmin directory and go to 'properties' now in the pop-up window go to 'web-sharing' tab and select the share-this-folder radio button and this will pop-up (I know it is windows and this sounds like pop-up-video of VH1). Write phpMyAdmin in the ALIAS Text Box of pop-up and select on WRITE and SCRIPT SOURCE ACCESS box. In APPLICATION PERMISSION choose SCRIPTS radio button. To test phpMyAdmin open http://localhost/phpMyAdmin/index.php in browser and you should see "localhost phpMyAdmin - 2.9.1.1". You are done with this now :) 4. For PERL. you need http://www.activestate.com/store/activeperl/download anyways, so click and download it first. Install this in C:/PERL directory then use the instruction at http://www.visualwin.com/Perl/ . To test the PERL - CGI installation, create a file called test.pl inside the directory C:\Inetpub\wwwroot\cgi-bin and type: #!/usr/bin/perl $time=time; $len=80; print "Content-type:text/html\n\n"; @base=qw/A T G C/; print ">Seq$time $len random bases\n"; while($c<$len){ $c++; print "@base[int(rand(4))]"; } Now save the test.pl in C:\Inetpub\wwwroot\cgi-bin. Open the link http://localhost/cgi-bin/test.pl in browser, this should generate a random DNA Fasta file of 80 bases.

In the next tutorial I will lead you into creating a bioinformatics database of sequences and then using it to align using muscle and store back in MySQL db... till then bye!

1 comment:

Anonymous said...

Thanks for writing this.