As stated within the note "jimo at mail dot azhsv dot com
29-Nov-2003 04:33
PHP 4 and IIS 6.0 (Windows Server 2003)," I found the same steps were requiered for installation of PhP 5 beta 3 on my Windows 2003 server (Standard Edition)
This section holds common questions about the way to install PHP. PHP is available for almost any OS (except maybe for MacOS before OSX), and almost any web server.
To install PHP, follow the instructions in Installation and Configuration.
PHP is glue. It is the glue used to build cool web applications by sticking dozens of 3rd-party libraries together and making it all appear as one coherent entity through an intuitive and easy to learn language interface. The flexibility and power of PHP relies on the stability and robustness of the underlying platform. It needs a working OS, a working web server and working 3rd-party libraries to glue together. When any of these stop working PHP needs ways to identify the problems and fix them quickly. When you make the underlying framework more complex by not having completely separate execution threads, completely separate memory segments and a strong sandbox for each request to play in, further weaknesses are introduced into PHP's system.
If you want to use a threaded MPM, look at a FastCGI configuration where PHP is running in its own memory space.
By default on Unix it should be in /usr/local/lib which is <install-path>/lib. Most people will want to change this at compile-time with the --with-config-file-path flag. You would, for example, set it with something like:
--with-config-file-path=/etc
--with-config-file-scan-dir=PATH
On Windows the default path for the php.ini file is the Windows directory. If you're using the Apache webserver, php.ini is first searched in the Apaches install directory, e.g. c:\program files\apache group\apache. This way you can have different php.ini files for different versions of Apache on the same machine.
See also the chapter about the configuration file.
This probably means that PHP is having some sort of problem and is core-dumping. Look in your server error log to see if this is the case, and then try to reproduce the problem with a small test case. If you know how to use 'gdb', it is very helpful when you can provide a backtrace with your bug report to help the developers pinpoint the problem. If you are using PHP as an Apache module try something like:
Stop your httpd processes
gdb httpd
Stop your httpd processes
> run -X -f /path/to/httpd.conf
Then fetch the URL causing the problem with your browser
> run -X -f /path/to/httpd.conf
If you are getting a core dump, gdb should inform you of this now
type: bt
You should include your backtrace in your bug report. This should be submitted to » http://bugs.php.net/
If your script uses the regular expression functions (preg_match() and friends), you should make sure that you compiled PHP and Apache with the same regular expression package. This should happen automatically with PHP and Apache 1.3.x
Assuming you installed both Apache and PHP from RPM packages, you need to uncomment or add some or all of the following lines in your httpd.conf file:
# Extra Modules AddModule mod_php.c AddModule mod_perl.c # Extra Modules LoadModule php_module modules/mod_php.so LoadModule php5_module modules/libphp5.so LoadModule perl_module modules/libperl.so
AddType application/x-httpd-php .php
No, PHP works fine with the FrontPage extensions. The problem is that the FrontPage patch modifies several Apache structures, that PHP relies on. Recompiling PHP (using 'make clean ; make') after the FP patch is applied would solve the problem.
Do a 'view source' in the web browser and you will probably find that you can see the source code of your PHP script. This means that the web server did not send the script to PHP for interpretation. Something is wrong with the server configuration - double check the server configuration against the PHP installation instructions.
Something went wrong when the server tried to run PHP. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (php.exe on Windows) and run php -i. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of HTML codes (the output of the phpinfo() function) then PHP is working, and your problem may be related to your server configuration which you should double check.
[mybox:user /src/php5] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress
This has actually nothing to do with PHP, but with the MySQL client libraries. Some need --with-zlib , others do not. This is also covered in the MySQL FAQ.
cgi error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
This error message means that PHP failed to output anything at all. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (php.exe on Windows) and run php -i. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of HTML codes (the output of the phpinfo() function) then PHP is working.
Once PHP is working at the command line, try accessing the script via the browser again. If it still fails then it could be one of the following:
Make sure any user who needs to run a PHP script has the rights to run php.exe! IIS uses an anonymous user which is added at the time IIS is installed. This user needs rights to php.exe. Also, any authenticated user will also need rights to execute php.exe. And for IIS4 you need to tell it that PHP is a script engine. Also, you will want to read this faq.
You must set the cgi.force_redirect directive to 0. It defaults to 1 so be sure the directive isn't commented out (with a ;). Like all directives, this is set in php.ini
Because the default is 1, it's critical that you're 100% sure that the correct php.ini file is being read. Read this faq for details.
To be sure your php.ini is being read by PHP, make a call to phpinfo(). Near the top, there will be a listing called Configuration File (php.ini). This will tell you where PHP is looking for php.ini and whether or not it's being read. If just a directory PATH exists, then it's not being read, and you should put your php.ini in that directory. If php.ini is included within the PATH, it is being read.
If php.ini is being read and you're running PHP as a module, then be sure to restart your web server after making changes to php.ini
See also php_ini_loaded_file().
On Windows 7, XP, Vista, 2008, 2012 and up:
Go to Control Panel and open the System icon (Start → Control Panel)
Go to the Advanced tab
Click on the 'Environment Variables' button
Look into the 'System Variables' pane
Find the Path entry (you may need to scroll to find it)
Double click on the Path entry
Enter your PHP directory at the end, including ';' before (e.g. ;C:\php)
Press OK
On Windows 98/Me you need to edit the autoexec.bat file:
Open the Notepad (Start → Run and enter notepad)
Open the C:\autoexec.bat file
Locate the line with PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;..... and add: ;C:\php to the end of the line
Save the file and restart your computer
Note: Be sure to reboot after following the steps above to ensure that the PATH changes are applied.
The PHP manual used to promote the copying of files into the Windows system directory, this is because this directory (C:\Windows, C:\WINNT, etc.) is by default in the system's PATH. Copying files into the Windows system directory has long since been deprecated and may cause problems.
There are several ways of doing this. If you are using Apache, read their installation specific instructions (Apache 1, Apache 2), otherwise you must set the PHPRC environment variable:
On Windows NT, 2000, XP and 2003:
Go to Control Panel and open the System icon (Start → Settings → Control Panel → System, or just Start → Control Panel → System for Windows XP/2003)
Go to the Advanced tab
Click on the 'Environment Variables' button
Look into the 'System variables' pane
Click on 'New' and enter 'PHPRC' as the variable name and the directory where php.ini is located as the variable value (e.g. C:\php)
Press OK and restart your computer
On Windows 98/Me you need to edit the autoexec.bat file:
Open the Notepad (Start → Run and enter notepad)
Open the C:\autoexec.bat file
Add a new line to the end of the file: set PHPRC=C:\php (replace C:\php with the directory where php.ini is located). Please note that the path cannot contain spaces. For instance, if you have installed PHP in C:\Program Files\PHP, you would enter C:\PROGRA~1\PHP instead.
Save the file and restart your computer
If links to PHP files include extension, everything works perfect. This FAQ is only for the case when links to PHP files don't include extension and you want to use content negotiation to choose PHP files from URL with no extension. In this case, replace the line AddType application/x-httpd-php .php with:
AddHandler php5-script php AddType text/html php
No, it is possible to handle any request method, e.g. CONNECT. Proper response status can be sent with header(). If only GET and POST methods should be handled, it can be achieved with this Apache configuration:
<LimitExcept GET POST> Deny from all </LimitExcept>
As stated within the note "jimo at mail dot azhsv dot com
29-Nov-2003 04:33
PHP 4 and IIS 6.0 (Windows Server 2003)," I found the same steps were requiered for installation of PhP 5 beta 3 on my Windows 2003 server (Standard Edition)
Installing PHP 4 or 5 on Windows Server 2003 x64 results in http error 505. This is not a PHP bug. It is due to running a 32-bit ISAPI DLL under the 64-bit version of IIS 6, as documented here: http://support.microsoft.com/?id=895976
Solution: Flip the Metabase flag for Enable32bitAppOnWin64 as described in http://support.microsoft.com/?id=894435 ,
like this: CSCRIPT ADSUTIL.VBS SET W3SVC/AppPools/Enable32bitAppOnWin64 1
(Alternatively with full path: cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1)
You do not have to restart the whole system make effect of changing the PATH env var. For me (sbs2003) worked automatically.
on older systems you can use
set $Path=%path%;c:\php
command to extend immediately the path var.
PHP 4 and IIS 6.0 (Windows Server 2003)
Had difficulty getting PHP 4.3.3 to work with Win2003 Ent Server for use with SquirrelMail. Problem found and believed solved. Appears to be something New with IIS 6.0 (More security by Micro$oft) Was getting 404 error and php was not being run as a cgi even though it was in extensions and IIS user had rights to execute it. (php from command line operated correctly)
If you are installing on Windows Server 2003 (only have Enterprise Edition � Not sure if this applies to standard edition), and you have done the normal procedures for inclusion of PHP scripts (either ISAPI or CGI) in IIS, you will still get a 404 error when attempting to execute those scripts even though IIS has rights and the extension points to the correct file. To alleviate this problem, perform the following:
1. Open a command prompt window
2. Change to C:\windows\system32
3. Execute the command: cscript iisext.vbs /AddFile c:\php\php.exe 1 php 0 php
4. Execute the command: cscript iisext.vbs /EnFile c:\php\php.exe
5. To check for correct execution of the above,
6. Execute the command: cscript IisExt.vbs /ListFile � the php extension should be listed
If you try just step 4 without step 3 you get an error that the file is not in the list (and won�t be there till you do step 3 above)
After this, IIS seems to like the php extension and work normally.
For additional reference, see the below 3 Micro$oft KB Articles:
HOWTO: Enable and Disable ISAPI Extensions and CGI Applications in IIS 6.0 (MS KB Article 328360)
HOWTO List Web Server Extensions and Extension Files in IIS 6.0 (MS KB Article 328505)
HOWTO Add and Remove Web Service Extension Files in IIS 6.0 (MS KB Article 328419)
One final note to the message below if you are getting the message about not having rights to execute...You need to use IIS right click on the website and choose 'Properties/Home Directory' then on the 'Execute Permissions' combo box you need to choose 'Scripts only'...Click ok...another dialog may appear asking which directories to apply the action too...choose any directories that you intend on using php in and click ok...It should work now...
For Windows XP users
Just add php.ini to windows/system 32 and also save a copy in the setup folder e.g. c:/php/php.ini, c:/php5/php.ini,
You have to follow the suggestions, add to path, uncomment extensions and voila!!
Windows 2000 Server and IIS (SP4 and all patches):
After many frustrating hours of trying to figure out the install (again), It took a while, but here are a couple tips:
PHP working with IIS uses c:\winnt\php.ini
It doesn't matter what you set the path to, nor what you set the PHPRC environment variable to. After you get PHP running correctly in the installation folder (using php -i) copy the php.ini file into the c:\winnt folder.
Here's what worked for me:
- Add PHP path to System environment variable
- Add php5activescript.dll from http://snaps.php.net/ to the PHP folder, then Register it: "regsvr32 php5activescript.dll"
Set extension_dir and doc_root directives in PHP.INI:
extension_dir = C:\WWW\PHP\ext
doc_root = C:\WWW\Site
cgi.force_redirect = 0
(the last cgi.force_redirect isn't required, but I like to set it anyway)
Copy the .INI file into WINNT folder
In IIS Manager, right-click "Default Web Site", Click "Home Directory",
Click "Configuration", "Add" the ISAPI application:
Executable: <your php install>\php5isapi.dll
Extension: .php
Limit to: GET,HEAD,POST
Check: "Script Engine"
Uncheck: "Check that file exists"
Finally: Set up an ISAPI filter:
Click the "ISAPI Filters" tab,
Filter Name: PHP
Executable: <your php install>\php5isapi.dll
Notes: You don't have to set any of your folders as "Script source" folders. .PHP files aren't scripts, merely text files that require processing before being shipped off to the browser, which is what the ISAPI filter does.
Finally, working again.
Chase
Had a hard day to MSI install 5.2.3 on WinXP with MySQL. I use a drive substitution (subst drive: path - in my case subst d: c:\drive_d) and installed PHP in D:\PHP - which in reality is C:\DRIVE_D\PHP. To make a long story short - only after (1) changing all substituted D:\ back to C:\DRIVE_D and (2) resolving all DOS short names to Win long names PHP started to work. The first one is clear - the substitution works only for the active console user - not for services or IUSR. For the second one I have no explanation, since DOS short names should work systemwide - maybe Win handles them correctly but PHP not ?
BTW <?php phpinfo(); ?> was of tremendeous help
Meiki
<LimitExcept GET POST>
Deny from all
</LimitExcept>
Does not work with Apache2+ & PHP5 . Apache Refuses to start
I have some additional troubleshooting tips for 53.7, which deals with getting a blank screen on your browser when running a PHP script.
In addition to server misconfiguration, it may also be that PHP isn't configured to output errors to the browser, which is the case if you or your host uses a more secure php.ini. If this is the case, you need to find out where errors are being logged to find out if any errors are preventing normal output from being delivered to the client.
If you have access to php.ini, check the 'display_errors' directive, which is, by default, located under the 'error_reporting' directive. It's helpful to have 'display_errors' on during debugging phases, but best to have it off in production environments.
Related functions: http://php.net/ini_set | http://php.net/error_reporting | http://php.net/error_log
Here are my struggle to get PHP 5.2.12 working on Windows XP SP3, IIS 5.1 (Please note Win XP SP3 has issue of FastCGI)
1. Dowloaded installer and installed in C:\Program Files\PHP as ISAPI module
---->Did not work
Added php5isapi.dll in ISAPI Filter and added the extension .php in Home Dir->Configuration
(For every setting change restarted IIS on cmd->iisreset)
---->Did not work
(And the Google was pointing to the Fast CGI issue; Don't know why microsoft has MS-FAST ! )
Uninstalled the PHP and cleaned up the folders, PATH environment variable & PHPRC, the IIS settings and registry entries and shut down(restart is different from shut down) the system to make it very clean
2. Reinstalled the PHP in C:\PHP as ISAPI and did the same as above in IIS
(For every setting change restarted IIS on cmd->iisreset)
---->Did not work
Uninstalled and cleaned up same as above and took a breath to make sure what I am doing wrong.
Shutdown the system.
3. Unzipped the php-5.2.12-Win32.zip and did the same as above (this time manually PATH variable and security permission for the PHP folder and following settings)
short_open_tag = On
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
doc_root = "C:\Inetpub\wwwroot"
extension_dir = "C:\PHP\ext"
cgi.force_redirect = 0
---->Did not work
Uninstalled and cleaned up same as above
Shutdown the system.
4. Downloaded Microsoft Web Platform Installer 2.0 and select the PHP+Fast CGI+Windows Cache for PHP extension and Web Deployment Tools
restarted the system to take effect the settings
---->Did not work
Uninstalled and cleaned up same as above
Shutdown the system
5. Took the prev version of PHP php-5.2.4-Win32.zip unzip the folder and did the following changes:
short_open_tag = On
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
doc_root = "C:\Inetpub\wwwroot"
extension_dir = "C:\PHP\ext"
cgi.force_redirect = 0
set the security permission as IIS_machinename with full access to the C:\PHP folder
------->IT GOT WOKRING
Hope people would be aware of php-5.2.12 and would love the php-5.2.4
Running Win2K AS + IIS5.0 + PHP 4.3.1, I ran into a nasty problem that I mistakenly thought had to do with something in the php.ini configuration. When I would try to submit a form using the HTTP method GET it would work, but I would get a "404 Page Not Found" error using the POST method.
All my permissions were set correctly, the php.ini was configured correctly. It had to do with URLScan being installed on IIS (see below)
Page 404 File Not Found Error When Using POST method in PHP (and Perl, and otherwise)
-------------------------------------------
This is related to the Microsoft URLScan utility. If you have this problem, the IIS administrator has probably run the IIS Lockdown tool as well as configured URLScan to reject this type of HTTP method when sent in a URL. These tools are meant to enhance web server security.
URLScan configuration files can be found in the \WINNT\system32\inetsrv\urlscan folder on the web server. Specifically, the file to modify is urlscan.ini.
The changes to make are as follows:
1. Make sure UseAllowVerbs=1 under [options]
2. Under the [AllowVerbs] section, list your allowed HTTP methods to include:
GET
POST
For more information on the IIS Lockdown tool and URLScan, visit http://technet.microsoft.com
I recntly upgraded from PHP 5.1 to 5.2 on my Windows Server 2003 using IIS6. I selected CGI as before. My PHP folder is as always C:\Program Files\PHP. I also edited my brand new php.ini, enabling all my old extensions and recommended settings for IIS. I like not to keep my old config into a new version.
After upgrade, I just got blank pages in my browser, and the response status was 404 Not found.
I checked my installation twice, using this FAQ, but got no way.
Then I went to IIS Manager, Web Service Extensions. The php Service Extension was Allowed as it should. I deleted the Service Extension and added it. The old extension used short file names containing tilde (PROGRA~) character, but I don'æt know if that gas anything to do with the problem. Anyway, after allowing my" new" Service Extension, pointing to php-cgi.exe as before, mye web sites suddenly worked. So will revommend anyone with thos problem to delete and add the Servcie Extension. It didn't help re-allowing it, restarting IIS or the complete server.
Finally got IIS 5 and PHP 5 to talk.
What worked for me was:
1) Set
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
W3SVC\Parameters\Script Map]
".php"="your path to php\\php.exe"
2) ensure there is not a php.ini in the windows system folder and that there is one wherever you've put PHP
3) edit php.ini and set cgi force redirect to 0 and cgi.rfc2616_headers = 1
4) Put the PHP scripts in their own folder underneath the inetpub root
5) Open the IIS console, right click your new php folder
In the Directory tab
set application name to the name of the folder
set executable and script as permission
set application protection to low
Click configuration and check that .php is mapped to wherever you put
PHP
Restart IIS
Try a very simple PHP page and it should work
Nigel
INSTALLATION ON OPENBSD 3.1 VIA PORTS COLLECTION
Would have succeed but no mysql support.
I commented out the FLAVORS+= dbase filepro mysql mysql_bundled postgresql iodbc in the /usr/ports/www/php4/Makefile and in the configure options added
--with-mysql=/usr/local and it worked.
Good Luck
To limit HTTP Request Methods on the Apache server running PHP you should use mod_rewrite or mod_security instead of LimitExcept, to give you more control over the handling of such http errors. Can go in .htaccess file or httpd.conf
# mod_rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|POST)$
RewriteRule .* - [F,L]
</IfModule>
# mod_security
<IfModule mod_security.c>
SecFilterSelective REQUEST_METHOD "!^(GET|HEAD|POST)$" "deny,log,status:403"
</IfModule>
You can use the php request method scanner at askapache to see exactly how your server deals with various request methods, and check that your server is configured properly..
http://www.askapache.com/online-tools/request-method-scanner/
When i first installed PHP 5.2 / 5.1 on Windows 2k3 server standard edition, i got error 404's on every page i tried to load, i then noticed that in the file extention configuration list, .php files where going to E:\PHP\\php5isapi.dll or something similar, the problem was the two back slashes, i'm not sure what their purpose is. After i changed it too one, PHP worked well for about 5 minutes then the Application poop started to crash and a whole new bag of problems fell open, but thats just observation if it helps anyone.
After setting the PHPRC environment variable, none of my PHP files would hit the preprocessor. The browser was just serving out PHP source code right there in the "view source."
The manual was telling me to set this var to "c:\php," but nothing was working. It's almost as if IIS/Win2000 wasn't reading my php.ini at all.
After I set that variable to "c:\php\php.ini," all of a sudden I was getting honest to goodness PHP pages working.
In setting up PHP 5.0.4 + IIS 6 I can concur with vlad at vkelman dot com that setting the environment variable PHPRC is ineffective at telling IIS where to look for php.ini. The only place PHP5 seems to successfully find php.ini is in C:\Windows. Using PHPIniDir with Apache2 works like a charm, however.
PHP 4.3.7.7 and IIS 6 (w2k3 standard)
Followed note from nigel dot salt at hotmail dot com
but had to modify "Script Map" to "ScriptMap"
Also, had to follow note from jimo at mail dot azhsv dot com
after all that - it worked.
WINDOWS 2003 and IIS. BIG LESSON FOR ME was "don't mess with the optional components".
I had lots of trouble until I tried installing without asking for extras and then it was very smooth.
I have found no need to set up paths.
I have found no need to configure IIS.
I have found no need to change security on the PHP folder.
What works for me with Windows/IIS:
1. You need to be logged-on as "administrator"
2. Run "php-5.2.6-win32-installer.msi"
Your ONLY action during this wizard is to select "IIS ISAPI" as the webserver. Do NOT CHANGE anything else! I am guessing that the optional extras apply only to Apache because after enabling them I see Apache-related error messages.
3. Setup a test virtual directory as you would for an ASP or ASP.NET web app. eg "phptest"
Then use notepad to create a test page eg "test.php"
<?php
phpinfo();
?>
4. In Internet Explorer, test with eg this address
http://localhost/phptest/test.php
IF this does not give you a beautiful page of details THEN start reading other advice on this page - especially helpful for me was the faq advice to test run "php.exe -i" from the command prompt.
Fixing 404 (file not found) errors with PHP 5.0.3 and IIS 6.0
IIS 6.0 is installed with security settings that don't permit dynamic content. This means that even if all the hints in the FAQ are paid attention to (.ini modified correctly, security and permissions correct for IUSR_xxx user, etc), you still get 404 errors for all php files.
To fix this: IIS Manager -> expand local computer -> Web Services Extensions -> Add web service or extension -> .php, browse to c:\php\php-cgi.exe or wherever you had the php executable installed. That plus setting the doc_root in the .ini file solved the problem.
--BF
Great WAMP 1.4.4 (Apache 1.*, MySql 4.*, PHP 4.*) installation article at http://www.circaware.com/articles.php?id=2
This article details how to install these onto a USB stick--which means changing *nothing* on the host PC, such as registry entries, environment variables, files in the Windows path, NT services, ini files, etc.
The USB stick install seems awkward, but I installed WAMP to my harddrive using this article as a guide (essentially replacing E:\ with C:\), and it works fine. No more trying to decide where the *real* php.ini or my.ini file is that needs to be changed.