Sunday, February 17, 2008

Installation and configuration of PHP 5 and MySQL 5 on Windows IIS

I spent almost a full day to finally install and configure PHP on my windows system. I am basically a .NET developer and used ASP.NET, C# and MS SQL Server. From that background, configuring PHP with MySQL was a hell. I even tried the installer from php.net website but when it gave the option to choose from list of servers e.g.

IIS CGI
IIS ISAPI
Apache etc etc....

I selected IIS ISAPI and it gave some omnihttpd config error and told to configure manually. A nightmare for a Microsoft tool user :P

I un-installed PHP 5 and downloaded a zip file version from http://www.php.net/. All I did was the following to fix the errors.

Let me first tell you what errors that I was facing.
  • No Input file error while opening php page in a browser
  • MY SQL 5 was not detected when I was trying to install PHPBB3
  • When I executed a test.php file with code, the information screen said that php.ini path is c:\windows and no php.ini file is currently loaded

So, I did the following fix above

  • UnZip php5 in some folder. It is recommended not to uses spaces in folder names. I unzipped in X:\Data\Web\php\php folder.
  • Set user permissions: Give "Everyone" user the "Read and Execute" permissions in C:\windows, the php unzip folder and all of your php virtual directories. Just right click on the folder, select Security, Add user "Everyone" and give "Read and Execute" rights.
  • Set the path of unzip php folder in you system variables path. Right click on "My Computer", go to "Properties", then "Advanced", then "Environment Variables". In "System variables" tab, find "Path" variable and edit it. Append the php path at the end. The paths must be split by semicolons.
  • Copy the php.ini file to c:\windows folder. Now, php will use this as its configuration file.
  • Open php.ini from c:\windows folder and comment the line "doc_root="
  • In php.ini file, set "extension_dir" variable to your "ext" subfolder of php folder. I have set this as extension_dir = "X:\Data\Web\php\php\ext"
  • Set your virtual directory to run php files. Open IIS --> Default Website --> Your PHP virtual directory. This would contain your web application or the php pages that you want to run. Right click the virtual directory, go to "properties", then "Configuration". In "Mappings" tab, press "Add" button. In"Executable" browse for php5isapi.dll from your php unzip folder. In "Extension", give ".php". Remove the double quotes in both text fields, if there are any
  • Restart IIS. A short way of doing is to Start --> Run. Type iisreset.

Don't FORGET to Reset the IIS services.

After performing all the above steps, I executed test.php which has the phpinfo(); function call in it showed the php information screen and showed that php.ini path is c:\windows and currently loaded php.ini file is c:\windows\php.ini.

All this effort just to configure the php correctly........

Now, to configure this for MY SQL 5.0, I did the following steps:

  • In c:\windows\php.ini file, set extensions_dir to your extensions folder. Mine is extension_dir = "E:\Data\Web\php\php\ext"
  • By default, all the extensions in php.ini file are commented. So, uncomment the following 2 lines for MY SQL 5
  • extension=php_mysql.dll
  • extension=php_mysqli.dll
  • Be sure to download the php connectors dlls from http://dev.mysql.com/downloads/connector/php/ and copy them in your php extensions folder. The default ones did not work in my case. Download both MYSQL and MYSQLI and unzip in the extensions folder. My extensions folder in this case is E:\Data\Web\php\php\ext
  • Make sure that MY SQL 5.0 is installed. Download the My SQL Administrator tool to verify that the server is installed and the services are also running
  • Save the php.ini file and reset the IIS services. Use either iisreset command or IIS management console.

After performing the above steps, the phpbb3 install was showing MY SQL and MY SQL with My SQLI extensions both available.

Man!!!! I was so happy to see that green available word.

I thought to post the solution to all the forums that I visited for help, but I forgot which forums I visited. I remember google as the search engine... lolz...

Finally, I thought to post a blog for it for my own records, when I need it later in case of problems. All the best to googlers if you find it and fix your configuration issues.

Tuesday, February 12, 2008

Naruto - My new craze



As long as movies and TV are concerned, I was first addicted to Friends seasons. Now, a friend of mine gave me some episodes of Naruto, a japanese animation series. It seemed stupid first that the characters are talking in japanese and English translation is showing at the bottom. But the story is so great that I am watching it non-stop. One of the best resource for downloading the series is http://www.narutocentral.com/.




Below are the 2 main characters from the animation series.




A must watch if you are a fan of martial arts or ninja. Below is the whole team of the Konoha villiage