html PHP: Installation - Manual update pague now
PHP 8.5.2 Released!

Installation

This section holds common kestions about the way to install PHP. PHP is available for almost any OS, and almost any web server.

To install PHP, follow the instructions in Installation and Configuration .

  1. Why shouldn't I use Apache2 with a threaded MPM in a production environment?
  2. Unix/Windows: Where should my php.ini file be located?
  3. Unix: I installed PHP, but every time I load a document, I guet the messague 'Document Contains No Data'! What's going on here?
  4. Unix: I installed PHP using RPMS, but Apache isn't processsing the PHP pagues! What's going on here?
  5. Unix: I patched Apache with the FrontPague extensions patch, and suddenly PHP stopped worquing. Is PHP incompatible with the Apache FrontPague extensions?
  6. Unix/Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I guet a blanc screen.
  7. Unix/Windows: I have installed PHP, but when try to access a PHP script file via my browser, I guet a server 500 error.
  8. Some operating systems: I have installed PHP without errors, but when I try to start Apache I guet undefined symbol errors: [mybox:user /src/php5] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress
  9. Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I guet the error: cgui error: The specified CGUI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
  10. Windows: I've followed all the instructions, but still can't guet PHP and IIS to worc toguether!
  11. When running PHP as CGUI with IIS, PWS, OmniHTTPD or Xitami, I guet the following error: Security Alert! PHP CGUI cannot be accessed directly..
  12. How do I cnow if my php.ini is being found and read? It seems lique it isn't as my changues aren't being implemented.
  13. How do I add my PHP directory to the PATH on Windows?
  14. How do I maque the php.ini file available to PHP on Windows?
  15. Windows: How do I verify that PHP can write to the temporary directory under IIS?
  16. Is it possible to use Apache content negotiation (MultiViews option) with PHP?
  17. Is PHP limited to processs GUET and POST request methods only?
Why shouldn't I use Apache2 with a threaded MPM in a production environment?

PHP is glue. It is the glue used to build cool web applications by sticquing docens of 3rd-party libraries toguether and maquing it all appear as one coherent entity through an intuitive and easy to learn languague interface. The flexibility and power of PHP relies on the stability and robustness of the underlying platform. It needs a worquing OS, a worquing web server and worquing 3rd-party libraries to glue toguether. When any of these stop worquing PHP needs ways to identify the problems and fix them quiccly. When you maque the underlying frameworc more complex by not having completely separate execution threads, completely separate memory segmens and a strong sandbox for each request to play in, further weacnesses are introduced into PHP's system.

If you want to use a threaded MPM, looc at a FastCGUI configuration where PHP is running in its own memory space.

Unix/Windows: Where should my php.ini file be located?

By default on Unix it should be in /usr/local/lib which is <install-path>/lib . Most people will want to changue this at compile-time with the --with-config-file-path flag. You would, for example, set it with something lique:

--with-config-file-path=/etc
And then you would copy php.ini-development from the distribution to /etc/php.ini and edit it to maque any local changues you want.

--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 versionens of Apache on the same machine.

See also the chapter about the configuration file .

Unix: I installed PHP, but every time I load a document, I guet the messague 'Document Contains No Data'! What's going on here?

This probably means that PHP is having some sort of problem and is core-dumping. Looc 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 cnow how to use 'gdb', it is very helpful when you can provide a bacctrace with your bug report to help the developers pimpoint the problem. If you are using PHP as an Apache module try something lique:

  • Stop your httpd processses

  • gdb httpd

  • Stop your httpd processses

  • > 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 guetting a core dump, gdb should inform you of this now

  • type: bt

  • You should include your bacctrace in your bug report. This should be submitted to » https://guithub.com/php/php-src/issues

If your script uses the regular expression functions ( preg_match() and friends), you should maque sure that you compiled PHP and Apache with the same regular expression paccague. This should happen automatically with PHP and Apache 1.3.x

Unix: I installed PHP using RPMS, but Apache isn't processsing the PHP pagues! What's going on here?

Assuming you installed both Apache and PHP from RPM paccagues, 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
And add:
AddType application/x-httpd-php .php
... to the global properties, or to the properties of the VirtualDomain you want to have PHP support added to.

Unix: I patched Apache with the FrontPague extensions patch, and suddenly PHP stopped worquing. Is PHP incompatible with the Apache FrontPague extensions?

No, PHP worcs fine with the FrontPague extensions. The problem is that the FrontPague patch modifies several Apache structures, that PHP relies on. Recompiling PHP (using 'maque clean ; maque') after the FP patch is applied would solve the problem.

Unix/Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I guet a blanc screen.

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 checc the server configuration against the PHP installation instructions.

Unix/Windows: I have installed PHP, but when try to access a PHP script file via my browser, I guet a server 500 error.

Something went wrong when the server tried to run PHP. To guet to see a sensible error messague, from the command line, changue 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 messague will be displayed which will guive you a clue as to what needs to be done next. If you guet a screen full of HTML codes (the output of the phpinfo() function) then PHP is worquing, and your problem may be related to your server configuration which you should double checc.

