User Contributed Notes 58 notes

PHP will not "take" the changes until the webserver is restarted, and that doesn't mean through the MMC. Usually folks just reboot. But you can also use the following commands, for a much faster "turnaround". At a command line prompt, type:

iisreset /stop

and that will stop the webserver service. Then type:

net start w3svc

and that will start the webserver service again. MUCH faster than a reboot, and you can check your changes faster as a result with the old:

<?php>
phpinfo();
?>

in your page somewhere.

I wish I could remember where I read this tip; it isn't anything I came up with...

If you use the installer for Windows (PHP >= 5.2.x) and you want the mysql_* functions to be used, you may have to restart your machine after you install.

I was getting the error "Call to undefined function mysql_connect..." However, I knew that my php.ini settings were correct and I was including php_mysql.dll. When I viewed phpinfo(), it was not showing that MySQL was part of the install. My first thought was to restart Apache - this did not change anything. So, then I restarted the machine, viewed phpinfo() again and it was now there.

I've manually installed several times on Windows and not had this problem. This was my first time running the installer. I think it may have something to do with setting registry values or changing environment variables. Nonetheless, hope this helps.

In order to run php scripts with php.exe CGI instead of php4isapi.dll under IIS, following steps can be followed.

i) Add a web service extension for PHP using IIS manager. Choose a web service extension name like 'PHP' and add your php.exe path in the 'file location' while adding the required file e.g. 'C:\php\php.exe' in the Add extension dialog box. Don't forget to 'Allow' the extension file.

ii) Open php.ini file located at %systemroot%. Set the following variables to the shown values.

cgi.force_redirect = 0cgi.redirect_status_env = ENV_VAR_NAME

iii) In your websites, add Application Mapping for '.php' and set the executable path to your php.exe file path.

You can test whether PHP is running or not and other PHP settings using the following simple PHP script.

To allow acWEB.sf.net win32-webserver and Eserv 2.98 (www.eserv.ru) web-server run PHP 4.2.2 without problems with FORCE_REDIRECT you should set "cgi.force_redirect = Off" in php.ini in windows directory.

I installed by Microsoft Installer, manually, whatever I always received de same error from IIS7.

HTTP Error 404.3 - Not FoundThe page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

The IIS7 interface is quite diferent and are not all together like IIS6

The 5.3 version have not any of those files: php5stdll, php5isapi.dll. etc.

The installer puts others files in handlers and I decided to use them as substitutes. Nothing done!

After that, I discovered that installer do not install these files within the sites, but in the root default site configuration of IIS7.

So, I copied the root configuration to my site and them it worked (all others procedures were done e.g. copy php.ini to windows folder)

In IIS 5.1 on Windows XP Pro, Go into the Internet Information Services, and into the properties of the virtual directory where the problem occurs. On The 'Virtual Directory' tab, click on the 'Configuration...' button. Select the '.php' extension, and press 'Edit'. On the bottom, Check the 'Check that file exists' checkbox.

Background:For several days now I, as a newbie, have been unsure if I had installed PHP correctly, or not. No matter what I did phpinfo( ) reported "Configuratin File Path" as: “C:\WINDOWS”. I was left to wonder what was wrong.

To help resolve the phpinfo() “issue”, I conducted a series of tests using two scripts:

The first is “test-php-ini-loaded.php”; it is stored in c:\inetpub\wwwroot, and has the following code:

Test 1:a. PHPRC environment variable and IniFilePath Registry left in place and activeb. Verified no other copies of php.ini exist on the system other than in my E:\PHP folderc. Renamed php.ini to hold-php.inid. Stopped and started IIS (“net stop iisadmin” and “net start w3svc”)e. Ran “test-php-ini-loaded.php” to check whether my php.ini is loaded. It is not.f. Ran "test.php". “Loaded Configuration File” was empty, while “Configuration File (php.ini) Path” showed: C:\WINDOWS.

