Set up IIS 7 w/ MySQL and PHP 5
Hey fellas, this is my first Blog Post.
In my posts i’ll try to share with you some experiences i’ve had in the past week during my work as a web developer.
As all of us are talking about the new coming Windows Vista, I decided to dedicate my first post to guide you all on how to setup IIS 7 along with MySQL and PHP 5. Before entering the venture myself, I searched the internet for tutorials on how about to do that, however, the closest i got was to install IIS 7, PHP and MySQL, however, everywhere i looked the PHP didn’t work with MySQL.
I decided to go on the ride anyways, hoping to get it to work, and fortunately, i did ;).
Here is how i was about doing that:
First step, IIS 7.
I have Windows Vista RTM 64bits, thus this guide will show all the steps required to set it up on Vista 64bits, however, i will try mention all the steps that 32bit users should accomplish instead.
In order to set IIS 7 up, please go to Start->Control Panel->Programs->Turn Windows features on or off.
see yellow mark on the picture below
Inside the window that popped up, Look in the list for Internet Information Services. and check the box next to it.
Under “Internet Information Services”->”Web Management Tools” check “ISAPI Extensions”.
Click ok and wait for it to install IIS 7. When finished close the Control Panel window.
That’s it, IIS 7 is all set, in order to confirm that, you can try to go to http://localhost in your favorite browser.
Next step: PHP 5.
Because i was using the 64bit edition of Vista, instead of downloading the regular distribution from php.net i downloaded a 64bit version from http://www.fusionxlan.com/PHPx64.php, Please download the zip package, as of this time, the latest version is 5.2.0
People who are using the 32bit edition of Vista, please download the zip package from http://www.php.net/downloads.php.
Unzip the zip to your drive, i used C:\php. now inside C:\php you will find a file named php.ini-dist.
copy this file to c:\windows\ and rename it to php.ini (erase the -dist part).
Now open the php.ini in notepad.
Inside the file, look for the line ;extension=php_mysql.dll and delete the semi-color (;) from the beginning of the line.
Now save and close the file.
Next, let’s copy the dll to the right place…
Go to c:\php\ext and copy the file php_mysql.dll. Now go to C:\Windows\System32 and paste the dll there.
When asked to, Click continue to gain Administrator privilege.
Now let’s configure IIS to work with our PHP.
Go to start->run and start InetMgr.exe (IIS Manager).
Inside IIS Manager click on “Handler Mappings”.
On the right side of the window, click on “Add Script Map…” (Yellow box in the pic below)
In the window that pops up, fill up the fields with these values:
“Request path:” *.php
The window should look like this one when you are done.
Click “Ok”, And when the “Add Script Map” dialog pops up, Click “Yes”.
Ok, so we have PHP and IIS 7 working together, now it’s time to add the last piece to the puzzle, MySQL.
Download MySQL, i used MySQL 5.1 located at: http://dev.mysql.com/downloads/mysql/5.1.html
32bit users, download the 32bit distribution, 64bit, download the 64bit one.
Once you downloaded the MySQL installer, 32bit users, all you have to do is go through the Installer steps (Click next,next next next) and you should be fine.
64bit users, you still got some little work, after installing the MySQL, i had a problem running the configuration wizard, in order to solve that problem, i used the following trick.
I downloaded the 32bit zip package (without installer), inside C:\Program Files\MySQL\MySQL Server 5.1\bin i renamed the file libmySQL.dll to libmySQL64.dll and copied the 32bit file into the directory instead. Then i ran the configuration wizard, and this time it worked.
After the configuration process was completed, delete the 32bit file from the directory and rename the file libmySQL64.dll back to libmySQL.dll.
That’s it, you are all set with IIS 7+MySQL+PHP.
In order to make sure that everything is in order, create a file named test.php inside C:\inetpub\wwwroot\ and write inside
Then inside your favorite browser browse to http://localhost/test.php and you should see all the settings of your php installation, if you will scroll down, you should also see MySQL settings which will confirm that MySQL is indeed installed.
A fix for Sessions Issue: Vista seems to have a permission problem with php’s session.
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line
In order to solve the issue, inside CMD as administrator (Right click on CMD.exe and “Run as administrator”). write these two commands:
icacls %windir%\serviceprofiles\networkservice\AppData\Local\Temp /grant Users:(CI)(S,WD,AD,X)
icacls %windir%\serviceprofiles\networkservice\AppData\Local\Temp /grant “CREATOR OWNER”:(OI)(CI)(IO)(F)
Well, i hope that my first Post will assist at least some of you, any comments regarding my writing are welcome. And of course, if you have any questions or you are having any difficulties in the process, don’t hesitate to comment and i promise to try and help with every comment.
Till the next time…
Posted in Tools