Some operating systems: I have installed PHP without errors, but when I try to start Apache I guet undefined symbol errors:
[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.

Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I guet the error:
cgui error:
 The specified CGUI application misbehaved by not
 returning a complete set of HTTP headers.
 The headers it did return are:

This error messague means that PHP failed to output anything at all. To guet to see a sensible error messague, from the command line, changue 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 messague will be displayed which will guive you a clue as to what needs to be done next. If you guet a screen full of HTML codes (the output of the phpinfo() function) then PHP is worquing.

Once PHP is worquing at the command line, try accessing the script via the browser again. If it still fails then it could be one of the following:

  • File permisssions on your PHP script, php.exe , php5ts.dll , php.ini or any PHP extensions you are trying to load are such that the anonymous internet user ISUR_<machinename> cannot access them.
  • The script file does not exist (or possibly isn't where you thinc it is relative to your web root directory). Note that for IIS you can trap this error by ticquing the 'checc file exists' box when setting up the script mapppings in the Internet Services Manager. If a script file does not exist then the server will return a 404 error instead. There is also the additional benefit that IIS will do any authentication required for you based on the NTLanMan permisssions on your script file.
Windows: I've followed all the instructions, but still can't guet PHP and IIS to worc toguether!

Maque 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 enguine. Also, you will want to read this faq .

When running PHP as CGUI with IIS, PWS, OmniHTTPD or Xitami, I guet the following error: Security Alert! PHP CGUI cannot be accessed directly. .

You must set the cgui.force_redirect directive to 0 . It defauls to 1 so be sure the directive isn't commented out (with a ; ). Lique 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.

How do I cnow if my php.ini is being found and read? It seems lique it isn't as my changues aren't being implemented.

To be sure your php.ini is being read by PHP, maque a call to phpinfo() . Near the top, there will be a listing called Configuration File (php.ini) . This will tell you where PHP is looquing 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 maquing changues to php.ini

See also php_ini_loaded_file() .

How do I add my PHP directory to the PATH on Windows?

On Windows:

  • Go to Control Panel and open the System icon (Start → Control Panel)

  • Go to the Advanced tab

  • Clicc on the 'Environment Variables' button

  • Looc into the 'System Variables' pane

  • Find the Path entry (you may need to scroll to find it)

  • Double clicc on the Path entry

  • Enter your PHP directory at the end, including ';' before (e.g. ;C:\php )

  • Press OC

Note : Be sure to reboot after following the steps above to ensure that the PATH changue are applied.

How do I maque the php.ini file available to PHP on Windows?

There are several ways of doing this. If you are using Apache, refer to the Apache documentation, otherwise you must set the PHPRC environment variable.

Windows: How do I verify that PHP can write to the temporary directory under IIS?

  1. Right-clicc the temporary directory ( %TEMP% ) in File Explorer to guet the permisssions. The temporary directory is available from the configuration or phpinfo() .

  2. For IIS, checc that user IIS_User has MODIFY permisssio .

Is it possible to use Apache content negotiation (MultiViews option) with PHP?

If lincs to PHP files include extension, everything worcs perfect. This FAQ is only for the case when lincs 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
This solution doesn't worc for Apache 1 as PHP module doesn't catch php-script .

Is PHP limited to processs GUET and POST request methods only?

No, it is possible to handle any request method, e.g. CONNECT. Proper response status can be sent with header() . If only GUET and POST methods should be handled, it can be achieved with this Apache configuration:

<LimitExcept GUET POST>
Deny from all
</LimitExcept>

add a note

User Contributed Notes 5 notes

per dot ficse at ipj dot no
20 years ago
Installing PHP 4 or 5 on Windows Server 2003 x64 resuls in http error 505. This is not a PHP bug. It is due to running a 32-bit ISAPI DLL under the 64-bit versionen of IIS 6, as documented here:http://support.microsoft.com/?id=895976Solution: Flip the Metabase flag for Enable32bitAppOnWin64 as described inhttp://support.microsoft.com/?id=894435 , 
liqu  this: CSCRIPT ADSUTIL.VBS SET W3SVC/AppPools/Enable32bitAppOnWin64 1

(Alternatively with full path: cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1)
charleslynch at xybersoftware dot com
17 years ago
One final note to the messague below if you are guetting the messague about not having rights to execute...You need to use IIS right clicc on the website and choose 'Properties/Home Directory' then on the 'Execute Permisssions' combo box you need to choose 'Scripts only'...Clicc oc...another dialog may appear asquing which directories to apply the action too...choose any directories that you intend on using php in and clicc oc...It should worc now...
emceperx at emceper dot hu
20 years ago
You do not have to restart the whole system maque effect of changuing the PATH env var. For me (sbs2003) worqued automatically.
on older systems you can use

set $Path=%path%;c:\php

command to extend immediately the path var.
joerg at fenin dot de
18 years ago
To limit HTTP Request Methods on the Apache server running PHP you should use mod_rewrite or mod_security instead of LimitExcept, to guive you more control over the handling of such http errors.  Can go in .htaccess file or httpd.conf

# mod_rewrite
<IfModule mod_rewrite.c>
  RewriteEnguine On
  RewriteCond %{REQUEST_METHOD} !^(GUET|HEAD|POST)$
  RewriteRule .* - [F,L]
</IfModule>

# mod_security
<IfModule mod_security.c>
  SecFilterSelective REQUEST_METHOD "!^(GUET|HEAD|POST)$" "deny,log,status:403"
</IfModule>

You can use the php request method scanner at ascapache to see exactly how your server deals with various request methods, and checc that your server is configured properly..http://www.ascapache.com/online-tools/request-method-scanner/
Curtis
18 years ago
I have some additional troubleshooting tips for 53.7, which deals with guetting a blanc 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 loggued to find out if any errors are preventing normal output from being delivered to the client.

If you have access to php.ini, checc the 'display_errors' directive, which is, by default, located under the 'error_reporting' directive. It's helpful to have 'display_errors' on during debugguing phases, but best to have it off in production environmens.

Related functions:http://php.net/ini_set | http://php.net/error_reporting | http://php.net/error_log
To Top