Test 2:a. Moved php.ini from E:\PHP to C:\WINDOWSb. Stopped and started IISc. Ran "test-php-ini-loaded.php" to check if my php.ini is loaded. It is not, which surprised me.d. Ran "test.php". My php.ini is apparently not loaded, or found, by phpinfo( ), even though “Configuration File (php.ini) Path” reports it as being in C:\WINDOWS.e. Note: Per PHP’s “The configuration file” note, PHP's search order includes: “Windows directory (C:\windows or C:\winnt) (for Windows), ...”; but it apparently doesn’t or php.ini would have been found and displayed at “Loaded Configuration File”.

Test 3:a. Left the solo copy of my php.ini in C:\WINDOWSb. Disabled PHPRC environment variable by renaming it to “Ex-PHPRC and saving the settings (note: for this test I left the Registry entry for PHP IniFilePath intact)c. Stopped and started IISd. Ran "test-php-ini-loaded.php" to check whether my php.ini is loaded. Predictably it is not found.e. Ran the "test.php". Again, my php.ini file is reported as not found in C:\WINDOWS though “Configuration File (php.ini) Path” reports it as being there.

Test 4:a. To be thorough and eliminate all possible sources of “mis-direction” I deleted the PHP IniFilePath Registry entry (after backing up the Registry). The PHPRC environment variable was left disabled. b. Stopped and started IISc. Ran "test-php-ini-loaded.php" to check whether my php.ini is loaded. Predictably it is not.d. Ran "test.php". Again, no change. My php.ini file is not found “Configuration File (php.ini) Path” reports it as being there.

Conclusions:The first conclusion I came to is that, in the default download version of phpinfo( ), “Configuration File (php.ini) Path” is hard-wired to report C:\WINDOWS whether php.ini is there or not. Further, that C:\WINDOWS is not a default search location (at least not on XP).

However, given an otherwise “proper” setup, phpinfo() reporting C:\WINDOWS as the value for “Configuration File (php.ini) Path” is merely misleading and is not actually harmful or indicative of a failed installation.

Thanks go to Peter Guy of www.peterguy.com who suggested the testing, and to Daniel Brown of www.php.net for some initial guidance.

P.S. This note is not meant to take anything away from PHP. It is a fine tool. The sole purpose of the testing was to confirm that my installation of PHP was correct.

I hadn't installed PHP in years, used the PHP 5.2.9-2 installer. Selected FastCGI on IIS, I just didn't work. On both a w2k3 server and on a Vista laptop.

First, I forget to install from ZIP, as I had before. I suggest a notice on the download page. The message "Use of the installer isn't the preferred method for installing PHP." is on the "Windows Installer (PHP 5.1.0 and earlier)" page. Is that no longer true for "Windows Installer (PHP 5.2 and later)"?

If you get errors like this:PHP Notice: Constant XML_ELEMENT_NODE already defined in Unknown on line 0

And many more complaining about XML constants, comment out the line:extension=php_domxml.dllin your php.ini. That extension seems to be compiled into PHP when you get those errors or something else is including the functionality before that dll.

If you have installed using the msi file, allowed it to configure IIS6 for you using the default directory, and are receiving a 404 error (specifically 404 2 error in your log file), then you need to modify the "application extension" for .php to include the full quoted path. The default uses the old 8.3 convention which is not considered the same by IIS, and therefor the web extension isn't allowed.

cgi.force_redirect = 0++ You MUST set this (its commented out by default)

two new settings are included...session.save_path = "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\php\session"upload_tmp_dir = "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\php\upload"++ sessions will fail: $_SESSION['something'] unless you deal with permissions on the new location,or simply comment out the session.save_path and go back to default "c:\windows\temp"

Add the two installations and their EXT directories to the Path variable. For example, add:c:\php;c:\php\ext;c:\TMAS\php;c:\tmas\php\ext;

Then, add the newer PHP version's directory as a variable called PHPRC. For example:Variable:PHPRCValue: C:\PHP

Click OK to close the Environment Variables window, and click OK to close System Properties.

2. In registry, under HKEY_LOCAL_MACHINE>SOFTWARE>PHP, add a REG_SZ key called iniFilePath and give it a valueof the directory where the older PHP is installed. For example:C:\TMAS\PHP

