Click to See Complete Forum and Search --> : Install FAQ (IIS6, mysql_*() functions, etc.)


bradgrafelman
06-01-2007, 12:02 AM
After seeing the same issues arise and be resolved by the same suggestions many, many times, I've decided to create this FAQ thread. You should feel free to post additions/suggestions/etc. in this thread. For a bit of housekeeping, I will delete each post as I integrate its content into this thread. Also note that any off-topic posts will be obliterated on sight.

Topics currently covered in this thread:

Integrating PHP5 with IIS6 using the ISAPI filter
PHP5 :: Can't use mysql_*() functions
PHP won't read php.ini (IIS6)

bradgrafelman
06-01-2007, 12:07 AM
1. Installing and Integrating PHP with IIS6

1. Download the zipped package for PHP5: Visit www.php.net and click Downloads
at the top. Make sure you choose the “zip package” under Windows Binaries
2. Unzip the package to an easy-to-remember location (example: C:\php\ - doesn’t have
to be the C: drive, however)
3. Rename the php.ini-recommended file to php.ini and configure as necessary.
a. If you unzipped PHP into a different directory than “C:/PHP”, you’ll need
to search through the php.ini and replace “C:/php” with the correct path
(use forward slashes, ala Unix paths)
4. Create 3 folders in the PHP directory: includes, logs, tmp
5. Add the PHP directory to your system’s PATH environment variable:
a. Properties of My Computer
b. Advanced tab
c. Environment Variables button at the bottom
d. Under System variables, select the Path variable and click Edit
e. Add “C:\php;” at the beginning (the semicolon is a path separator)
f. Create a new System variable called PHPRC – set it’s value to the
path to the PHP directory (e.g. C:\php)
g. Yes, rebooting the entire server is a necessary step – stop trying
to get around it :)
6. Now it’s time to integrate PHP into IIS! Open up IIS manager
7. Right-click on the Web Service Extensions folder and choose
“Add a new Web service extension”
a. Give the new extension a name (“PHP” sounds nice and obscure,
so we might as well use that)
b. Click Add under Required files, and browse to the
“C:\php\php5isapi.dll” file
c. Check the box labeled “Set extension status to Allowed”
8. Right-click on “yoursite.com” under Web Sites and choose Properties
a. On the Home Directory tab, make sure Execute permissions is set to
“Scripts only”
b. Click the Configuration button next to Execute permissions
i. Click the Add button
ii. Browse to the “C:\php\php5isapi.dll” file
iii. Under Extension, type in “.php”
iv. Make sure Verbs is set to “All verbs”
v. Make sure “Script engine” is checked but “Verify that file exists” is
unchecked
c. Click on the ISAPI Filters tab
i. Click the Add button
ii. Give the Filter a name (“PHP”, anyone?)
iii. Browse to... that’s right, you guessed it! Php5isapi.dll strikes
again!
d. On the Documents tab, add “index.php” to the default content page list.

bradgrafelman
06-01-2007, 12:34 AM
2. PHP5 :: Can't use mysql_*() functions

Let me preface this FAQ by suggesting you ditch the MySQL extension - hey, the PHP team already did, that's why it's not enabled by default anymore! - and instead use a more robust set of functions/classes, such as MySQLi or PDO.

So, you uncommented the "extension=php_mysql.dll" line in your php.ini file, yet you still get "undefined function" errors? The trick that solves this 99.9% of the time is to add the PHP5 directory (e.g. c:\php\) to your system's PATH environment variable.

Why?

The "php_mysql.dll" extension needs (as do other extensions) some support libraries (.dll files). PHP5 makes it easy and places all of these .dll libraries in the root of the PHP installation folder (e.g. c:\php\). If your system doesn't know to look for them there, however, the extension won't either.

Note: You should never copy any PHP-related file outside of the main PHP installation directory (e.g. c:\php\) into a system directory!

To add the path to your system's PATH environment variable, the PHP manual has a nice FAQ entry located here (http://www.php.net/manual/en/faq.installation.php#faq.installation.addtopath).

Fixing your PATH and ensuring that your php.ini file is being parsed almost always fixes this error.

bradgrafelman
06-01-2007, 12:42 AM
3. PHP won't read php.ini (IIS6)

If you make changes in your php.ini file, restart IIS, yet nothing seems to have changed in the output of phpinfo(), your php.ini file most likely isn't being parsed at all. Another symptom of this behavior is seeing "C:\WINDOWS" (or the path to your Windows directory) as the "Configuration File (php.ini) Path" in phpinfo().

Note: You should never copy any PHP-related file outside of the main PHP installation directory (e.g. c:\php\) into a system directory!

The simplest method that (seemingly) always works for IIS6 users is to add a PHPRC environment variable to your system that points to the directory where your php.ini file resides (e.g. c:\php\). For more information on doing this, see this (http://www.php.net/manual/en/faq.installation.php#faq.installation.phprc) FAQ in the php.net manual.

sneakyimp
09-11-2007, 05:49 AM
What about this problem (http://simonwillison.net/2004/Mar/31/phpAndApache2/) ? Any tips on how to avoid it? Or how to get some multithreaded php action going on?

jacknbey
02-22-2008, 02:14 AM
How do we know if it is parsed for MySQL to work?

I only keep 1 copy of PHP.ini and DLL files in the c:\php directory.

Can someone help to take a look at this php.ini and see if it is configured correctly?

Thanks a million.

bradgrafelman
02-22-2008, 03:05 AM
Do a phpinfo(). If you see a table for mysql, then the MySQL extension has been enabled successfully.

Alternatively, if you're using PHP5, you could use the MySQLi (or even PDO) extension since the MySQL extension has been deprecated.

mattastic
04-23-2009, 05:27 AM
Regarding changing the path environment variable for IIS6.

This is assigned to coldfusion at the moment as coldfusion runs my intranet.

C:\CFusionMX7\verity\k2\_nti40\bin;C:\Program Files\NetApp\SnapDrive\;C:\Program Files\Support Tools\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files\System Center Operations Manager 2007\


Is it still ok to change or will it mess things up?

Thankyou

bradgrafelman
04-23-2009, 02:56 PM
You can add PHP because that's basically a list; even if ColdFusion isn't first, the entire list will be searched until a requested file is found (or the list is exhausted and the file can't be found).