3. In IIS, go to the Web Service Extensions. Add both versions' ISAPI module separately to the extensionslist, and allow both.

4. In IIS, go to each website utilizing the PHP versions. Set an ISAPI filter if needed. On the Home Directorytab, click Configuration, and add .php, .php3, .phtml, and any other extensions needed (perhaps .html?) tobe filtered through PHP, and specify the ISAPI module version needed for each website.

You can now run two versions of PHP. This is because the order of where to look for the .ini file changedbetween previous PHP versions and PHP 5.2, as documented at http://us2.php.net/ini:

--------------------------------------------------- php.ini is searched in these locations (in order):

Thought someone would save some time and headaches by using this post.

Our tech department is migrating to Windows 2003 Server and they have some complex security implementations between our Web Servers and our Application (COM) servers.

If you have this type of scenario and are receiving the "Warning (null)(): Unable to lookup.... Access is denied." error, it is because the "Identity" in the Web Server's application pool does not have sufficient permissions to connect to the Application (COM) Server.

To fix this:

- create a new Application Pool- right click the new pool and select "properties"- click on the "Identity" tab- change the permissions from "Network Service" to a user on the Web Server who has access to call the Application (COM) server.- right click the application pool- click "start"- right click your web site- click on the "Home Directory" tab- change the application pool to the new application pool you've just created.- restart IIS

You can have multiple versions of PHP running on the same Apache server. I have seen many different solutions pointing at achieving this, but most of them required installing additional instances of Apache, redirecting ports/hosts, etc., which was not satisfying for me.Finally, I have come up with the simplest solution I've seen so far, limited to reconfiguring Apache's httpd.conf.

My goal is to have PHP5 as the default scripting language for .php files in my DocumentRoot (which is in my case d:/htdocs), and PHP4 for specified DocumentRoot subdirectories.

# populate this for every directory with PHP4 code<Directory "d:/htdocs/some_subdir"> Action application/x-httpd-php "/php4/php.exe" # directory where your PHP4 php.ini file is located at SetEnv PHPRC "c:/usr/php4"</Directory>

# remember to put this section below the above<Directory "d:/htdocs"> # directory where your PHP5 php.ini file is located at SetEnv PHPRC "c:/usr/php5"</Directory>---------------------------

This solution is not limited to having only two parallel versions of PHP. You can play with httpd.conf contents to have as many PHP versions configured as you want.You can also use multiple php.ini configuration files for the same PHP version (but for different DocumentRoot subfolders), which might be useful in some cases.

Remember to put your php.ini files in directories specified in lines "SetEnv PHPRC...", and make sure that there's no php.ini files in other directories (such as c:\windows in Windows).

And finally, as you can see, I run PHP in CGI mode. This has its advantages and limitations. If you have to run PHP as Apache module, then... sorry - you have to use other solution (the best advice as always is: Google it!).

If you get 404 page not found on Windows/IIS5, have a look at C:\SYSTEM32\INETSRV\URLSCAN

There is a .ini file there that prevents some files from being served by IIS, even if they exist, instead IIS will give a 404. The urlscan logfile (same place) should give you some insight into what parameter is preventing a page from loading, if any.

On the Windows 2003 & IIS6 platform, you can run different websites on different versions & copies of PHP. This is useful in at least two cases:

1. You want one website on your box to have register_globals on, but since you're running IIS, you cannot specify that in an .htaccess file. And you definately don't want register_globals on for the rest of the websites. 2. You want to run different versions of PHP for different websites, or even just different extensions. Say you wanted one site to use 4.0.5 and a different site to use 4.1.11.

Its simple, just: 1. Move your php.ini file from your c:\windows\ directory directly to your php directory (by default that would be c:\php\) 2. Make sure you don't have a php.ini file in any other location that would supercede the c:\php\php.ini file. Using phpinfo(); is useful here. 3. Have your alternate version of php (either a different version or a different php.ini) have its own install directory, like c:\php4RG\ or c:\php405\. 4. In the Home Directory Configuration for your website, specify the .php extension to use a different script, pointing it at the alternate directory.

One very helpfull note to Win2003 iis6 users:If you'd like to use isapi in the web service extensions and you're in a development server (or even if your php.ini config file changes frequently), here's what you can do:

Now go to your site (or virtual directory site)-> properties->change the application pool to the newly configured appPool.

At this moment, is good to make a iss restart (note this is the only resart needed).

Your site is now semi-runtime changed :) You can try it with the usal php info() test. Change something in the php.ini and check the number of requests it takes to use the new configuration.

The downside of this approach (wich is still better than to use php-cgi.exe): the process is recycled, so all the configuration in php.ini is read every N requests - with php-cgi.exe, this would happen for every request, so.. is a good solution.

Again, be carefull when using this in a production environment, since the load can increase (not sure how much, but it will certainly increase).

And keep in the new appPool JUST the php sites that require runtime changes in php.ini !

Note to windows users, if you are trying to install php5 ISAPI on windows server 2003 / IIS and getting a 404 when you try to view a simple php script, even though everything else seems to be right... click into "web service extensions" from IIS and either add a new web service extension, or click onto "all unknown ISAPI extensions" and click allow.

This is just to clarify on a posting on this page that states the nescesity of allowing all unknown cgi Extensions in Windows 2003 IIS 6. Although this will work and it should be consider as a quick option for an itranet solution with no web access at all.

This poses a very serious security problem and its not the best course of action, in my opinion. The proper way of making this work will be to actually enable the extension that you want to execute. After verifying that the .php extension is present, simply go to "Web Service extensions" in the IIS Manager and click on "Add a new web service extension";

Once the "new web service extension" opens:

1- Add the "extension name" field, please enter "PHP" (or what ever you wanna call it) Other more conservative admins will say call it what it is and always input ".php". Its up to you!2-Click on the "add" button and browse to the php4ts.dll file on your c:\PHP (default) and then click open --> OK and set the checkmark under "set extension status to allowed" click OK and thats it!!!

If you missed the checkmark moment cause you are just so impatient, like me, then simply select the extension on the web service extensions windows and click ALLOW.

This is a very simple process and it will work everytime.

I hope this helps, as I have found several things in this forums that are incredibly helpfull!!

PS: For the non programmer, it is a good practice to install mysql and a free php forum like bb2 to test how well your php IIS and mysql is working.

Under a Windows 2003 and IIS 6.x installation of PHP, it is interesting to note that by default in most cases, the "DefaultAppPool" for the "Default Web Site" is running under the security context of "Network Service" which maybe too restrictive. This results in a 403: Forbidden error every time you try to access a PHP page.

You have several options to remedy the problem:an obvious one is to make it run as the "Local System", but that may be too much power for some administrators' tastes.

The other option is at the IIS Manager,go to the computer's "Application Pools" folder,and go to the properties dialog box of the "DefaultAppPool",and then to the "Identity" tab, and select the "Configurable" identity of "IWAM_[COMPUTER_NAME]" as the security context. This will make the application pool run the way it did in the previous versions.

This solved the repeated problems of the 403 errors. However, do not forget to give permission to "IUSR_[COMPUTER_NAME]" and "IWAM_[COMPUTER_NAME]" appropriate directory permissions for your web directories as stated above.

For those having trouble installing PHP 5+ ISAPI for IIS 6 (on Windows 2003 server), who have tried everything on this site and all over the net, with no success (like I did) - try the following before throwing your server out of a 3rd story window.

It was the only thing that worked out of all the many solutions I tried.

Probably some other solutions would've worked as well, but in my frusterated state of mind, this explanation was the clearest.

My problem was that in addition to adding the the Web service extension, I was not adding the ISAPI extensions for the websites in IIS Manager manaully. ALSO, remember to reboot after the changes on the site listed above. It's the only thing he forgot to mention, and depending on your setup, you may need to reboot to register the dll moves and changes made. (IIS restart will not re-register dlls).

I've installed Apache + PHP on a Windows machine of which I'm not an administrator.

I found out it was necessary to change the permissions of the httpd.conf file on C:\Program Files\Apache Group\Apache\conf in order to have everything working. Since I'm also using cygwin this was simply done with: >chmod 755 httpd.conf.

If you are using Application Pool Isolation and you're trying to get PHP to run as CGI and you're getting 403 errors, try looking at this article (watch the word wrap):http://www.servertastic.com/articles/2005/11/unable-to-run-perl-or-php-in-application-pool-isolation/

IIS6 AND PHP5 on w2k31.download php and unzip to c:\php - also create c:\php\sessions2.add c:\php to you path -right click mycomputer,properties,advance,env variables2.On IIS Manager add web service extension -name: php isapi -req files: c:\php\php5isapi.dll3.Now let iis know what to do with .php -On iis Manager,right click Web Sites, properties, home directory tab, configuration button, add button executable: c:\php\php5isapi.dll extension: .php limit to: GET,POST,HEAD4. rename php.ini-recommended to php.ini you can copy php.ini to c:windows or modify the registry to look for php.ini in c:\php to use the registry create a php.reg file with the following inside. after this just double click. do not put the lines.-------------------------------------------------Windows Registry Editor Version 5.00

6. the web sites are going to be using the default pool. this runs under network service. go to c:\php and give the network service read& execute, list folder content,read -go to c:\php\sessions and add write and modify access network service

I've had problems Installing PHP 4.0.0 on IIS5, Win2k's default web server, spanish version (I live in Colombia). I've had HTTP 500 Errors and I followed all instructions step by step, but nothing seemed to work.

I solved the problem eventually, and I think it had something to do with the fact that I have installed PHP4 manually and placed it in the directory "C:\Archivos de programa\php-4.4.0-Win32" ('Archivos de programa' stands for 'Program Files'), a directory with spaces in between.

When I added the application mappings for "C:\Archivos de programa\php-4.4.0-Win32/sapi/php4isapi.php", An error would ocurr and a message along with it: "Escriba una ruta de acceso valida", as in "Write a valid access rute", as in "I can't find the file".

I thought i had it when I encapsulated it with Doublequotes ("), but that didn't work either.

As a final long shot, I copied the php4isapi.dll to the windows/system32 directory and 'WALA!' It worked.

I'm not sure, but i suspect that it had to do with spaces in between directory names, so avoid those, or copy the isapi module to another directory.

It's a hard way to get work php on win98/PWS... but with this comment-page I found it out how it works:<br>
- error 403: give read/write rights to the directory. You can do this by clicking the right mouse key on the directory in the explorer.<br>
- html file in a dos box: 1) clean the "doc_root" line in the php.ini file. 2) start personal web-manager / go to 'advanced' / make for your web-default-directory a virtual directory with all possible rights.<br>
On my system it works now!

(IMPORTANT: the quotes from c:\ to end of dll are important since the default install location, Program Files, has a space...in my youth I would yell "Stupid Microsoft"...but now I would more maturely just note that there is an inconsistency with the way that Paths are defined...in definingenvironment variables, for instance, such spaces are OK...).

I've installed php 5.0.5 with the ISAPI module, as the isapi dll file (php5isapi.dll) resides in the php root directory, I didn't have trouble in my installation (In php4 this dll file is in sapi directory and it should be moved to php root directory).

Note, if you have a web.config file present within the Virtual Directory folder, or otherwise configure the Virtual Directory to run ASP.NET scripts in a specific configuration...

IIS will ignore its ISAPI obligations to render your PHP script and then cite a 401.3 error, access denied based on ACL. If you have Integrated Windows Authentication turned on as a second authentication method, the web browser will prompt you for credentials. If you supply some, either from the local machine or from your domain, the website will suddenly work. This will also result in your website loading when you reference it via Localhost. Only works with Localhost, and does not work with any network-access IP.

Oddly enough, Anonymous impersonation will FAIL under these conditions! Why? I suspect it is because ASP.NET scripts run under the APPLICATION-POOL USERNAME CONTEXT. Once its kicked into that gear, any hope of using Anonymous user impersonation may go out the window.

References:/*******************/Impersonation in ASP.NET:

(Look up "Impersonation in ASP.NET (IIS 6.0)" on www.microsoft.com/Technet/ )

Filemon/Process Mon will not register any kind of failed file access attempts, everything will appear normally. Even the presence of a BUFFER_OVERFLOW message is normal within the context of SYSINTERNALS traces...

But if you download the IIS 6.0 resource kit, pay attention specifically to IISTRACE.

Running IISTRACE and hitting your webserver will reveal that the PHP5ISAPI filter DLL is never called! Only the asp filter DLL.

The moral of your story? Keep web.config files out of your PHP directories!

On IIS7 and Vista I got errors using Appcmd to add the handlers. I also wasn't able to choose FastCGI when adding the handler in the IIS Manager GUI. Removal of CGI from IIS components, a reboot, and re-adding CGI to IIS components allowed selection of FastCGI in the GUI and made it possible to complete the configuration steps.

Here is a URL (note the complete URL is presented here as 2 lines) for another tutorial on the process with steps for both GUI and command line configuration: learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis7/

If you get this error: "Service Unavailable" after installing PHP to a Windows XP x64 Pro, and you followed all the instructions posted in this page, you may want to try checking the ISAPI Filters in your IIS.

Make sure your a running the 32-bit version of the Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll.

If you are running the 64-bit version, you will notice that liested item in the ISAPI Filters has a red arrow pointing down. This means that the service failed to load. Delete this item from the list and add a new one. Make sure you use the one located here: %Windows%/Microsoft.NET\Framework\v2.*\aspnet_filter.dll.

Also make sure the permissions to your PHP folder have "NETWORK SERVICE", "IUSR_*", "SYSTEM" included.

I installed php 5.2.3 using the msi package to Windows XP SP2. First time, ISAPI choice defaulted to installing php to c:\program files\php. The IIS Manager > Websites > Home Directory > Extensions used the short filename. Didn't work - message was "module not found". I then removed and installed to c:\php. That worked easily.

i have encountered always the same problem installing php on windows 2003 (it always worked fine with w2k) "php has encountered an access violation at xxxx". tried php5.x and downgrade to php4.x without success. problem was solved only by giving r+w+e permission on php folder to user IIS_WPG

Another cause of the "No input file specified" on systems with multiple hosts is that the doc_root setting in the php.ini file has been set to a specific directory. When using IIS with multiple hosts in distinct top level directories you should comment the doc_root line out.

I have found the following procedure to work correctly EVERY time for installing PHP version 5.x.x on Windows 2003 servers. (I have done over 100 of these on Web, Standard & Enterprise)

1. Download the current PHP Zip file to a folder of your choosing.

2. Download the old Installer.exe (I use 5.0.2)

3. Run the installer and accept the defaults in all cases except the IIS server, choose IIS 6.0 or later. The installer will complain that a script map is not registered and ask you if you want to register it. SAY YES!!!

4. Run the installer a *second* time, using the same settings as above. This time instead of the complaint that a script is not registered you should see a black dos box open and then close. This is your clue that the install was successful.

5. Copy your PHP .zip file to c:\php and extract and overwrite all files from the regular installer.

6. Edit c:\windows\php.ini to enable any extensions you may need and to set the extension directory to c:/php/ext

All should be good to go. Test by running an info() from the web server.

I have used this install on over 100 installs of 2003/IIS web servers. Generally they have been virgin installs, but a few have had existing sites on them. Using the above method I am able to install PHP in under 2 min. Of course, these are windows systems thus your mileage may vary.

Note: I just tried to use the new .msi installer without success. Resorted to the above procedure and now have 5.2.0 running on the new server.

Note2: PHP powers that be, please make a copy of the old installer available again somewhere easily found by people. I would be screwed if I had not kept an archive copy of the 5.0 installer.

Don't forget if you are getting ACL exceptions to reading the test php page you have created you MUST share the PHP directory or the resources PHP uses to "everyone" but remember use restricted access for security.

IIS 5: If you change the application mappings for PHP (for example, from CGI to ISAPI module), reboot after the change is made. The PHP Application Mapping change may cause a conflict if ISAPI applications are cached.