cvs: php-src(PHP_4_4) / INSTALL /win32 install.txt

From: Date: Fri, 20 Apr 2007 14:18:19 +0000
Subject: cvs: php-src(PHP_4_4) / INSTALL /win32 install.txt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-44007@lists.php.net to get a copy of this message
nlopess Fri Apr 20 14:18:19 2007 UTC Modified files: (Branch: PHP_4_4) /php-src INSTALL /php-src/win32 install.txt Log: update install instructions (auto-generated from phpdoc XML sources)

http://cvs.php.net/viewvc.cgi/php-src/INSTALL?r1=1.25.4.4&r2=1.25.4.4.2.1&diff_format=u Index: php-src/INSTALL diff -u php-src/INSTALL:1.25.4.4 php-src/INSTALL:1.25.4.4.2.1 --- php-src/INSTALL:1.25.4.4 Wed Mar 30 13:15:33 2005 +++ php-src/INSTALL Fri Apr 20 14:18:19 2007 @@ -1,6 +1,5 @@ - Installing PHP - _________________________________________________________________ + __________________________________________________________________ Table of Contents Preface @@ -12,15 +11,16 @@ Caudium fhttpd related notes Sun, iPlanet and Netscape servers on Sun Solaris - CGI and commandline setups + CGI and command line setups HP-UX specific installation notes OpenBSD installation notes Solaris specific installation tips - Gentoo installation notes + Debian GNU/Linux installation notes 3. Installation on Mac OS X Using Packages + Using the bundled PHP Compiling for OS X Server Compiling for MacOS X Client @@ -29,7 +29,7 @@ Introduction to PECL Installations Downloading PECL extensions PECL for Windows users - Compiling shared PECL extensions with PEAR + Compiling shared PECL extensions with the pecl command Compiling shared PECL extensions with phpize Compiling PECL extensions statically into PHP @@ -43,14 +43,16 @@ The configuration file How to change configuration settings - _________________________________________________________________ + + 7. Installation FAQ + __________________________________________________________________ Preface - These installation instructions were generated from the HTML version - of the PHP Manual so formatting and linking have been altered. See the + These installation instructions were generated from the HTML version of + the PHP Manual so formatting and linking have been altered. See the online and updated version at: http://php.net/install.unix - _________________________________________________________________ + __________________________________________________________________ Chapter 1. General Installation Considerations @@ -58,9 +60,9 @@ want to use PHP for. There are three main fields you can use PHP, as described in the What can PHP do? section: - * Server-side scripting + * Websites and web applications (server-side scripting) * Command line scripting - * Client-side GUI applications + * Desktop (GUI) applications For the first and most common form, you need three things: PHP itself, a web server and a web browser. You probably already have a web @@ -70,39 +72,39 @@ set up anything on your own, only write your PHP scripts, upload it to the server you rent, and see the results in your browser. - While setting up the server and PHP on your own, you have two choices - for the method of connecting PHP to the server. For many servers PHP - has a direct module interface (also called SAPI). These servers - include Apache, Microsoft Internet Information Server, Netscape and - iPlanet servers. Many other servers have support for ISAPI, the + In case of setting up the server and PHP on your own, you have two + choices for the method of connecting PHP to the server. For many + servers PHP has a direct module interface (also called SAPI). These + servers include Apache, Microsoft Internet Information Server, Netscape + and iPlanet servers. Many other servers have support for ISAPI, the Microsoft module interface (OmniHTTPd for example). If PHP has no module support for your web server, you can always use it as a CGI or FastCGI processor. This means you set up your server to use the CGI executable of PHP to process all PHP file requests on the server. If you are also interested to use PHP for command line scripting (e.g. - write scripts autogenerating some images for you offline, or - processing text files depending on some arguments you pass to them), - you always need the command line executable. For more information, - read the section about writing command line PHP applications. In this - case, you need no server and no browser. + write scripts autogenerating some images for you offline, or processing + text files depending on some arguments you pass to them), you always + need the command line executable. For more information, read the + section about writing command line PHP applications. In this case, you + need no server and no browser. With PHP you can also write desktop GUI applications using the PHP-GTK extension. This is a completely different approach than writing web - pages, as you do not output any HTML, but manage windows and objects + pages, as you do not output any HTML, but manage Windows and objects within them. For more information about PHP-GTK, please visit the site dedicated to this extension. PHP-GTK is not included in the official PHP distribution. From now on, this section deals with setting up PHP for web servers on - Unix and Windows with server module interfaces and CGI executables. - You will also find information on the command line executable in the + Unix and Windows with server module interfaces and CGI executables. You + will also find information on the command line executable in the following sections. PHP source code and binary distributions for Windows can be found at http://www.php.net/downloads.php. We recommend you to choose a mirror nearest to you for downloading the distributions. - _________________________________________________________________ + __________________________________________________________________ Chapter 2. Installation on Unix systems @@ -119,14 +121,14 @@ There are several ways to install PHP for the Unix platform, either with a compile and configure process, or through various pre-packaged methods. This documentation is mainly focused around the process of - compiling and configuring PHP. Many Unix like systems have some sort - of package installation system. This can assist in setting up a - standard configuration, but if you need to have a different set of - features (such as a secure server, or a different database driver), - you may need to build PHP and/or your webserver. If you are unfamiliar - with building and compiling your own software, it is worth checking to - see whether somebody has already built a packaged version of PHP with - the features you need. + compiling and configuring PHP. Many Unix like systems have some sort of + package installation system. This can assist in setting up a standard + configuration, but if you need to have a different set of features + (such as a secure server, or a different database driver), you may need + to build PHP and/or your web server. If you are unfamiliar with + building and compiling your own software, it is worth checking to see + whether somebody has already built a packaged version of PHP with the + features you need. Prerequisite knowledge and software for compiling: @@ -138,7 +140,7 @@ * Any module specific components (such as gd, pdf libs, etc.) The initial PHP setup and configuration process is controlled by the - use of the commandline options of the configure script. You could get + use of the command line options of the configure script. You could get a list of all available options along with short explanations running ./configure --help. Our manual documents the different options separately. You will find the core options in the appendix, while the @@ -146,15 +148,15 @@ pages. When PHP is configured, you are ready to build the module and/or - executables. The command make should take care of this. If it fails - and you can't figure out why, see the Problems section. - _________________________________________________________________ + executables. The command make should take care of this. If it fails and + you can't figure out why, see the Problems section. + __________________________________________________________________ Apache 1.3.x on Unix systems This section contains notes and hints specific to Apache installs of - PHP on Unix platforms. We also have instructions and notes for Apache - 2 on a separate page. + PHP on Unix platforms. We also have instructions and notes for Apache 2 + on a separate page. You can select arguments to add to the configure on line 10 below from the list of core configure options and from extension specific options @@ -164,7 +166,7 @@ your files. Example 2-1. Installation Instructions (Apache Shared Module Version) - for PHP + for PHP 1. gunzip apache_xxx.tar.gz 2. tar -xvf apache_xxx.tar 3. gunzip php-xxx.tar.gz @@ -248,36 +250,38 @@ Alternatively, to install PHP as a static object: Example 2-2. Installation Instructions (Static Module Installation for - Apache) for PHP + Apache) for PHP 1. gunzip -c apache_1.3.x.tar.gz | tar xf - 2. cd apache_1.3.x 3. ./configure 4. cd .. -5. gunzip -c php-4.x.y.tar.gz | tar xf - -6. cd php-4.x.y +5. gunzip -c php-5.x.y.tar.gz | tar xf - +6. cd php-5.x.y 7. ./configure --with-mysql --with-apache=../apache_1.3.x 8. make 9. make install 10. cd ../apache_1.3.x -11. ./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a - (The above line is correct! Yes, we know libphp4.a does not exist at this +11. ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a + (The above line is correct! Yes, we know libphp5.a does not exist at this stage. It isn't supposed to. It will be created.) 12. make - (you should now have an httpd binary which you can copy to your Apache bin -dir if - is is your first install then you need to "make install" as well) + (you should now have an httpd binary which you can copy to your Apache bin d +ir if + it is your first install then you need to "make install" as well) -13. cd ../php-4.x.y +13. cd ../php-5.x.y 14. cp php.ini-dist /usr/local/lib/php.ini 15. You can edit /usr/local/lib/php.ini file to set PHP options. Edit your httpd.conf or srm.conf file and add: AddType application/x-httpd-php .php + Note: Replace php-5 by php-4 and php5 by php4 in PHP 4. + Depending on your Apache install and Unix variant, there are many possible ways to stop and restart the server. Below are some typical lines used in restarting the server, for different apache/unix @@ -309,41 +313,40 @@ ./configure --with-apxs --with-pgsql - This will create a libphp4.so shared library that is loaded into - Apache using a LoadModule line in Apache's httpd.conf file. The - PostgreSQL support is embedded into this libphp4.so library. + This will create a libphp5.so (or libphp4.so in PHP 4) shared library + that is loaded into Apache using a LoadModule line in Apache's + httpd.conf file. The PostgreSQL support is embedded into this library. ./configure --with-apxs --with-pgsql=shared This will create a libphp4.so shared library for Apache, but it will - also create a pgsql.so shared library that is loaded into PHP either - by using the extension directive in php.ini file or by loading it + also create a pgsql.so shared library that is loaded into PHP either by + using the extension directive in php.ini file or by loading it explicitly in a script using the dl() function. ./configure --with-apache=/path/to/apache_source --with-pgsql - This will create a libmodphp4.a library, a mod_php4.c and some - accompanying files and copy this into the src/modules/php4 directory - in the Apache source tree. Then you compile Apache using - --activate-module=src/modules/php4/libphp4.a and the Apache build - system will create libphp4.a and link it statically into the httpd - binary. The PostgreSQL support is included directly into this httpd - binary, so the final result here is a single httpd binary that - includes all of Apache and all of PHP. + This will create a libmodphp5.a library, a mod_php5.c and some + accompanying files and copy this into the src/modules/php5 directory in + the Apache source tree. Then you compile Apache using + --activate-module=src/modules/php5/libphp5.a and the Apache build + system will create libphp5.a and link it statically into the httpd + binary (replace php5 by php4 in PHP 4). The PostgreSQL support is + included directly into this httpd binary, so the final result here is a + single httpd binary that includes all of Apache and all of PHP. ./configure --with-apache=/path/to/apache_source --with-pgsql=shared - Same as before, except instead of including PostgreSQL support - directly into the final httpd you will get a pgsql.so shared library - that you can load into PHP from either the php.ini file or directly - using dl(). + Same as before, except instead of including PostgreSQL support directly + into the final httpd you will get a pgsql.so shared library that you + can load into PHP from either the php.ini file or directly using dl(). When choosing to build PHP in different ways, you should consider the advantages and drawbacks of each method. Building as a shared object will mean that you can compile apache separately, and don't have to recompile everything as you add to, or change, PHP. Building PHP into apache (static method) means that PHP will load and run faster. For - more information, see the Apache webpage on DSO support. + more information, see the Apache web page on DSO support. Note: Apache's default httpd.conf currently ships with a section that looks like this: @@ -355,11 +358,11 @@ ("Group daemon" is also very common) PHP will not be able to open files. - Note: Make sure you specify the installed version of apxs when - using --with-apxs=/path/to/apxs. You must NOT use the apxs version - that is in the apache sources but the one that is actually - installed on your system. - _________________________________________________________________ + Note: Make sure you specify the installed version of apxs when using + --with-apxs=/path/to/apxs. You must NOT use the apxs version that is + in the apache sources but the one that is actually installed on your + system. + __________________________________________________________________ Apache 2.0 on Unix systems @@ -372,38 +375,36 @@ Use the prefork MPM instead, or use Apache1. For information on why, read the related FAQ entry on using Apache2 with a threaded MPM - You are highly encouraged to take a look at the Apache Documentation - to get a basic understanding of the Apache 2.0 Server. + You are highly encouraged to take a look at the Apache Documentation to + get a basic understanding of the Apache 2.0 Server. PHP and Apache 2.0.x compatibility notes: The following versions of PHP are known to work with the most recent version of Apache 2.0.x: * PHP 4.3.0 or later available at http://www.php.net/downloads.php. * the latest stable development version. Get the source code - http://snaps.php.net/php4-latest.tar.gz or download binaries for - Windows http://snaps.php.net/win32/php4-win32-latest.zip. + http://snaps.php.net/php5-latest.tar.gz or download binaries for + Windows http://snaps.php.net/win32/php5-win32-latest.zip. * a prerelease version downloadable from http://qa.php.net/. * you have always the option to obtain PHP through anonymous CVS. These versions of PHP are compatible to Apache 2.0.40 and later. - Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works - with Apache 2.0.39, don't use any other version of Apache with PHP - 4.2.3. However, the recommended setup is to use PHP 4.3.0 or later - with the most recent version of Apache2. + Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works with + Apache 2.0.39, don't use any other version of Apache with PHP 4.2.3. + However, the recommended setup is to use PHP 4.3.0 or later with the + most recent version of Apache2. All mentioned versions of PHP will work still with Apache 1.3.x. Download the most recent version of Apache 2.0 and a fitting PHP version from the above mentioned places. This quick guide covers only - the basics to get started with Apache 2.0 and PHP. For more - information read the Apache Documentation. The version numbers have - been omitted here, to ensure the instructions are not incorrect. You - will need to replace the 'NN' here with the correct values from your - files. + the basics to get started with Apache 2.0 and PHP. For more information + read the Apache Documentation. The version numbers have been omitted + here, to ensure the instructions are not incorrect. You will need to + replace the 'NN' here with the correct values from your files. - Example 2-4. Installation Instructions (Apache 2 Shared Module - Version) + Example 2-4. Installation Instructions (Apache 2 Shared Module Version) 1. gzip -d httpd-2_0_NN.tar.gz 2. tar xvf httpd-2_0_NN.tar 3. gunzip php-NN.tar.gz @@ -461,11 +462,11 @@ For PHP 4: - LoadModule php4_module libexec/libphp4.so + LoadModule php4_module modules/libphp4.so For PHP 5: - LoadModule php5_module libexec/libphp5.so + LoadModule php5_module modules/libphp5.so 15. Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse the .php extension as PHP. You could @@ -486,12 +487,12 @@ Following the steps above you will have a running Apache 2.0 with support for PHP as SAPI module. Of course there are many more configuration options available for both, Apache and PHP. For more - information use ./configure --help in the corresponding source tree. - In case you wish to build a multithreaded version of Apache 2.0 you - must overwrite the standard MPM-Module prefork either with worker or - perchild. To do so append to your configure line in step 6 above - either the option --with-mpm=worker or --with-mpm=perchild. Take care - about the consequences and understand what you are doing. For more + information use ./configure --help in the corresponding source tree. In + case you wish to build a multithreaded version of Apache 2.0 you must + overwrite the standard MPM-Module prefork either with worker or + perchild. To do so append to your configure line in step 6 above either + the option --with-mpm=worker or --with-mpm=perchild. Take care about + the consequences and understand what you are doing. For more information read the Apache documentation about the MPM-Modules. Note: If you want to use content negotiation, read the Apache @@ -502,7 +503,7 @@ Zend Thread Safety (ZTS). Therefore not all extensions might be available. The recommended setup is to build Apache with the standard prefork MPM-Module. - _________________________________________________________________ + __________________________________________________________________ Caudium @@ -539,7 +540,7 @@ that the normal MySQL client code is used. Otherwise there might be conflicts if your Pike already has MySQL support. You do this by specifying a MySQL install directory the --with-mysql option. - _________________________________________________________________ + __________________________________________________________________ fhttpd related notes @@ -551,24 +552,24 @@ capability. Note: Support for fhttpd is no longer available as of PHP 4.3.0. - _________________________________________________________________ + __________________________________________________________________ Sun, iPlanet and Netscape servers on Sun Solaris This section contains notes and hints specific to Sun Java System Web - Server, Sun ONE Web Server, iPlanet and Netscape server installs of - PHP on Sun Solaris. + Server, Sun ONE Web Server, iPlanet and Netscape server installs of PHP + on Sun Solaris. From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to generate custom directory listings and error pages. Additional functions for Apache compatibility are also available. For support in - current webservers read the note about subrequests. + current web servers read the note about subrequests. You can find more information about setting up PHP for the Netscape Enterprise Server (NES) here: http://benoit.noss.free.fr/php/install-php4.html - To build PHP with Sun JSWS/Sun ONE WS/iPlanet/Netscape webservers, + To build PHP with Sun JSWS/Sun ONE WS/iPlanet/Netscape web servers, enter the proper install directory for the --with-nsapi=[DIR] option. The default directory is usually /opt/netscape/suitespot/. Please also read /php-xxx-version/sapi/nsapi/nsapi-readme.txt. @@ -594,9 +595,9 @@ 4). 4. tar xvf php-x.x.x.tar 5. Change to your extracted PHP directory: cd ../php-x.x.x - 6. For the following step, make sure /opt/netscape/suitespot/ is - where your netscape server is installed. Otherwise, change to the - correct path and run: + 6. For the following step, make sure /opt/netscape/suitespot/ is where + your netscape server is installed. Otherwise, change to the correct + path and run: ./configure --with-mysql=/usr/local/mysql \ --with-nsapi=/opt/netscape/suitespot/ \ @@ -610,7 +611,7 @@ Configuration Instructions for Sun/iPlanet/Netscape. Firstly you may need to add some paths to the LD_LIBRARY_PATH environment for the server to find all the shared libs. This can best done in the start - script for your webserver. The start script is often located in: + script for your web server. The start script is often located in: /path/to/server/https-servername/start. You may also need to edit the configuration files that are located in: /path/to/server/https-servername/config/. @@ -621,17 +622,17 @@ type=magnus-internal/x-httpd-php exts=php 2. Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6) - and add the following, shlib will vary depending on your system, - it will be something like /opt/netscape/suitespot/bin/libphp4.so. - You should place the following lines after mime types init. - -Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="/o -pt/netscape/suitespot/bin/libphp4.so" -Init fn="php4_init" LateInit="yes" errorString="Failed to initialize PHP!" [php -_ini="/path/to/php.ini"] + and add the following, shlib will vary depending on your system, it + will be something like /opt/netscape/suitespot/bin/libphp4.so. You + should place the following lines after mime types init. + +Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="/op +t/netscape/suitespot/bin/libphp4.so" +Init fn="php4_init" LateInit="yes" errorString="Failed to initialize PHP!" [php_ +ini="/path/to/php.ini"] (PHP >= 4.3.3) The php_ini parameter is optional but with it you - can place your php.ini in your webserver config directory. + can place your php.ini in your web server config directory. 3. Configure the default object in obj.conf (for virtual server classes [version 6.0+] in their vserver.obj.conf): @@ -639,10 +640,10 @@ . . . -.#NOTE this next line should happen after all 'ObjectType' and before all 'AddL -og' lines -Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inik -ey=value ...] +.#NOTE this next line should happen after all 'ObjectType' and before all 'AddLo +g' lines +Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inike +y=value ...] . . </Object> @@ -665,8 +666,8 @@ server and assign it the style x-httpd-php. All files in it will get executed as PHP. This is nice to hide PHP usage by renaming files to .html. - 5. Setup of authentication: PHP authentication cannot be used with - any other authentication. ALL AUTHENTICATION IS PASSED TO YOUR PHP + 5. Setup of authentication: PHP authentication cannot be used with any + other authentication. ALL AUTHENTICATION IS PASSED TO YOUR PHP SCRIPT. To configure PHP Authentication for the entire server, add the following line to your default object: @@ -677,39 +678,37 @@ . </Object> - 6. To use PHP Authentication on a single directory, add the - following: + 6. To use PHP Authentication on a single directory, add the following: <Object ppath="d:\path\to\authenticated\dir\*"> AuthTrans fn=php4_auth_trans </Object> Note: The stacksize that PHP uses depends on the configuration of - the webserver. If you get crashes with very large PHP scripts, it + the web server. If you get crashes with very large PHP scripts, it is recommended to raise it with the Admin Server (in the section "MAGNUS EDITOR"). - _________________________________________________________________ + __________________________________________________________________ CGI environment and recommended modifications in php.ini Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE WS/iPlanet/Netscape is a multithreaded web server. Because of that all - requests are running in the same process space (the space of the - webserver itself) and this space has only one environment. If you want - to get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the - correct way to try this in the old PHP 3.x way with getenv() or a - similar way (register globals to environment, $_ENV). You would only - get the environment of the running webserver without any valid CGI - variables! + requests are running in the same process space (the space of the web + server itself) and this space has only one environment. If you want to + get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the correct + way to try this in the old PHP 3.x way with getenv() or a similar way + (register globals to environment, $_ENV). You would only get the + environment of the running web server without any valid CGI variables! Note: Why are there (invalid) CGI variables in the environment? - Answer: This is because you started the webserver process from the - admin server which runs the startup script of the webserver, you + Answer: This is because you started the web server process from the + admin server which runs the startup script of the web server, you wanted to start, as a CGI script (a CGI script inside of the admin - server!). This is why the environment of the started webserver has + server!). This is why the environment of the started web server has some CGI environment variables in it. You can test this by starting - the webserver not from the administration server. Use the command + the web server not from the administration server. Use the command line as root user and start it manually - you will see there are no CGI-like environment variables. @@ -720,15 +719,15 @@ it, because you do not need the environment here): variables_order = "GPCS" register_globals = On - _________________________________________________________________ + __________________________________________________________________ Special use for error pages or self-made directory listings (PHP >= 4.3.3) You can use PHP to generate the error pages for "404 Not Found" or similar. Add the following line to the object in obj.conf for every error page you want to overwrite: -Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value ini -key=value...] +Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inik +ey=value...] where XXX is the HTTP error code. Please delete any other Error directives which could interfere with yours. If you want to place a @@ -737,32 +736,32 @@ Another possibility is to generate self-made directory listings. Just create a PHP script which displays a directory listing and replace the - corresponding default Service line for - type="magnus-internal/directory" in obj.conf with the following: -Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scr -ipt.php" [inikey=value inikey=value...] + corresponding default Service line for type="magnus-internal/directory" + in obj.conf with the following: +Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scri +pt.php" [inikey=value inikey=value...] For both error and directory listing pages the original URI and translated URI are in the variables $_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED']. - _________________________________________________________________ + __________________________________________________________________ Note about nsapi_virtual() and subrequests (PHP >= 4.3.3) The NSAPI module now supports the nsapi_virtual() function (alias: - virtual()) to make subrequests on the webserver and insert the result - in the webpage. This function uses some undocumented features from the + virtual()) to make subrequests on the web server and insert the result + in the web page. This function uses some undocumented features from the NSAPI library. On Unix the module automatically looks for the needed functions and uses them if available. If not, nsapi_virtual() is disabled. Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!! - _________________________________________________________________ + __________________________________________________________________ -CGI and commandline setups +CGI and command line setups - The default is to build PHP as a CGI program. This creates a - commandline interpreter, which can be used for CGI processing, or for + The default is to build PHP as a CGI program. This creates a command + line interpreter, which can be used for CGI processing, or for non-web-related PHP scripting. If you are running a web server PHP has module support for, you should generally go for that solution for performance reasons. However, the CGI version enables users to run @@ -780,15 +779,15 @@ and this is described in detail in the manual section named Using PHP from the command line. For further details please read that section of the manual. - _________________________________________________________________ + __________________________________________________________________ Testing If you have built PHP as a CGI program, you may test your build by - typing make test. It is always a good idea to test your build. This - way you may catch a problem with PHP on your platform early instead of + typing make test. It is always a good idea to test your build. This way + you may catch a problem with PHP on your platform early instead of having to struggle with it later. - _________________________________________________________________ + __________________________________________________________________ Benchmarking @@ -801,86 +800,41 @@ configuration file. Note: make bench is only available for PHP 3. - _________________________________________________________________ + __________________________________________________________________ Using Variables Some server supplied environment variables are not defined in the - current CGI/1.1 specification. Only the following variables are - defined there: AUTH_TYPE, CONTENT_LENGTH, CONTENT_TYPE, - GATEWAY_INTERFACE, PATH_INFO, PATH_TRANSLATED, QUERY_STRING, - REMOTE_ADDR, REMOTE_HOST, REMOTE_IDENT, REMOTE_USER, REQUEST_METHOD, - SCRIPT_NAME, SERVER_NAME, SERVER_PORT, SERVER_PROTOCOL, and - SERVER_SOFTWARE. Everything else should be treated as 'vendor - extensions'. - _________________________________________________________________ + current CGI/1.1 specification. Only the following variables are defined + there: AUTH_TYPE, CONTENT_LENGTH, CONTENT_TYPE, GATEWAY_INTERFACE, + PATH_INFO, PATH_TRANSLATED, QUERY_STRING, REMOTE_ADDR, REMOTE_HOST, + REMOTE_IDENT, REMOTE_USER, REQUEST_METHOD, SCRIPT_NAME, SERVER_NAME, + SERVER_PORT, SERVER_PROTOCOL, and SERVER_SOFTWARE. Everything else + should be treated as 'vendor extensions'. + __________________________________________________________________ HP-UX specific installation notes This section contains notes and hints specific to installing PHP on - HP-UX systems. (Contributed by paul_mckay at clearwater-it dot co dot - uk). - - Note: These tips were written for PHP 4.0.4 and Apache 1.3.9. - - 1. You need gzip, download a binary distribution from - http://hpux.connect.org.uk/ftp/hpux/Gnu/gzip-1.2.4a/gzip-1.2.4a-sd - -10.20.depot.Z uncompress the file and install using swinstall. - 2. You need gcc, download a binary distribution from - http://gatekeep.cs.utah.edu/ftp/hpux/Gnu/gcc-2.95.2/gcc-2.95.2-sd- - 10.20.depot.gz. uncompress this file and install gcc using - swinstall. - 3. You need the GNU binutils, you can download a binary distribution - from - http://hpux.connect.org.uk/ftp/hpux/Gnu/binutils-2.9.1/binutils-2. - 9.1-sd-10.20.depot.gz. uncompress this file and install binutils - using swinstall. - 4. You now need bison, you can download a binary distribution from - http://hpux.connect.org.uk/ftp/hpux/Gnu/bison-1.28/bison-1.28-sd-1 - 0.20.depot.gz, install as above. - 5. You now need flex, you need to download the source from one of the - http://www.gnu.org mirrors. It is in the non-gnu directory of the - ftp site. Download the file, gunzip, then tar -xvf it. Go into the - newly created flex directory and run ./configure, followed by - make, and then make install. - If you have errors here, it's probably because gcc etc. are not in - your PATH so add them to your PATH. - 6. Download the PHP and apache sources. - 7. gunzip and tar -xvf them. We need to hack a couple of files so - that they can compile OK. - 8. Firstly the configure file needs to be hacked because it seems to - lose track of the fact that you are a hpux machine, there will be - a better way of doing this but a cheap and cheerful hack is to put - lt_target=hpux10.20 on line 47286 of the configure script. - 9. Next, the Apache GuessOS file needs to be hacked. Under - apache_1.3.9/src/helpers change line 89 from echo - "hp${HPUXMACH}-hpux${HPUXVER}"; exit 0 to: echo - "hp${HPUXMACH}-hp-hpux${HPUXVER}"; exit 0 - 10. You cannot install PHP as a shared object under HP-UX so you must - compile it as a static, just follow the instructions at the Apache - page. - 11. PHP and Apache should have compiled OK, but Apache won't start. - you need to create a new user for Apache, e.g. www, or apache. You - then change lines 252 and 253 of the conf/httpd.conf in Apache so - that instead of - -User nobody -Group nogroup + HP-UX systems. - you have something like + There are two main options for installing PHP on HP-UX systems. Either + compile it, or install a pre-compiled binary. -User www -Group sys + Official pre-compiled packages are located here: + http://software.hp.com/ - This is because you can't run Apache as nobody under hp-ux. Apache - and PHP should then work. - _________________________________________________________________ + Until this manual section is rewritten, the documentation about + compiling PHP (and related extensions) on HP-UX systems has been + removed. For now, consider reading the following external resource: + Building Apache and PHP on HP-UX 11.11 + __________________________________________________________________ OpenBSD installation notes This section contains notes and hints specific to installing PHP on OpenBSD 3.6. - _________________________________________________________________ + __________________________________________________________________ Using Binary Packages @@ -914,7 +868,7 @@ Read the packages(7) manual page for more information about binary packages on OpenBSD. - _________________________________________________________________ + __________________________________________________________________ Using Ports @@ -925,7 +879,7 @@ PHP modules. If you find you do not want to create some of these modules, use the no_* FLAVOR. For example, to skip building the imap module, set the FLAVOR to no_imap. - _________________________________________________________________ + __________________________________________________________________ Common Problems @@ -940,28 +894,26 @@ automatically installs into the correct chroot directories, so no special modification is needed there. More information on the OpenBSD Apache is available in the OpenBSD FAQ. - * The OpenBSD 3.6 package for the gd extension requires XFree86 to - be installed. If you do not wish to use some of the font features - that require X11, install the php4-gd-4.3.8-no_x11.tgz package - instead. - _________________________________________________________________ + * The OpenBSD 3.6 package for the gd extension requires XFree86 to be + installed. If you do not wish to use some of the font features that + require X11, install the php4-gd-4.3.8-no_x11.tgz package instead. + __________________________________________________________________ Older Releases Older releases of OpenBSD used the FLAVORS system to compile up a statically linked PHP. Since it is hard to generate binary packages using this method, it is now deprecated. You can still use the old - stable ports trees if you wish, but they are unsupported by the - OpenBSD team. If you have any comments about this, the current - maintainer for the port is Anil Madhavapeddy (avsm at openbsd dot - org). - _________________________________________________________________ + stable ports trees if you wish, but they are unsupported by the OpenBSD + team. If you have any comments about this, the current maintainer for + the port is Anil Madhavapeddy (avsm at openbsd dot org). + __________________________________________________________________ Solaris specific installation tips This section contains notes and hints specific to installing PHP on Solaris systems. - _________________________________________________________________ + __________________________________________________________________ Required software @@ -984,142 +936,255 @@ In addition, you will need to install (and possibly compile) any additional software specific to your configuration, such as Oracle or MySQL. - _________________________________________________________________ + __________________________________________________________________ Using Packages - You can simplify the Solaris install process by using pkgadd to - install most of your needed components. - _________________________________________________________________ + You can simplify the Solaris install process by using pkgadd to install + most of your needed components. + __________________________________________________________________ -Gentoo installation notes +Debian GNU/Linux installation notes This section contains notes and hints specific to installing PHP on - Gentoo Linux. - _________________________________________________________________ + Debian GNU/Linux. + __________________________________________________________________ -Using Portage (emerge) +Using APT While you can just download the PHP source and compile it yourself, - using Gentoo's packaging system is the simplest and cleanest method of + using Debian's packaging system is the simplest and cleanest method of installing PHP. If you are not familiar with building software on Linux, this is the way to go. - If you have built your Gentoo system so far, you are probably used to - Portage already. Installing Apache and PHP is no different than the - other system tools. - The first decision you need to make is whether you want to install - Apache 1.3.x or Apache 2.x. While both can be used with PHP, the steps - given below will use Apache 1.3.x. Another thing to consider is - whether your local Portage tree is up to date. If you have not updated - it recently, you need to run emerge sync before anything else. This - way, you will be using the most recent stable version of Apache and - PHP. + Apache 1.3.x or Apache 2.x. The corresponding PHP packages are + respectively named libapache-mod-php* and libapache2-mod-php*. The + steps given below will use Apache 1.3.x. Please note that, as of this + writing, there is no official Debian packages of PHP 5. Then the steps + given below will install PHP 4. + + PHP is available in Debian as CGI or CLI flavour too, named + respectively php4-cgi and php4-cli. If you need them, you'll just have + to reproduce the following steps with the good package names. Another + special package you'd want to install is php4-pear. It contains a + minimal PEAR installation and the pear commandline utility. + + If you need more recent packages of PHP than the Debian's stable ones + or if some PHP modules lacks the Debian official repository, perhaps + you should take a look at http://www.apt-get.org/. One of the results + found should be Dotdeb. This unofficial repository is maintained by + Guillaume Plessis and contains Debian packages of the most recent + versions of PHP 4 and PHP 5. To use it, just add the to following two + lines to your /etc/apt/sources.lists and run apt-get update : + + Example 2-7. The two Dotdeb related lines +deb http://packages.dotdeb.org stable all +deb-src http://packages.dotdeb.org stable all + + The last thing to consider is whether your list of packages is up to + date. If you have not updated it recently, you need to run apt-get + update before anything else. This way, you will be using the most + recent stable version of the Apache and PHP packages. Now that everything is in place, you can use the following example to install Apache and PHP: - Example 2-7. Gentoo Install Example with Apache 1.3 -# emerge \<apache-2 -# USE="-*" emerge php mod_php -# ebuild /var/db/pkg/dev-php/mod_php-<your PHP version>/mod_php-<your PHP versi -on>.ebuild config -# nano /etc/conf.d/apache - Add "-D PHP4" to APACHE_OPTS - -# rc-update add apache default -# /etc/init.d/apache start + Example 2-8. Debian Install Example with Apache 1.3 + # apt-get install libapache-mod-php4 - You can read more about emerge in the excellent Portage Manual - provided on the Gentoo website. + APT will automatically install the PHP 4 module for Apache 1.3, and all + its dependencies and then activate it. If you're not asked to restart + Apache during the install process, you'll have to do it manually : - If you need to use Apache 2, you can simply use emerge apache in the - last example. - _________________________________________________________________ + Example 2-9. Stopping and starting Apache once PHP 4 is installed +# /etc/init.d/apache stop +# /etc/init.d/apache start + __________________________________________________________________ Better control on configuration - In the last section, PHP was emerged without any activated modules. As - of this writing, the only module activated by default with Portage is - XML which is needed by PEAR. This may not be what you want and you - will soon discover that you need more activated modules, like MySQL, - gettext, GD, etc. - - When you compile PHP from source yourself, you need to activate - modules via the configure command. With Gentoo, you can simply provide - USE flags which will be passed to the configure script automatically. - To see which USE flags to use with emerge, you can try: - - Example 2-8. Getting the list of valid USE flags -# USE="-*" emerge -pv php - -[ebuild N ] dev-php/php-4.3.6-r1 -X -berkdb -crypt -curl -debug -doc --fdftk -firebird -flash -freetds -gd -gd-external -gdbm -gmp -hardenedphp --imap -informix -ipv6 -java -jpeg -kerberos -ldap -mcal -memlimit -mssql --mysql -ncurses -nls -oci8 -odbc -pam -pdflib -png -postgres -qt -readline --snmp -spell -ssl -tiff -truetype -xml2 -yaz 3,876 kB - - As you can see from the last output, PHP considers a lot of USE flags. - Look at them closely and choose what you need. If you choose a flag - and you do not have the proper libraries, Portage will compile them - for you. It is a good idea to use emerge -pv again to see what Portage - will compile in accordance to your USE flags. As an example, if you do - not have X installed and you choose to include X in the USE flags, - Portage will compile X prior to PHP, which can take a couple of hours. - - If you choose to compile PHP with MySQL, cURL and GD support, the - command will look something like this: - - Example 2-9. Install PHP with USE flags - # USE="-* curl mysql gd" emerge php mod_php - - As in the last example, do not forget to emerge php as well as - mod_php. php is responsible for the command line version of PHP as - mod_php is for the Apache module version of PHP. - _________________________________________________________________ + In the last section, PHP was installed with only core modules. This may + not be what you want and you will soon discover that you need more + activated modules, like MySQL, cURL, GD, etc. + + When you compile PHP from source yourself, you need to activate modules + via the configure command. With APT, you just have to install + additional packages. They're all named 'php4-*' (or 'php5-*' if you + installed PHP 5 from a third party repository). + + Example 2-10. Getting the list of PHP additional packages + # dpkg -l 'php4-*' + + As you can see from the last output, there's a lot of PHP modules that + you can install (excluding the php4-cgi, php4-cli or php4-pear special + packages). Look at them closely and choose what you need. If you choose + a module and you do not have the proper libraries, APT will + automatically install all the dependencies for you. + + If you choose to add the MySQL, cURL and GD support to PHP the command + will look something like this: + + Example 2-11. Install PHP with MySQL, cURL and GD + # apt-get install php4-mysql php4-curl php4-gd + + APT will automatically add the appropriate lines to your different + php.ini (/etc/php4/apache/php.ini, /etc/php4/cgi/php.ini, etc). + + Example 2-12. These lines activate MySQL, cURL and GD into PHP +extension=mysql.so +extension=curl.so +extension=gd.so + + You'll only have to stop/start Apache as previously to activate the + modules. + __________________________________________________________________ Common Problems * If you see the PHP source instead of the result the script should - produce, you have probably forgot to edit /etc/conf.d/apache. - Apache needs to be started with the -D PHP4 flag. To see if the - flag is present, you should be able to see it when using ps ax | - grep apache while Apache is running. - * Due to slotting problems, you might end up with more than one - version of PHP installed on your system. If this is the case, you - need to unmerge the old versions manually by using emerge unmerge - mod_php-<old version>. - * If you cannot emerge PHP because of Java, try putting -* in front - of your USE flags like in the above examples. - * If you are having problems configuring Apache and PHP, you can - always search the Gentoo Forums. Try searching with the keywords - "Apache PHP". - _________________________________________________________________ + produce, APT has probably not included /etc/apache/conf.d/php4 in + your Apache 1.3 configuration. Please ensure that the following + line is present in your /etc/apache/httpd.conf file then stop/start + Apache: + + Example 2-13. This line activates PHP 4 into Apache +# Include /etc/apache/conf.d/ + + * If you installed an additional module and if its functions are not + available in your scripts, please ensure that the appropriate line + is present in your php.ini, as seen before. APT may fail during the + installation of the additional module, due to a confusing debconf + configuration. + __________________________________________________________________ Chapter 3. Installation on Mac OS X - This section contains notes and hints specific to installing PHP on - Mac OS X. There are two slightly different versions of Mac OS X, - Client and Server, our manual deals with installing PHP on both - systems. Note that PHP is not available for MacOS 9 and earlier - versions. - _________________________________________________________________ + This section contains notes and hints specific to installing PHP on Mac + OS X. There are two slightly different versions of Mac OS X, Client and + Server, our manual deals with installing PHP on both systems. Note that + PHP is not available for MacOS 9 and earlier versions. + __________________________________________________________________ Using Packages There are a few pre-packaged and pre-compiled versions of PHP for Mac OS X. This can help in setting up a standard configuration, but if you - need to have a different set of features (such as a secure server, or - a different database driver), you may need to build PHP and/or your - web server yourself. If you are unfamiliar with building and compiling - your own software, it's worth checking whether somebody has already - built a packaged version of PHP with the features you need. - _________________________________________________________________ + need to have a different set of features (such as a secure server, or a + different database driver), you may need to build PHP and/or your web + server yourself. If you are unfamiliar with building and compiling your + own software, it's worth checking whether somebody has already built a + packaged version of PHP with the features you need. + + The following resources offer easy to install packages and precompiled + binaries for PHP on Mac OS: + + * Darwin: http://darwinports.opendarwin.org/ + * Entropy: http://www.entropy.ch/software/macosx/php/ + * Fink: http://fink.sourceforge.net/ + __________________________________________________________________ + +Using the bundled PHP + + PHP has come standard with Macs since OS X version 10.0.0. Enabling PHP + with the default web server requires uncommenting a few lines in the + Apache configuration file httpd.conf whereas the CGI and/or CLI are + enabled by default (easily accessible via the Terminal program). + + Enabling PHP using the instructions below is meant for quickly setting + up a local development environment. It's highly recommended to always + upgrade PHP to the newest version. Like most live software, newer + versions are created to fix bugs and add features and PHP being is no + different. See the appropriate MAC OS X installation documentation for + further details. The following instructions are geared towards a + beginner with details provided for getting a default setup to work. All + users are encouraged to compile, or install a new packaged version. + + The standard installation type is using mod_php, and enabling the + bundled mod_php on Mac OS X for the Apache web server (the default web + server, that is accessible via System Preferences) involves the + following steps: + + 1. Locate and open the Apache configuration file. By default, the + location is as follows: /etc/httpd/httpd.conf + Using Finder or Spotlight to find this file may prove difficult as + by default it's private and owned by the root user. + + Note: One way to open this is by using a Unix based text editor in + the Terminal, for example nano, and because the file is owned by + root we'll use the sudo command to open it (as root) so for example + type the following into the Terminal Application (after, it will + prompt for a password): sudo nano /etc/httpd/httpd.conf + Noteworthy nano commands: ^w (search), ^o (save), and ^x (exit) + where ^ represents the Ctrl key. + 2. With a text editor, uncomment the lines (by removing the #) that + look similar to the following (these two lines are often not + together, locate them both in the file): + +# LoadModule php4_module libexec/httpd/libphp4.so + +# AddModule mod_php4.c + + Notice the location/path. When building PHP in the future, the + above files should be replaced or commented out. + 3. Be sure the desired extensions will parse as PHP (examples: .php + .html and .inc) + Due to the following statement already existing in httpd.conf (as + of Mac Panther), once PHP is enabled the .php files will + automatically parse as PHP. + +<IfModule mod_php4.c> + # If php is turned on, we respect .php and .phps files. + AddType application/x-httpd-php .php + AddType application/x-httpd-php-source .phps + + # Since most users will want index.php to work we + # also automatically enable index.php + <IfModule mod_dir.c> + DirectoryIndex index.html index.php + </IfModule> +</IfModule> + + 4. Be sure the DirectoryIndex loads the desired default index file + This is also set in httpd.conf. Typically index.php and index.html + are used. By default index.php is enabled because it's also in the + PHP check shown above. Adjust accordingly. + 5. Set the php.ini location or use the default + A typical default location on Mac OS X is /usr/local/php/php.ini + and a call to phpinfo() will reveal this information. If a php.ini + is not used, PHP will use all default values. See also the related + FAQ on finding php.ini. + 6. Locate or set the DocumentRoot + This is the root directory for all the web files. Files in this + directory are served from the web server so the PHP files will + parse as PHP before outputting them to the browser. A typical + default path is /Library/WebServer/Documents but this can be set to + anything in httpd.conf. Alternatively, the default DocumentRoot for + individual users is /Users/yourusername/Sites + 7. Create a phpinfo() file + The phpinfo() function will display information about PHP. Consider + creating a file in the DocumentRoot with the following PHP code: + +<?php phpinfo(); ?> + + 8. Restart Apache, and load the PHP file created above + To restart, either execute sudo apachectl graceful in the shell or + stop/start the "Personal Web Server" option in the OS X System + Preferences. By default, loading local files in the browser will + have an URL like so: http://localhost/info.php Or using the + DocumentRoot in the user directory is another option and would end + up looking like: http://localhost/~yourusername/info.php + + The CLI (or CGI in older versions) is appropriately named php and + likely exists as /usr/bin/php. Open up the terminal, read the command + line section of the PHP manual, and execute php -v to check the PHP + version of this PHP binary. A call to phpinfo() will also reveal this + information. + __________________________________________________________________ Compiling for OS X Server - Mac OS X Server install. + Mac OS X Server install. 1. Get the latest distributions of Apache and PHP. 2. Untar them, and run the configure program on Apache like so. @@ -1134,8 +1199,8 @@ --enable-module=most \ --target=apache - 3. If you want the compiler to do some optimization, you may also - want to add this line: + 3. If you want the compiler to do some optimization, you may also want + to add this line: setenv OPTIM=-O2 @@ -1166,17 +1231,17 @@ --target=apache \ --activate-module=src/modules/php4/libphp4.a - You may get a message telling you that libmodphp4.a is out of - date. If so, go to the src/modules/php4 directory inside your - Apache source directory and run this command: ranlib libmodphp4.a. - Then go back to the root of the Apache source directory and run - the above configure command again. That'll bring the link table up - to date. Run make and make install again. + You may get a message telling you that libmodphp4.a is out of date. + If so, go to the src/modules/php4 directory inside your Apache + source directory and run this command: ranlib libmodphp4.a. Then go + back to the root of the Apache source directory and run the above + configure command again. That'll bring the link table up to date. + Run make and make install again. 7. Copy and rename the php.ini-dist file to your bin directory from - your PHP 4 source directory: cp php.ini-dist - /usr/local/bin/php.ini or (if your don't have a local directory) - cp php.ini-dist /usr/bin/php.ini. - _________________________________________________________________ + your PHP 4 source directory: cp php.ini-dist /usr/local/bin/php.ini + or (if your don't have a local directory) cp php.ini-dist + /usr/bin/php.ini. + __________________________________________________________________ Compiling for MacOS X Client @@ -1187,8 +1252,7 @@ Warning - Be careful when you do this, you could screw up your Apache web - server! + Be careful when you do this, you could screw up your Apache web server! Do this to install: @@ -1198,9 +1262,9 @@ wait for the download to finish. 3. Type gunzip libphp4.so.gz. 4. Type sudo apxs -i -a -n php4 libphp4.so - 5. Now type sudo open -a TextEdit /etc/httpd/httpd.conf. TextEdit - will open with the web server configuration file. Locate these two - lines towards the end of the file: (Use the Find command) + 5. Now type sudo open -a TextEdit /etc/httpd/httpd.conf. TextEdit will + open with the web server configuration file. Locate these two lines + towards the end of the file: (Use the Find command) #AddType application/x-httpd-php .php #AddType application/x-httpd-php-source .phps @@ -1215,145 +1279,166 @@ Now open up 127.0.0.1/~your_username/test.php in your web browser. You should see a status table with information about the PHP module. - _________________________________________________________________ + __________________________________________________________________ Chapter 4. Installation of PECL extensions Introduction to PECL Installations - PHP extensions may be installed in a variety of ways. PECL is a - repository of PHP extensions living within the PEAR structure, and the - following demonstrates how to install these extensions. + PECL is a repository of PHP extensions that are made available to you + via the PEAR packaging system. This section of the manual is intended + to demonstrate how to obtain and install PECL extensions. These instructions assume /your/phpsrcdir/ is the path to the PHP - source, and extname is the name of the PECL extension. Adjust - accordingly. These instructions also assume a familiarity with the - pear command. - - Shared extensions may be installed by including them inside of php.ini - using the extension PHP directive. See also the extensions_dir - directive, and dl(). The installation methods described below do not - automatically configure PHP to include these extensions, this step - must be done manually. - - When building PHP modules, it's important to have the appropriate - versions of the required tools (autoconf, automake, libtool, etc.) See - the Anonymous CVS Instructions for details on the required tools, and + source distribution, and that extname is the name of the PECL + extension. Adjust accordingly. These instructions also assume a + familiarity with the pear command. The information in the PEAR manual + for the pear command also applies to the pecl command. + + To be useful, a shared extension must be built, installed, and loaded. + The methods described below provide you with various instructions on + how to build and install the extensions, but they do not automatically + load them. Extensions can be loaded by adding an extension directive. + To this php.ini file, or through the use of the dl() function. + + When building PHP modules, it's important to have known-good versions + of the required tools (autoconf, automake, libtool, etc.) See the + Anonymous CVS Instructions for details on the required tools, and required versions. - _________________________________________________________________ + __________________________________________________________________ Downloading PECL extensions There are several options for downloading PECL extensions, such as: * http://pecl.php.net - Listed here is information like the ChangeLog, release - information, requirements, revisions, etc. Although not every PECL - extension has a webpage, most do. - * pear download extname - The pear command may also be used to download source files. + The PECL web site contains information about the different + extensions that are offered by the PHP Development Team. The + information available here includes: ChangeLog, release notes, + requirements and other similar details. + * pecl download extname + PECL extensions that have releases listed on the PECL web site are + available for download and installation using the pecl command. Specific revisions may also be specified. * CVS - All PECL files reside in CVS. A web-based view may be seen at - http://cvs.php.net/pecl/. To download straight from CVS, consider - the following where phpfi is the password for user cvsread: + Most PECL extensions also reside in CVS. A web-based view may be + seen at http://cvs.php.net/pecl/. To download straight from CVS, + the following sequence of commands may be used. Note that phpfi is + the password for user cvsread: $ cvs -d:pserver:cvsread@cvs.php.net:/repository login $ cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/extname * Windows downloads Windows users may find compiled PECL binaries by downloading the - Collection of PECL modules from the PHP Downloads page, and by - retrieving a PECL Snapshot. To compile PHP under Windows, read the - Win32 Build README. - _________________________________________________________________ + Collection of PECL modules from the PHP Downloads page, or by + retrieving a PECL Snapshot or an extension DLL on PECL4WIN. To + compile PHP under Windows, read the appropriate chapter. + __________________________________________________________________ PECL for Windows users - Like with any other PHP extension DLL, to install move the PECL - extension DLLs into the extension_dir folder and include them within - php.ini. For example: + As with any other PHP extension DLL, installation is as simple as + copying the PECL extension DLLs into the extension_dir folder and + loading them from php.ini. For example, add the following line to your + php.ini: extension=php_extname.dll After doing this, restart the web server. - _________________________________________________________________ + __________________________________________________________________ -Compiling shared PECL extensions with PEAR +Compiling shared PECL extensions with the pecl command - PEAR makes it easy to create shared PHP extensions. Using the pear + PECL makes it easy to create shared PHP extensions. Using the pecl command, do the following: - $ pear install extname + $ pecl install extname + + This will download the source for extname, compile, and install + extname.so into your extension_dir. extname.so may then be loaded via + php.ini + + By default, the pecl command will not install packages that are marked + with the alpha or beta state. If no stable packages are available, you + may install a beta package using the following command: + + $ pecl install extname-beta + + You may also install a specific version using this variant: - That will download the source for extname, and compile it on the - system. This results in an extname.so file that may then be included - in php.ini - - In case the systems preferred_state is set higher than an available - extname version, like it's set to stable and the extension is still in - beta, either alter the preferred_state via pear config-set or specify - a specific version of the PECL extension. For example: - - $ pear install extname-0.1.1 - - Regardless, pear will copy this extname.so into the extensions - directory. Adjust php.ini accordingly. - _________________________________________________________________ + $ pecl install extname-0.1 + __________________________________________________________________ Compiling shared PECL extensions with phpize - If using pear is not an option, like for building shared PECL - extensions from CVS, or for unreleased PECL packages, then creating a - shared extension may also be done by manually using the phpize - command. The pear command essentially does this but it may also be - done manually. Assuming the source file is named extname.tgz, and that - it was downloaded into the current directory, consider the following: + Sometimes, using the pecl installer is not an option. This could be + because you're behind a firewall, or it could be because the extension + you want to install is not available as a PECL compatible package, such + as unreleased extensions from CVS. If you need to build such an + extension, you can use the lower-level build tools to perform the build + manually. + + The phpize command is used to prepare the build environment for a PHP + extension. In the following sample, the sources for an extension are in + a directory named extname: -$ pear download extname -$ gzip -d < extname.tgz | tar -xvf - $ cd extname $ phpize -$ ./configure && make +$ ./configure +$ make +# make install - Upon success, this will create extname.so and put it into the modules/ - and/or .libs/ directory within the extname/ source. Move this shared - extension (extname.so) into the PHP extensions directory, and adjust - php.ini accordingly. - _________________________________________________________________ + A successful install will have created extname.so and put it into the + PHP extensions directory. You'll need to and adjust php.ini and add an + extension=extname.so line before you can use the extension. + + If the system is missing the phpize command, and precompiled packages + (like RPM's) are used, be sure to also install the appropriate devel + version of the PHP package as they often include the phpize command + along with the appropriate header files to build PHP and its + extensions. + + Execute phpize --help to display additional usage information. + __________________________________________________________________ Compiling PECL extensions statically into PHP - To statically include the extension within the PHP build, put the - extensions source into the ext/ directory found in the PHP source. For - example: + You might find that you need to build a PECL extension statically into + your PHP binary. To do this, you'll need to place the extension source + under the php-src/ext/ directory and tell the PHP build system to + regenerate its configure script. $ cd /your/phpsrcdir/ext -$ pear download extname +$ pecl download extname $ gzip -d < extname.tgz | tar -xvf - $ mv extname-x.x.x extname -$ rm package.xml This will result in the following directory: /your/phpsrcdir/ext/extname - From here, build PHP as normal: + From here, force PHP to rebuild the configure script, and then build + PHP as normal: $ cd /your/phpsrcdir -$ ./buildconf +$ rm configure +$ ./buildconf --force $ ./configure --help $ ./configure --with-extname --enable-someotherext --with-foobar $ make $ make install + Note: To run the 'buildconf' script you need autoconf 2.13 and + automake 1.4+ (newer versions of autoconf may work, but are not + supported). + Whether --enable-extname or --with-extname is used depends on the extension. Typically an extension that does not require external - libraries uses --enable. To be sure, run the following after - buildconf: + libraries uses --enable. To be sure, run the following after buildconf: $ ./configure --help | grep extname - _________________________________________________________________ + __________________________________________________________________ Chapter 5. Problems? @@ -1361,7 +1446,7 @@ Some problems are more common than others. The most common ones are listed in the PHP FAQ, part of this manual. - _________________________________________________________________ + __________________________________________________________________ Other problems @@ -1379,7 +1464,7 @@ system, what PHP version, what web server, if you are running PHP as CGI or a server module, safe mode, etc...), and preferably enough code to make others able to reproduce and test your problem. - _________________________________________________________________ + __________________________________________________________________ Bug reports @@ -1392,37 +1477,52 @@ Read the How to report a bug document before submitting any bug reports! - _________________________________________________________________ + __________________________________________________________________ Chapter 6. Runtime Configuration The configuration file - The configuration file (called php3.ini in PHP 3, and simply php.ini - as of PHP 4) is read when PHP starts up. For the server module - versions of PHP, this happens only once when the web server is - started. For the CGI and CLI version, it happens on every invocation. - - The default location of php.ini is a compile time option (see the FAQ - entry), but can be changed for the CGI and CLI version with the -c - command line switch, see the chapter about using PHP from the command - line. You can also use the environment variable PHPRC for an - additional path to search for a php.ini file. + The configuration file (called php3.ini in PHP 3, and simply php.ini as + of PHP 4) is read when PHP starts up. For the server module versions of + PHP, this happens only once when the web server is started. For the CGI + and CLI version, it happens on every invocation. + + php.ini is searched in these locations (in order): + + * SAPI module specific location (PHPIniDir directive in Apache 2, -c + command line option in CGI and CLI, php_ini parameter in NSAPI, + PHP_INI_PATH environment variable in THTTPD) + * The PHPRC environment variable. Before PHP 5.2.0 this was checked + after the registry key mentioned below. + * As of PHP 5.2.0, the following registry locations are searched in + order: HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z\IniFilePath, + HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y\IniFilePath and + HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x\IniFilePath, where x, y and z + mean the PHP major, minor and release versions. + * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry + location) + * Current working directory (except CLI) + * The web server's directory (for SAPI modules), or directory of PHP + (otherwise in Windows) + * Windows directory (C:\windows or C:\winnt) (for Windows), or + --with-config-file-path compile time option If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is - e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini. + e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini. SAPI + name can be determined by php_sapi_name(). - Note: The Apache web server changes the directory to root at - startup causing PHP to attempt to read php.ini from the root - filesystem if it exists. + Note: The Apache web server changes the directory to root at startup + causing PHP to attempt to read php.ini from the root filesystem if + it exists. The php.ini directives handled by extensions are documented - respectively on the pages of the extensions themselves. The list of - the core directives is available in the appendix. Probably not all the - PHP directives are documented in the manual though. For a completel - list of directives available in your PHP version, please read your - well commented php.ini file. Alternatively, you may find the the - latest php.ini from CVS helpful too. + respectively on the pages of the extensions themselves. The list of the + core directives is available in the appendix. Probably not all PHP + directives are documented in the manual though. For a complete list of + directives available in your PHP version, please read your well + commented php.ini file. Alternatively, you may find the the latest + php.ini from CVS helpful too. Example 6-1. php.ini example ; any text on a line after an unquoted semicolon (;) is ignored @@ -1438,7 +1538,11 @@ ; backslashes are treated the same as any other character include_path = ".;c:\php\lib" - _________________________________________________________________ + + Since PHP 5.1.0, it is possible to refer to existing .ini variables + from within .ini files. Example: open_basedir = ${open_basedir} + ":/new/dir". + __________________________________________________________________ How to change configuration settings @@ -1451,17 +1555,17 @@ With PHP 4 and PHP 5, there are several Apache directives that allow you to change the PHP configuration from within the Apache - configuration files. For a listing of which directives are - PHP_INI_ALL, PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the - List of php.ini directives appendix. + configuration files. For a listing of which directives are PHP_INI_ALL, + PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the List of php.ini + directives appendix. Note: With PHP 3, there are Apache directives that correspond to each configuration setting in the php3.ini name, except the name is prefixed by "php3_". php_value name value - Sets the value of the specified directive. Can be used only - with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a + Sets the value of the specified directive. Can be used only with + PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a previously set value use none as the value. Note: Don't use php_value to set boolean values. php_flag (see @@ -1474,14 +1578,14 @@ php_admin_value name value Sets the value of the specified directive. This can not be used in .htaccess files. Any directive type set with php_admin_value - can not be overridden by .htaccess or virtualhost directives. - To clear a previously set value use none as the value. + can not be overridden by .htaccess or virtualhost directives. To + clear a previously set value use none as the value. php_admin_flag name on|off Used to set a boolean configuration directive. This can not be used in .htaccess files. Any directive type set with - php_admin_flag can not be overridden by .htaccess or - virtualhost directives. + php_admin_flag can not be overridden by .htaccess or virtualhost + directives. Example 6-2. Apache configuration example <IfModule mod_php5.c> @@ -1504,7 +1608,7 @@ error_reporting directive as they will have no meaning and will evaluate to 0. Use the associated bitmask values instead. These constants can be used in php.ini - _________________________________________________________________ + __________________________________________________________________ Changing PHP configuration via the Windows registry @@ -1518,18 +1622,430 @@ active for any script running from this directory or any subdirectory of it. The values under the key should have the name of the PHP configuration directive and the string value. PHP constants in the - values are not parsed. However, only configuration values changeable - in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not. - _________________________________________________________________ + values are not parsed. However, only configuration values changeable in + PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not. + __________________________________________________________________ Other interfaces to PHP - Regardless of how you run PHP, you can change certain values at - runtime of your scripts through ini_set(). See the documentation on - the ini_set() page for more information. + Regardless of how you run PHP, you can change certain values at runtime + of your scripts through ini_set(). See the documentation on the + ini_set() page for more information. If you are interested in a complete list of configuration settings on your system with their current values, you can execute the phpinfo() - function, and review the resulting page. You can also access the - values of individual configuration directives at runtime using - ini_get() or get_cfg_var(). + function, and review the resulting page. You can also access the values + of individual configuration directives at runtime using ini_get() or + get_cfg_var(). + __________________________________________________________________ + +Chapter 7. Installation FAQ + + 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 Installing PHP. + + 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 get the + message 'Document Contains No Data'! What's going on here? + + 4. Unix: I installed PHP using RPMS, but Apache isn't processing the + PHP pages! What's going on here? + + 5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the + database support I need! What's going on here? + + 6. Unix: I patched Apache with the FrontPage extensions patch, and + suddenly PHP stopped working. Is PHP incompatible with the + Apache FrontPage extensions? + + 7. Unix/Windows: I have installed PHP, but when I try to access a PHP + script file via my browser, I get a blank screen. + + 8. Unix/Windows: I have installed PHP, but when try to access a PHP + script file via my browser, I get a server 500 error. + + 9. Some operating systems: I have installed PHP without errors, but + when I try to start apache I get undefined symbol errors: + +[mybox:user /src/php4] root# apachectl configtest + apachectl: /usr/local/apache/bin/httpd Undefined symbols: + _compress + _uncompress + + 10. Windows: I have installed PHP, but when I to access a PHP script + file via my browser, I get the error: + +cgi error: + The specified CGI application misbehaved by not + returning a complete set of HTTP headers. + The headers it did return are: + + 11. Windows: I've followed all the instructions, but still can't get + PHP and IIS to work together! + + 12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get + the following error: Security Alert! PHP CGI cannot be accessed + directly.. + + 13. How do I know if my php.ini is being found and read? It seems like + it isn't as my changes aren't being implemented. + + 14. How do I add my PHP directory to the PATH on Windows? + 15. How do I make the php.ini file available to PHP on windows? + 16. Is it possible to use Apache content negotiation (MultiViews + option) with PHP? + + 17. Is PHP limited to process GET and POST request methods only? + + 1. 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 + 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, feet of clay are introduced into PHP's system. + + If you feel you have to use a threaded MPM, look at a FastCGI + configuration where PHP is running in its own memory space. + + And finally, this warning against using a threaded MPM is not as strong + for Windows systems because most libraries on that platform tend to be + threadsafe. + + 2. 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 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 + + And then you would copy php.ini-dist from the distribution to + /etc/php.ini and edit it to make any local changes 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 versions of Apache on the same machine. + + See also the chapter about the configuration file. + + 3. Unix: I installed PHP, but every time I load a document, I get the + message 'Document Contains No Data'! What's going on here? + + 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 (ereg() 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 + + 4. Unix: I installed PHP using RPMS, but Apache isn't processing the + PHP pages! What's going on here? + + 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_php3.c +AddModule mod_perl.c + +# Extra Modules +LoadModule php_module modules/mod_php.so +LoadModule php3_module modules/libphp3.so # for PHP 3 +LoadModule php4_module modules/libphp4.so # for PHP 4 +LoadModule perl_module modules/libperl.so + + And add: +AddType application/x-httpd-php3 .php3 # for PHP 3 +AddType application/x-httpd-php .php # for PHP 4 + + ... to the global properties, or to the properties of the VirtualDomain + you want to have PHP support added to. + + 5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the + database support I need! What's going on here? + + Due to the way PHP 3 built, it is not easy to build a complete flexible + PHP RPM. This issue is addressed in PHP 4. For PHP 3, we currently + suggest you use the mechanism described in the INSTALL.REDHAT file in + the PHP distribution. If you insist on using an RPM version of PHP 3, + read on... + + The RPM packagers are setting up the RPMS to install without database + support to simplify installations and because RPMS use /usr/ instead of + the standard /usr/local/ directory for files. You need to tell the RPM + spec file which databases to support and the location of the top-level + of your database server. + + This example will explain the process of adding support for the popular + MySQL database server, using the mod installation for Apache. + + Of course all of this information can be adjusted for any database + server that PHP supports. We will assume you installed MySQL and Apache + completely with RPMS for this example as well. + + * First remove mod_php3 : + +rpm -e mod_php3 + + * Then get the source rpm and INSTALL it, NOT --rebuild + +rpm -Uvh mod_php3-3.0.5-2.src.rpm + + * Then edit the /usr/src/redhat/SPECS/mod_php3.spec file + In the %build section add the database support you want, and the + path. + For MySQL you would add --with-mysql=/usr The %build section will + look something like this: + +./configure --prefix=/usr \ +--with-apxs=/usr/sbin/apxs \ +--with-config-file-path=/usr/lib \ +--enable-debug=no \ +--enable-safe-mode \ +--with-exec-dir=/usr/bin \ +--with-mysql=/usr \ +--with-system-regex + + * Once this modification is made then build the binary rpm as + follows: + +rpm -bb /usr/src/redhat/SPECS/mod_php3.spec + + * Then install the rpm + +rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm + + Make sure you restart Apache, and you now have PHP 3 with MySQL support + using RPM's. Note that it is probably much easier to just build from + the distribution tarball of PHP 3 and follow the instructions in + INSTALL.REDHAT found in that distribution. + + 6. Unix: I patched Apache with the FrontPage extensions patch, and + suddenly PHP stopped working. Is PHP incompatible with the Apache + FrontPage extensions? + + 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. + + 7. Unix/Windows: I have installed PHP, but when I try to access a PHP + script file via my browser, I get a blank 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 check the server + configuration against the PHP installation instructions. + + 8. Unix/Windows: I have installed PHP, but when try to access a PHP + script file via my browser, I get a server 500 error. + + 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. + + 9. Some operating systems: I have installed PHP without errors, but + when I try to start apache I get undefined symbol errors: +[mybox:user /src/php4] 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. + + 10. Windows: I have installed PHP, but when I to access a PHP script + file via my browser, I get the error: +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: + + * File permissions on your PHP script, php.exe, php4ts.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 think + it is relative to your web root directory). Note that for IIS you + can trap this error by ticking the 'check file exists' box when + setting up the script mappings 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 + permissions on your script file. + + 11. Windows: I've followed all the instructions, but still can't get + PHP and IIS to work together! + + 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. + + 12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get + the following error: Security Alert! PHP CGI cannot be accessed + directly.. + + 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. + + 13. How do I know if my php.ini is being found and read? It seems like + it isn't as my changes aren't being implemented. + + To be sure your php.ini is being read by PHP, make a call to phpinfo() + and near the top 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 than it's not being + read and you should put your php.ini in that directory. If php.ini is + included within the PATH than 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 + + 14. How do I add my PHP directory to the PATH on Windows? + + 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 + * 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 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 + * 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 systems PATH. Copying files into the Windows + system directory has long since been deprecated and may cause problems. + + 15. How do I make the php.ini file available to PHP on windows? + + 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 + + 16. Is it possible to use Apache content negotiation (MultiViews + option) with PHP? + + 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: +# PHP 4 +AddHandler php-script php +AddType text/html php + +# PHP 5 +AddHandler php5-script php +AddType text/html php + + This solution doesn't work for Apache 1 as PHP module doesn't catch + php-script. + + 17. Is PHP limited to process GET 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 GET and POST methods + should be handled, it can be achieved with this Apache configuration: +<LimitExcept GET POST> +Deny from all +</LimitExcept> http://cvs.php.net/viewvc.cgi/php-src/win32/install.txt?r1=1.16.2.7&r2=1.16.2.7.2.1&diff_format=u Index: php-src/win32/install.txt diff -u php-src/win32/install.txt:1.16.2.7 php-src/win32/install.txt:1.16.2.7.2.1 --- php-src/win32/install.txt:1.16.2.7 Wed Mar 30 13:15:34 2005 +++ php-src/win32/install.txt Fri Apr 20 14:18:19 2007 @@ -1,13 +1,13 @@ - Installing PHP - _________________________________________________________________ + __________________________________________________________________ Table of Contents Preface 1. General Installation Considerations 2. Installation on Windows systems - Windows Installer + Windows Installer (PHP 5.2 and later) + Windows Installer (PHP 5.1.0 and earlier) Manual Installation Steps ActiveScript Microsoft IIS / PWS @@ -24,7 +24,7 @@ Introduction to PECL Installations Downloading PECL extensions PECL for Windows users - Compiling shared PECL extensions with PEAR + Compiling shared PECL extensions with the pecl command Compiling shared PECL extensions with phpize Compiling PECL extensions statically into PHP @@ -38,14 +38,16 @@ The configuration file How to change configuration settings - _________________________________________________________________ + + 6. Installation FAQ + __________________________________________________________________ Preface - These installation instructions were generated from the HTML version - of the PHP Manual so formatting and linking have been altered. See the + These installation instructions were generated from the HTML version of + the PHP Manual so formatting and linking have been altered. See the online and updated version at: http://php.net/install.windows - _________________________________________________________________ + __________________________________________________________________ Chapter 1. General Installation Considerations @@ -53,9 +55,9 @@ want to use PHP for. There are three main fields you can use PHP, as described in the What can PHP do? section: - * Server-side scripting + * Websites and web applications (server-side scripting) * Command line scripting - * Client-side GUI applications + * Desktop (GUI) applications For the first and most common form, you need three things: PHP itself, a web server and a web browser. You probably already have a web @@ -65,39 +67,39 @@ set up anything on your own, only write your PHP scripts, upload it to the server you rent, and see the results in your browser. - While setting up the server and PHP on your own, you have two choices - for the method of connecting PHP to the server. For many servers PHP - has a direct module interface (also called SAPI). These servers - include Apache, Microsoft Internet Information Server, Netscape and - iPlanet servers. Many other servers have support for ISAPI, the + In case of setting up the server and PHP on your own, you have two + choices for the method of connecting PHP to the server. For many + servers PHP has a direct module interface (also called SAPI). These + servers include Apache, Microsoft Internet Information Server, Netscape + and iPlanet servers. Many other servers have support for ISAPI, the Microsoft module interface (OmniHTTPd for example). If PHP has no module support for your web server, you can always use it as a CGI or FastCGI processor. This means you set up your server to use the CGI executable of PHP to process all PHP file requests on the server. If you are also interested to use PHP for command line scripting (e.g. - write scripts autogenerating some images for you offline, or - processing text files depending on some arguments you pass to them), - you always need the command line executable. For more information, - read the section about writing command line PHP applications. In this - case, you need no server and no browser. + write scripts autogenerating some images for you offline, or processing + text files depending on some arguments you pass to them), you always + need the command line executable. For more information, read the + section about writing command line PHP applications. In this case, you + need no server and no browser. With PHP you can also write desktop GUI applications using the PHP-GTK extension. This is a completely different approach than writing web - pages, as you do not output any HTML, but manage windows and objects + pages, as you do not output any HTML, but manage Windows and objects within them. For more information about PHP-GTK, please visit the site dedicated to this extension. PHP-GTK is not included in the official PHP distribution. From now on, this section deals with setting up PHP for web servers on - Unix and Windows with server module interfaces and CGI executables. - You will also find information on the command line executable in the + Unix and Windows with server module interfaces and CGI executables. You + will also find information on the command line executable in the following sections. PHP source code and binary distributions for Windows can be found at http://www.php.net/downloads.php. We recommend you to choose a mirror nearest to you for downloading the distributions. - _________________________________________________________________ + __________________________________________________________________ Chapter 2. Installation on Windows systems @@ -121,29 +123,112 @@ those are endorsed by PHP.net, as we believe that the manual installation is the best choice to have your system secure and optimised. - _________________________________________________________________ + __________________________________________________________________ + +Windows Installer (PHP 5.2 and later) + + The Windows PHP installer for later versions of PHP is built using MSI + technology using the Wix Toolkit (http://wix.sourceforge.net/). It will + install and configure PHP and all the built-in and PECL extensions, as + well as configure many of the popular web servers such as IIS, Apache, + and Xitami. + + First, install your selected HTTP (web) server on your system, and make + sure that it works. Then proceed with one of the following install + types. + __________________________________________________________________ + +Normal Install + + Run the MSI installer and follow the instructions provided by the + installation wizard. You will be prompted to select the Web Server you + wish to configure first, along with any configuration details needed. + + You will then be prompted to select which features and extensions you + wish to install and enable. By selecting "Will be installed on local + hard drive" in the drop-down menu for each item you can trigger whether + to install the feature or not. By selecting "Entire feature will be + installed on local hard drive", you will be able to install all + sub-features of the included feature ( for example by selecting this + options for the feature "PDO" you will install all PDO Drivers ). + + Warning -Windows Installer + It is not recommended to install all extensions by default, since many + other them require dependencies from outside PHP in order to function + properly. Instead, use the Installation Repair Mode that can be + triggered thru the 'Add/Remove Programs' control panel to enable or + disable extensions and features after installation. + + The installer then sets up PHP to be used in Windows and the php.ini + file, and configures certain web servers to use PHP. The installer will + currently configure IIS (CGI mode only), Apache, Xitami, and Sambar + Server; if you are using a different web server you'll need to + configure it manually. + __________________________________________________________________ + +Silent Install + + The installer also supports a silent mode, which is helpful for Systems + Administrators to deploy PHP easily. To use silent mode: + msiexec.exe /i php-VERSION-win32-install.msi /q + + You can control the install directory by passing it as a parameter to + the install. For example, to install to e:\php: + msiexec.exe /i php-VERSION-win32-install.msi /q INSTALLDIR=e:\php + + You can also use the same syntax to specify the Apache Configuration + Directory (APACHEDIR), the Sambar Server directory (SAMBARDIR), and the + Xitami Server directory (XITAMIDIR). + + You can also specify what features to install. For example, to install + the mysqli extension and the CGI executable: + msiexec.exe /i php-VERSION-win32-install.msi /q ADDLOCAL=cgi,ext_php_mysqli + + The current list of Features to install is as follows: +MainExecutable - php.exe executable +ScriptExecutable - php-win.exe executable +ext_php_* - the various extensions ( for example: ext_php_mysql for MySQL ) +apache13 - Apache 1.3 module +apache20 - Apache 2.0 module +apache22 - Apache 2,2 module +apacheCGI - Apache CGI executable +iis4ISAPI - IIS ISAPI module +iis4CGI - IIS CGI executable +NSAPI - Sun/iPlanet/Netscape server module +Xitami - Xitami CGI executable +Sambar - Sambar Server ISAPI module +CGI - php-cgi.exe executable +PEAR - PEAR installer +Manual - PHP Manual in CHM Format + + For more information on installing MSI installers from the command + line, visit + http://msdn.microsoft.com/library/en-us/msi/setup/command_line_options. + asp + __________________________________________________________________ + +Windows Installer (PHP 5.1.0 and earlier) The Windows PHP installer is available from the downloads page at http://www.php.net/downloads.php. This installs the CGI version of PHP - and for IIS, PWS, and Xitami, it configures the web server as well. - The installer does not include any extra external PHP extensions + and for IIS, PWS, and Xitami, it configures the web server as well. The + installer does not include any extra external PHP extensions (php_*.dll) as you'll only find those in the Windows Zip Package and PECL downloads. Note: While the Windows installer is an easy way to make PHP work, it is restricted in many aspects as, for example, the automatic - setup of extensions is not supported. Use of the installer isn't - the preferred method for installing PHP. + setup of extensions is not supported. Use of the installer isn't the + preferred method for installing PHP. - First, install your selected HTTP (web) server on your system, and - make sure that it works. + First, install your selected HTTP (web) server on your system, and make + sure that it works. Run the executable installer and follow the instructions provided by the installation wizard. Two types of installation are supported - - standard, which provides sensible defaults for all the settings it - can, and advanced, which asks questions as it goes along. + standard, which provides sensible defaults for all the settings it can, + and advanced, which asks questions as it goes along. The installation wizard gathers enough information to set up the php.ini file, and configure certain web servers to use PHP. One of the @@ -161,7 +246,7 @@ every option carefully. This automatically working setup gives you an instantly working PHP installation, but it is not meant to be used on online servers. - _________________________________________________________________ + __________________________________________________________________ Manual Installation Steps @@ -171,31 +256,31 @@ http://www.php.net/downloads.php. Although there are many all-in-one installation kits, and we also - distribute a PHP installer for Microsoft Windows, we recommend you - take the time to setup PHP yourself as this will provide you with a - better understanding of the system, and enables you to install PHP - extensions easily when needed. + distribute a PHP installer for Microsoft Windows, we recommend you take + the time to setup PHP yourself as this will provide you with a better + understanding of the system, and enables you to install PHP extensions + easily when needed. Upgrading from a previous PHP version: Previous editions of the manual suggest moving various ini and DLL files into your SYSTEM (i.e. C:\WINDOWS) folder and while this simplifies the installation procedure it makes upgrading difficult. We advise you remove all of these files (like php.ini and PHP related DLLs from the Windows - SYSTEM folder) before moving on with a new PHP installation. Be - sure to backup these files as you might break the entire system. - The old php.ini might be useful in setting up the new PHP as well. - And as you'll soon learn, the preferred method for installing PHP - is to keep all PHP related files in one directory and have this - directory available to your systems PATH. + SYSTEM folder) before moving on with a new PHP installation. Be sure + to backup these files as you might break the entire system. The old + php.ini might be useful in setting up the new PHP as well. And as + you'll soon learn, the preferred method for installing PHP is to + keep all PHP related files in one directory and have this directory + available to your systems PATH. MDAC requirements: If you use Microsoft Windows 98/NT4 download the latest version of the Microsoft Data Access Components (MDAC) for - your platform. MDAC is available at - http://msdn.microsoft.com/data/. This requirement exists because - ODBC is built into the distributed Windows binaries. + your platform. MDAC is available at http://msdn.microsoft.com/data/. + This requirement exists because ODBC is built into the distributed + Windows binaries. - The following steps should be completed on all installations before - any server specific instructions are performed: + The following steps should be completed on all installations before any + server specific instructions are performed: Extract the distribution file into a directory of your choice. If you are installing PHP 4, extract to C:\, as the zip file expands to a @@ -212,7 +297,7 @@ | +--cli | | - | |-php.exe -- CLI executable - ONLY for commandline scripting + | |-php.exe -- CLI executable - ONLY for command line scripting | +--dlls -- support DLLs required by some extensions | | @@ -238,8 +323,6 @@ | +--sapi -- SAPI (server module support) DLLs | | - | |-php4activescript.dll - | | | |-php4apache.dll | | | |-php4apache2.dll @@ -342,6 +425,7 @@ engine, allowing you to embed PHP in your Windows applications. * sapi/php4apache.dll (php5apache.dll) - Apache 1.3.x module. * sapi/php4apache2.dll (php5apache2.dll) - Apache 2.0.x module. + * sapi/php5apache2_2.dll - Apache 2.2.x module. * sapi/php4isapi.dll (php5isapi.dll) - ISAPI Module for ISAPI compliant web servers like IIS 4.0/PWS 4.0 or newer. * sapi/php4nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape server @@ -365,45 +449,39 @@ sure that this file can be found by your PHP installation. The search order for this DLL is as follows: - * The same directory from where php.exe is called, or in case you - use a SAPI module, the web server's directory (e.g. C:\Program + * The same directory from where php.exe is called, or in case you use + a SAPI module, the web server's directory (e.g. C:\Program Files\Apache Group\Apache2\bin). * Any directory in your Windows PATH environment variable. To make php4ts.dll / php5ts.dll available you have three options: copy the file to the Windows system directory, copy the file to the web server's directory, or add your PHP directory, C:\php to the PATH. For - better maintenance, we advise you to follow the last option, add - C:\php to the PATH, because it will be simpler to upgrade PHP in the - future. Read more about how to add your PHP directory to PATH in the - corresponding FAQ entry. - - The next step is to set up a valid configuration file for PHP, - php.ini. There are two ini files distributed in the zip file, - php.ini-dist and php.ini-recommended. We advise you to use - php.ini-recommended, because we optimized the default settings in this - file for performance, and security. Read this well documented file - carefully because it has changes from php.ini-dist that will - drastically affect your setup. Some examples are display_errors being - off and magic_quotes_gpc being off. In addition to reading these, - study the ini settings and set every element manually yourself. If you - would like to achieve the best security, then this is the way for you, - although PHP works fine with these default ini files. Copy your chosen - ini-file to a directory that PHP is able to find and rename it to - php.ini. PHP searches for php.ini in the following locations (in - order): - - * PHPIniDir directive (Apache 2 module only) - * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath - * The PHPRC environment variable - * Directory of PHP (for CLI), or the web server's directory (for - SAPI modules) - * Windows directory (C:\windows or C:\winnt) - - If you are running Apache 2, the simpler option is to use the - PHPIniDir directive (read the installation on Apache 2 page), - otherwise your best option is to set the PHPRC environment variable. - This process is explained in the following FAQ entry. + better maintenance, we advise you to follow the last option, add C:\php + to the PATH, because it will be simpler to upgrade PHP in the future. + Read more about how to add your PHP directory to PATH in the + corresponding FAQ entry (and then don't forget to restart the computer + - logoff isn't enough). + + The next step is to set up a valid configuration file for PHP, php.ini. + There are two ini files distributed in the zip file, php.ini-dist and + php.ini-recommended. We advise you to use php.ini-recommended, because + we optimized the default settings in this file for performance, and + security. Read this well documented file carefully because it has + changes from php.ini-dist that will drastically affect your setup. Some + examples are display_errors being off and magic_quotes_gpc being off. + In addition to reading these, study the ini settings and set every + element manually yourself. If you would like to achieve the best + security, then this is the way for you, although PHP works fine with + these default ini files. Copy your chosen ini-file to a directory that + PHP is able to find and rename it to php.ini. PHP searches for php.ini + in the locations described in the Section called The configuration file + in Chapter 5 section. + + If you are running Apache 2, the simpler option is to use the PHPIniDir + directive (read the installation on Apache 2 page), otherwise your best + option is to set the PHPRC environment variable. This process is + explained in the following FAQ entry. Note: If you're using NTFS on Windows NT, 2000, XP or 2003, make sure that the user running the web server has read permissions to @@ -412,8 +490,8 @@ The following steps are optional: * Edit your new php.ini file. If you plan to use OmniHTTPd, do not - follow the next step. Set the doc_root to point to your web - servers document_root. For example: + follow the next step. Set the doc_root to point to your web servers + document_root. For example: doc_root = c:\inetpub\wwwroot // for IIS/PWS @@ -431,21 +509,21 @@ browscap.ini, read the following FAQ. PHP is now setup on your system. The next step is to choose a web - server, and enable it to run PHP. Choose a webserver from the table of + server, and enable it to run PHP. Choose a web server from the table of contents. - _________________________________________________________________ + __________________________________________________________________ ActiveScript This section contains notes specific to the ActiveScript installation. - ActiveScript is a windows only SAPI that enables you to use PHP script + ActiveScript is a Windows only SAPI that enables you to use PHP script in any ActiveScript compliant host, like Windows Script Host, ASP/ASP.NET, Windows Script Components or Microsoft Scriptlet control. As of PHP 5.0.1, ActiveScript has been moved to the PECL repository. - You may download this PECL extension DLL from the PHP Downloads page - or at http://snaps.php.net/. + The DLL for this PECL extension may be downloaded from either the PHP + Downloads page or from http://pecl4win.php.net/ Note: You should read the manual installation steps first! @@ -471,11 +549,15 @@ Save and double-click on the file. If you receive a little window saying "Hello World!" you're done. - Note: ActiveScript doesn't use the default php.ini file. Instead, - it will look only in the same directory as the .exe that caused it - to load. You should create php-activescript.ini and place it in - that folder, if you wish to load extensions, etc. - _________________________________________________________________ + Note: In PHP 4, the engine was named 'ActivePHP', so if you are + using PHP 4, you should replace 'PHPScript' with 'ActivePHP' in the + above example. + + Note: ActiveScript doesn't use the default php.ini file. Instead, it + will look only in the same directory as the .exe that caused it to + load. You should create php-activescript.ini and place it in that + folder, if you wish to load extensions, etc. + __________________________________________________________________ Microsoft IIS / PWS @@ -487,29 +569,32 @@ By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section to learn how to defend yourself from those attacks. - _________________________________________________________________ + __________________________________________________________________ -General considerations for all installations of PHP with IIS +General considerations for all installations of PHP with IIS or PWS * First, read the Manual Installation Instructions. Do not skip this step as it provides crucial information for installing PHP on Windows. - * CGI users must set the cgi.force_redirect PHP directive to 0 - inside php.ini. Read the faq on cgi.force_redirect for important - details. Also, CGI users should set the cgi.redirect_status_env - directive to ENV_VAR_NAME. Be sure these directives aren't + * CGI users must set the cgi.force_redirect PHP directive to 0 inside + php.ini. Read the faq on cgi.force_redirect for important details. + Also, CGI users may want to set the cgi.redirect_status_env + directive. When using directives, be sure these directives aren't commented out inside php.ini. * The PHP 4 CGI is named php.exe while in PHP 5 it's php-cgi.exe. In PHP 5, php.exe is the CLI, and not the CGI. * Modify the Windows PATH environment variable to include the PHP - directory. This way the PHP DLL files, PHP executables, and - php.ini can all remain in the PHP directory without cluttering up - the Windows system directory. For more details, see the FAQ on - Setting the PATH. + directory. This way the PHP DLL files and PHP executables can all + remain in the PHP directory without cluttering up the Windows + system directory. For more details, see the FAQ on Setting the + PATH. + * The IIS user (usually IUSR_MACHINENAME) needs permission to read + various files and directories, such as php.ini, docroot, and the + session tmp directory. * Be sure the extension_dir and doc_root PHP directives are - appropriately set in php.ini. These directives depend on the - system that PHP is being installed on. In PHP 4, the extension_dir - is extensions while with PHP 5 it's ext. So, an example PHP 5 + appropriately set in php.ini. These directives depend on the system + that PHP is being installed on. In PHP 4, the extension_dir is + extensions while with PHP 5 it's ext. So, an example PHP 5 extensions_dir value is "c:\php\ext" and an example IIS doc_root value is "c:\Inetpub\wwwroot". * PHP extension DLL files, such as php_mysql.dll and php_curl.dll, @@ -521,9 +606,9 @@ also be checked. For a small performance penalty, the IIS (or PWS) will check that the script file exists and sort out authentication before firing up PHP. This means that the web server will provide - sensible 404 style error messages instead of CGI errors - complaining that PHP did not output any data. - _________________________________________________________________ + sensible 404 style error messages instead of CGI errors complaining + that PHP did not output any data. + __________________________________________________________________ Windows NT/200x/XP and IIS 4 or newer @@ -532,20 +617,18 @@ appear as 'Internet Services Manager', either in your Windows NT 4.0 Option Pack branch or the Control Panel=>Administrative Tools under Windows 2000/XP). Then right click on your Web server node (this will - most probably appear as 'Default Web Server'), and select - 'Properties'. + most probably appear as 'Default Web Server'), and select 'Properties'. If you want to use the CGI binary, do the following: - * Under 'Home Directory', 'Virtual Directory', or 'Directory', do - the following: + * Under 'Home Directory', 'Virtual Directory', or 'Directory', do the + following: * Change the Execute Permissions to 'Scripts only' * Click on the 'Configuration' button, and choose the Application Mappings tab. Click Add and set the Executable path to the - appropriate CGI file. An example PHP 5 value is: - C:\php\php-cgi.exe Supply .php as the extension. Leave 'Method - exclusions' blank, and check the 'Script engine' checkbox. Now, - click OK a few times. + appropriate CGI file. An example PHP 5 value is: C:\php\php-cgi.exe + Supply .php as the extension. Leave 'Method exclusions' blank, and + check the 'Script engine' checkbox. Now, click OK a few times. * Set up the appropriate security. (This is done in Internet Service Manager), and if your NT Server uses NTFS file system, add execute rights for I_USR_ to the directory that contains php.exe / @@ -553,12 +636,12 @@ To use the ISAPI module, do the following: - * If you don't want to perform HTTP Authentication using PHP, you - can (and should) skip this step. Under ISAPI Filters, add a new - ISAPI filter. Use PHP as the filter name, and supply a path to the + * If you don't want to perform HTTP Authentication using PHP, you can + (and should) skip this step. Under ISAPI Filters, add a new ISAPI + filter. Use PHP as the filter name, and supply a path to the php4isapi.dll / php5isapi.dll. - * Under 'Home Directory', 'Virtual Directory', or 'Directory', do - the following: + * Under 'Home Directory', 'Virtual Directory', or 'Directory', do the + following: * Change the Execute Permissions to 'Scripts only' * Click on the 'Configuration' button, and choose the Application Mappings tab. Click Add and set the Executable path to the @@ -573,8 +656,7 @@ Extensions, choose "Add a new Web service extension", enter in a name such as PHP, choose the Add button and for the value browse to either the ISAPI file (php4isapi.dll or php5isapi.dll) or CGI (php.exe or - php-cgi.exe) then check "Set extension status to Allowed" and click - OK. + php-cgi.exe) then check "Set extension status to Allowed" and click OK. In order to use index.php as a default content page, do the following: From within the Documents tab, choose Add. Type in index.php and click @@ -582,39 +664,39 @@ to setting DirectoryIndex with Apache. The steps above must be repeated for each extension that is to be - associated with PHP scripts. .php is the most common although .php3 - may be required for legacy applications. + associated with PHP scripts. .php is the most common although .php3 may + be required for legacy applications. If you experience 100% CPU usage after some time, turn off the IIS setting Cache ISAPI Application. - _________________________________________________________________ + __________________________________________________________________ Windows and PWS 4 PWS 4 does not support ISAPI, only PHP CGI should be used. - * Edit the enclosed pws-php4cgi.reg / pws-php5cgi.reg file (look - into the SAPI folder for PHP 4, or in the main folder for PHP 5) - to reflect the location of your php.exe / php-cgi.exe. Backslashes + * Edit the enclosed pws-php4cgi.reg / pws-php5cgi.reg file (look into + the SAPI folder for PHP 4, or in the main folder for PHP 5) to + reflect the location of your php.exe / php-cgi.exe. Backslashes should be escaped, for example: - [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parame - ters\Script Map] ".php"="C:\\php\\php.exe" (change to + [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\paramet + ers\Script Map] ".php"="C:\\php\\php.exe" (change to C:\\php\\php-cgi.exe if you are using PHP 5) Now merge this - registery file into your system; you may do this by - double-clicking it. + registery file into your system; you may do this by double-clicking + it. * In the PWS Manager, right click on a given directory you want to add PHP support to, and select Properties. Check the 'Execute' checkbox, and confirm. - _________________________________________________________________ + __________________________________________________________________ Windows and PWS/IIS 3 The recommended method for configuring these servers is to use the REG - file included with the distribution (pws-php4cgi.reg in the SAPI - folder for PHP 4, or pws-php5cgi.reg in the main folder for PHP 5). - You may want to edit this file and make sure the extensions and PHP - install directories match your configuration. Or you can follow the - steps below to do it manually. + file included with the distribution (pws-php4cgi.reg in the SAPI folder + for PHP 4, or pws-php5cgi.reg in the main folder for PHP 5). You may + want to edit this file and make sure the extensions and PHP install + directories match your configuration. Or you can follow the steps below + to do it manually. Warning @@ -630,8 +712,8 @@ * Type in the extension you wish to use for your php scripts. For example .php * Double click on the new string value and enter the path to php.exe - in the value data field. ex: C:\php\php.exe for PHP 4, or - C:\php\php-cgi.exe for PHP 5. + in the value data field. ex: C:\php\php.exe "%s" %s for PHP 4, or + C:\php\php-cgi.exe "%s" %s for PHP 5. * Repeat these steps for each extension you wish to associate with PHP scripts. @@ -664,31 +746,30 @@ * If using PWS on Windows, reboot to reload the registry. PWS and IIS 3 users now have a fully operational system. IIS 3 users - can use a nifty tool from Steven Genusa to configure their script - maps. - _________________________________________________________________ + can use a nifty tool from Steven Genusa to configure their script maps. + __________________________________________________________________ Apache 1.3.x on Microsoft Windows - This section contains notes and hints specific to Apache 1.3.x - installs of PHP on Microsoft Windows systems. There are also - instructions and notes for Apache 2 on a separate page. + This section contains notes and hints specific to Apache 1.3.x installs + of PHP on Microsoft Windows systems. There are also instructions and + notes for Apache 2 on a separate page. Note: Please read the manual installation steps first! There are two ways to set up PHP to work with Apache 1.3.x on Windows. - One is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for - PHP 5), the other is to use the Apache Module DLL. In either case you - need to edit your httpd.conf to configure Apache to work with PHP, and - then restart the server. + One is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for PHP + 5), the other is to use the Apache Module DLL. In either case you need + to edit your httpd.conf to configure Apache to work with PHP, and then + restart the server. It is worth noting here that now the SAPI module has been made more - stable under Windows, we recommend it's use above the CGI binary, - since it is more transparent and secure. + stable under Windows, we recommend it's use above the CGI binary, since + it is more transparent and secure. - Although there can be a few variations of configuring PHP under - Apache, these are simple enough to be used by the newcomer. Please - consult the Apache Documentation for further configuration directives. + Although there can be a few variations of configuring PHP under Apache, + these are simple enough to be used by the newcomer. Please consult the + Apache Documentation for further configuration directives. After changing the configuration file, remember to restart the server, for example, NET STOP APACHE followed by NET START APACHE, if you run @@ -697,8 +778,9 @@ Note: Remember that when adding path values in the Apache configuration files on Windows, all backslashes such as c:\directory\file.ext must be converted to forward slashes, as - c:/directory/file.ext. - _________________________________________________________________ + c:/directory/file.ext. A trailing slash may also be necessary for + directories. + __________________________________________________________________ Installing as an Apache module @@ -706,19 +788,20 @@ Example 2-3. PHP as an Apache 1.3.x module - This assumes PHP is installed to c:\php. Adjust the path if this is - not the case. + This assumes PHP is installed to c:\php. Adjust the path if this is not + the case. For PHP 4: # Add to the end of the LoadModule section -LoadModule php4_module "c:/php/php4apache.dll" +# Don't forget to copy this file from the sapi directory! +LoadModule php4_module "C:/php/php4apache.dll" # Add to the end of the AddModule section AddModule mod_php4.c For PHP 5: # Add to the end of the LoadModule section -LoadModule php5_module "c:/php/php5apache.dll" +LoadModule php5_module "C:/php/php5apache.dll" # Add to the end of the AddModule section AddModule mod_php5.c @@ -729,7 +812,7 @@ # For syntax highlighted .phps files, also add AddType application/x-httpd-php-source .phps - _________________________________________________________________ + __________________________________________________________________ Installing as a CGI binary @@ -760,31 +843,36 @@ attacks. Please read our CGI security section to learn how to defend yourself from those attacks. - If you would like to present PHP source files syntax highlighted, - there is no such convenient option as with the module version of PHP. - If you chose to configure Apache to use PHP as a CGI binary, you will - need to use the highlight_file() function. To do this simply create a - PHP script file and add this code: <?php + If you would like to present PHP source files syntax highlighted, there + is no such convenient option as with the module version of PHP. If you + chose to configure Apache to use PHP as a CGI binary, you will need to + use the highlight_file() function. To do this simply create a PHP + script file and add this code: <?php highlight_file('some_php_script.php'); ?>. - _________________________________________________________________ + __________________________________________________________________ Apache 2.0.x on Microsoft Windows - This section contains notes and hints specific to Apache 2.0.x - installs of PHP on Microsoft Windows systems. We also have - instructions and notes for Apache 1.3.x users on a separate page. + This section contains notes and hints specific to Apache 2.0.x installs + of PHP on Microsoft Windows systems. We also have instructions and + notes for Apache 1.3.x users on a separate page. Note: You should read the manual installation steps first! + Apache 2.2.x Support: Users of Apache 2.2.x may use the + documentation below except the appropriate DLL file is named + php5apache2_2.dll and it only exists as of PHP 5.2.0. See also + http://snaps.php.net/ + Warning We do not recommend using a threaded MPM in production with Apache2. Use the prefork MPM instead, or use Apache1. For information on why, - read the following FAQ entry + read the related FAQ entry on using Apache2 with a threaded MPM - You are highly encouraged to take a look at the Apache Documentation - to get a basic understanding of the Apache 2.0.x Server. Also consider - to read the Windows specific notes for Apache 2.0.x before reading on + You are highly encouraged to take a look at the Apache Documentation to + get a basic understanding of the Apache 2.0.x Server. Also consider to + read the Windows specific notes for Apache 2.0.x before reading on here. PHP and Apache 2.0.x compatibility notes: The following versions of @@ -792,17 +880,17 @@ * PHP 4.3.0 or later available at http://www.php.net/downloads.php. * the latest stable development version. Get the source code - http://snaps.php.net/php4-latest.tar.gz or download binaries for - Windows http://snaps.php.net/win32/php4-win32-latest.zip. + http://snaps.php.net/php5-latest.tar.gz or download binaries for + Windows http://snaps.php.net/win32/php5-win32-latest.zip. * a prerelease version downloadable from http://qa.php.net/. * you have always the option to obtain PHP through anonymous CVS. These versions of PHP are compatible to Apache 2.0.40 and later. - Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works - with Apache 2.0.39, don't use any other version of Apache with PHP - 4.2.3. However, the recommended setup is to use PHP 4.3.0 or later - with the most recent version of Apache2. + Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works with + Apache 2.0.39, don't use any other version of Apache with PHP 4.2.3. + However, the recommended setup is to use PHP 4.3.0 or later with the + most recent version of Apache2. All mentioned versions of PHP will work still with Apache 1.3.x. @@ -817,15 +905,16 @@ with the integration of PHP and Apache. There are two ways to set up PHP to work with Apache 2.0.x on Windows. - One is to use the CGI binary the other is to use the Apache module - DLL. In either case you need to edit your httpd.conf to configure - Apache to work with PHP and then restart the server. + One is to use the CGI binary the other is to use the Apache module DLL. + In either case you need to edit your httpd.conf to configure Apache to + work with PHP and then restart the server. Note: Remember that when adding path values in the Apache configuration files on Windows, all backslashes such as c:\directory\file.ext must be converted to forward slashes, as - c:/directory/file.ext. - _________________________________________________________________ + c:/directory/file.ext. A trailing slash may also be necessary for + directories. + __________________________________________________________________ Installing as a CGI binary @@ -847,7 +936,7 @@ By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section to learn how to defend yourself from those attacks. - _________________________________________________________________ + __________________________________________________________________ Installing as an Apache module @@ -857,6 +946,7 @@ Example 2-6. PHP and Apache 2.0 as Module # For PHP 4 do something like this: LoadModule php4_module "c:/php/php4apache2.dll" +# Don't forget to copy the php4apache2.dll file from the sapi directory! AddType application/x-httpd-php .php # For PHP 5 do something like this: @@ -866,32 +956,32 @@ # configure the path to php.ini PHPIniDir "C:/php" - Note: Remember to substitute the c:/php/ for your actual path to - PHP in the above examples. Take care to use either php4apache2.dll - or php5apache2.dll in your LoadModule directive and not - php4apache.dll or php5apache.dll as the latter ones are designed to - run with Apache 1.3.x. + Note: Remember to substitute your actual path to PHP for the c:/php/ + in the above examples. Take care to use either php4apache2.dll or + php5apache2.dll in your LoadModule directive and not php4apache.dll + or php5apache.dll as the latter ones are designed to run with Apache + 1.3.x. Note: If you want to use content negotiation, read related FAQ. Warning Don't mix up your installation with DLL files from different PHP - versions. You have the only choice to use the DLL's and extensions - that ship with your downloaded PHP version. - _________________________________________________________________ + versions. You have the only choice to use the DLL's and extensions that + ship with your downloaded PHP version. + __________________________________________________________________ Sun, iPlanet and Netscape servers on Microsoft Windows This section contains notes and hints specific to Sun Java System Web - Server, Sun ONE Web Server, iPlanet and Netscape server installs of - PHP on Windows. + Server, Sun ONE Web Server, iPlanet and Netscape server installs of PHP + on Windows. From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to generate custom directory listings and error pages. Additional functions for Apache compatibility are also available. For support in - current webservers read the note about subrequests. - _________________________________________________________________ + current web servers read the note about subrequests. + __________________________________________________________________ CGI setup on Sun, iPlanet and Netscape servers @@ -916,7 +1006,7 @@ More details about setting up PHP as a CGI executable can be found here: http://benoit.noss.free.fr/php/install-php.html - _________________________________________________________________ + __________________________________________________________________ NSAPI setup on Sun, iPlanet and Netscape servers @@ -937,20 +1027,20 @@ and add the following: You should place the lines after mime types init. -Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c: -/php/sapi/php4nsapi.dll" -Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php -_ini="c:/path/to/php.ini"] +Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:/ +php/sapi/php4nsapi.dll" +Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php_ +ini="c:/path/to/php.ini"] (PHP >= 4.3.3) The php_ini parameter is optional but with it you - can place your php.ini in your webserver config directory. + can place your php.ini in your web server configuration directory. * Configure the default object in obj.conf (for virtual server classes [Sun Web Server 6.0+] in their vserver.obj.conf): In the <Object name="default"> section, place this line necessarily after all 'ObjectType' and before all 'AddLog' lines: -Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inik -ey=value ...] +Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inike +y=value ...] (PHP >= 4.3.3) As additional parameters you can add some special php.ini-values, for example you can set a @@ -977,31 +1067,30 @@ found here: http://benoit.noss.free.fr/php/install-php4.html Note: The stacksize that PHP uses depends on the configuration of - the webserver. If you get crashes with very large PHP scripts, it + the web server. If you get crashes with very large PHP scripts, it is recommended to raise it with the Admin Server (in the section "MAGNUS EDITOR"). - _________________________________________________________________ + __________________________________________________________________ CGI environment and recommended modifications in php.ini Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE WS/iPlanet/Netscape is a multithreaded web server. Because of that all - requests are running in the same process space (the space of the - webserver itself) and this space has only one environment. If you want - to get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the - correct way to try this in the old PHP 3.x way with getenv() or a - similar way (register globals to environment, $_ENV). You would only - get the environment of the running webserver without any valid CGI - variables! + requests are running in the same process space (the space of the web + server itself) and this space has only one environment. If you want to + get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the correct + way to try this in the old PHP 3.x way with getenv() or a similar way + (register globals to environment, $_ENV). You would only get the + environment of the running web server without any valid CGI variables! Note: Why are there (invalid) CGI variables in the environment? - Answer: This is because you started the webserver process from the - admin server which runs the startup script of the webserver, you + Answer: This is because you started the web server process from the + admin server which runs the startup script of the web server, you wanted to start, as a CGI script (a CGI script inside of the admin - server!). This is why the environment of the started webserver has + server!). This is why the environment of the started web server has some CGI environment variables in it. You can test this by starting - the webserver not from the administration server. Use the command + the web server not from the administration server. Use the command line as root user and start it manually - you will see there are no CGI-like environment variables. @@ -1012,15 +1101,15 @@ it, because you do not need the environment here): variables_order = "GPCS" register_globals = On - _________________________________________________________________ + __________________________________________________________________ Special use for error pages or self-made directory listings (PHP >= 4.3.3) You can use PHP to generate the error pages for "404 Not Found" or similar. Add the following line to the object in obj.conf for every error page you want to overwrite: -Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value ini -key=value...] +Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inik +ey=value...] where XXX is the HTTP error code. Please delete any other Error directives which could interfere with yours. If you want to place a @@ -1029,21 +1118,21 @@ Another possibility is to generate self-made directory listings. Just create a PHP script which displays a directory listing and replace the - corresponding default Service line for - type="magnus-internal/directory" in obj.conf with the following: -Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scr -ipt.php" [inikey=value inikey=value...] + corresponding default Service line for type="magnus-internal/directory" + in obj.conf with the following: +Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scri +pt.php" [inikey=value inikey=value...] For both error and directory listing pages the original URI and translated URI are in the variables $_SERVER['PATH_INFO'] and $_SERVER['PATH_TRANSLATED']. - _________________________________________________________________ + __________________________________________________________________ Note about nsapi_virtual() and subrequests (PHP >= 4.3.3) The NSAPI module now supports the nsapi_virtual() function (alias: - virtual()) to make subrequests on the webserver and insert the result - in the webpage. The problem is, that this function uses some + virtual()) to make subrequests on the web server and insert the result + in the web page. The problem is, that this function uses some undocumented features from the NSAPI library. Under Unix this is not a problem, because the module automatically @@ -1060,18 +1149,17 @@ Init fn=php4_init ... server_lib="ns-httpdXX.dll" where XX is the correct DLL version number. To get it, look in the - server-root for the correct DLL name. The DLL with the biggest - filesize is the right one. + server-root for the correct DLL name. The DLL with the biggest filesize + is the right one. You can check the status by using the phpinfo() function. Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!! - _________________________________________________________________ + __________________________________________________________________ OmniHTTPd Server - This section contains notes and hints specific to OmniHTTPd on - Windows. + This section contains notes and hints specific to OmniHTTPd on Windows. Note: You should read the manual installation steps first! @@ -1096,8 +1184,8 @@ 4. On the 'External' tab, enter: virtual = .php | actual = c:\php\php.exe (use php-cgi.exe if installing PHP 5), and use the Add button. - 5. On the Mime tab, enter: virtual = wwwserver/stdcgi | actual = - .php, and use the Add button. + 5. On the Mime tab, enter: virtual = wwwserver/stdcgi | actual = .php, + and use the Add button. 6. Click OK Repeat steps 2 - 6 for each extension you want to associate with PHP. @@ -1109,12 +1197,12 @@ choose not to set up the built in support, but install your own. If the server is already on your machine, use the Replace button in Step 4 and 5 to set the new, correct information. - _________________________________________________________________ + __________________________________________________________________ Sambar Server on Microsoft Windows - This section contains notes and hints specific to the Sambar Server - for Windows. + This section contains notes and hints specific to the Sambar Server for + Windows. Note: You should read the manual installation steps first! @@ -1134,7 +1222,15 @@ (This line assumes that PHP was installed in c:\php.) * Now restart the Sambar server for the changes to take effect. - _________________________________________________________________ + + Note: If you intend to use PHP to communicate with resources which + are held on a different computer on your network, then you will need + to alter the account used by the Sambar Server Service. The default + account used for the Sambar Server Service is LocalSystem which will + not have access to remote resources. The account can be amended by + using the Services option from within the Windows Control Panel + Administation Tools. + __________________________________________________________________ Xitami on Microsoft Windows @@ -1156,44 +1252,50 @@ attacks. Please read our CGI security section to learn how to defend yourself from those attacks. - * Make sure the webserver is running, and point your browser to + * Make sure the web server is running, and point your browser to xitamis admin console (usually http://127.0.0.1/admin), and click on Configuration. * Navigate to the Filters, and put the extension which PHP should parse (i.e. .php) into the field File extensions (.xxx). * In Filter command or script put the path and name of your PHP CGI - executable i.e. C:\php\php.exe for PHP 4, or C:\php\php-cgi.exe - for PHP 5. + executable i.e. C:\php\php.exe for PHP 4, or C:\php\php-cgi.exe for + PHP 5. * Press the 'Save' icon. * Restart the server to reflect changes. - _________________________________________________________________ + __________________________________________________________________ Installation of extensions on Windows - After installing PHP and a webserver on Windows, you will probably - want to install some extensions for added functionality. You can - choose which extensions you would like to load when PHP starts by - modifying your php.ini. You can also load a module dynamically in your - script using dl(). + After installing PHP and a web server on Windows, you will probably + want to install some extensions for added functionality. You can choose + which extensions you would like to load when PHP starts by modifying + your php.ini. You can also load a module dynamically in your script + using dl(). The DLLs for PHP extensions are prefixed with php_. - Note: In PHP 4.3.1 BCMath, Calendar, COM, Ctype, FTP, MySQL, ODBC, - Overload, PCRE, Session, Tokenizer, WDDX, XML and Zlib support is - built in. You don't need to load any additional extensions in order - to use these functions. See your distributions README.txt or - install.txt or this table for a list of built in modules. + Many extensions are built into the Windows version of PHP. This means + additional DLL files, and the extension directive, are not used to load + these extensions. The Windows PHP Extensions table lists extensions + that require, or used to require, additional PHP DLL files. Here's a + list of built in extensions: + + In PHP 4 (updated PHP 4.3.11): BCMath, Caledar, COM, Ctype, FTP, MySQL, + ODBC, Overload, PCRE, Session, Tokenizer, WDDX, XML and Zlib + + In PHP 5 (updated PHP 5.0.4), the following changes exist. Built in: + DOM, LibXML, Iconv, SimpleXML, SPL and SQLite. And the following are no + longer built in: MySQL and Overload. - The default location PHP searches for extensions is c:\php4\extensions - in PHP 4 and c:\php5 in PHP 5. To change this setting to reflect your + The default location PHP searches for extensions is C:\php4\extensions + in PHP 4 and C:\php5 in PHP 5. To change this setting to reflect your setup of PHP edit your php.ini file: * You will need to change the extension_dir setting to point to the directory where your extensions lives, or where you have placed - your php_*.dll files. Please do not forget the last backslash. For - example: + your php_*.dll files. For example: -extension_dir = c:/php/extensions/ +extension_dir = C:\php\extensions * Enable the extension(s) in php.ini you want to use by uncommenting the extension=php_*.dll lines in php.ini. This is done by deleting @@ -1207,12 +1309,12 @@ extension=php_bz2.dll * Some of the extensions need extra DLLs to work. Couple of them can - be found in the distribution package, in the C:\php\dlls\ folder - in PHP 4 or in the main folder in PHP 5, but some, for example - Oracle (php_oci8.dll) require DLLs which are not bundled with the - distribution package. If you are installing PHP 4, copy the - bundled DLLs from C:\php\dlls folder to the main C:\php folder. - Don't forget to include C:\php in the system PATH (this process is + be found in the distribution package, in the C:\php\dlls\ folder in + PHP 4 or in the main folder in PHP 5, but some, for example Oracle + (php_oci8.dll) require DLLs which are not bundled with the + distribution package. If you are installing PHP 4, copy the bundled + DLLs from C:\php\dlls folder to the main C:\php folder. Don't + forget to include C:\php in the system PATH (this process is explained in a separate FAQ entry). * Some of these DLLs are not bundled with the PHP distribution. See each extensions documentation page for details. Also, read the @@ -1221,7 +1323,7 @@ in PECL, and these extensions require a separate download. Note: If you are running a server module version of PHP remember to - restart your webserver to reflect your changes to php.ini. + restart your web server to reflect your changes to php.ini. The following table describes some of the extensions available and required additional dlls. @@ -1229,13 +1331,12 @@ Table 2-1. PHP Extensions Extension Description Notes php_bz2.dll bzip2 compression functions None - php_calendar.dll Calendar conversion functions Built in since PHP - 4.0.3 + php_calendar.dll Calendar conversion functions Built in since PHP 4.0.3 php_cpdf.dll ClibPDF functions None php_crack.dll Crack functions None php_ctype.dll ctype family functions Built in since PHP 4.3.0 - php_curl.dll CURL, Client URL library functions Requires: - libeay32.dll, ssleay32.dll (bundled) + php_curl.dll CURL, Client URL library functions Requires: libeay32.dll, + ssleay32.dll (bundled) php_cybercash.dll Cybercash payment functions PHP <= 4.2.0 php_db.dll DBM functions Deprecated. Use DBA instead (php_dba.dll) php_dba.dll DBA: DataBase (dbm-style) Abstraction layer functions None @@ -1244,8 +1345,8 @@ php_domxml.dll DOM XML functions PHP <= 4.2.0 requires: libxml2.dll (bundled) PHP >= 4.3.0 requires: iconv.dll (bundled) php_dotnet.dll .NET functions PHP <= 4.1.1 - php_exif.dll EXIF functions php_mbstring.dll. And, php_exif.dll must - be loaded after php_mbstring.dll in php.ini. + php_exif.dll EXIF functions php_mbstring.dll. And, php_exif.dll must be + loaded after php_mbstring.dll in php.ini. php_fbsql.dll FrontBase functions PHP <= 4.2.0 php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll (bundled) @@ -1255,9 +1356,8 @@ that truecolor functions are not available in GD1, instead, use php_gd2.dll. php_gd2.dll GD library image functions GD2 - php_gettext.dll Gettext functions PHP <= 4.2.0 requires - gnu_gettext.dll (bundled), PHP >= 4.2.3 requires libintl-1.dll, - iconv.dll (bundled). + php_gettext.dll Gettext functions PHP <= 4.2.0 requires gnu_gettext.dll + (bundled), PHP >= 4.2.3 requires libintl-1.dll, iconv.dll (bundled). php_hyperwave.dll HyperWave functions None php_iconv.dll ICONV characterset conversion Requires: iconv-1.3.dll (bundled), PHP >=4.2.1 iconv.dll @@ -1298,151 +1398,172 @@ php_w32api.dll W32api functions None php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll (bundled) - php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll, - expat.dll (bundled). PHP >= 4.2.1 requires sablot.dll, expat.dll, - iconv.dll (bundled). + php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll, expat.dll + (bundled). PHP >= 4.2.1 requires sablot.dll, expat.dll, iconv.dll + (bundled). php_yaz.dll YAZ functions Requires: yaz.dll (bundled) php_zip.dll Zip File functions Read only access php_zlib.dll ZLib compression functions Built in since PHP 4.3.0 - _________________________________________________________________ + __________________________________________________________________ Chapter 3. Installation of PECL extensions Introduction to PECL Installations - PHP extensions may be installed in a variety of ways. PECL is a - repository of PHP extensions living within the PEAR structure, and the - following demonstrates how to install these extensions. + PECL is a repository of PHP extensions that are made available to you + via the PEAR packaging system. This section of the manual is intended + to demonstrate how to obtain and install PECL extensions. These instructions assume /your/phpsrcdir/ is the path to the PHP - source, and extname is the name of the PECL extension. Adjust - accordingly. These instructions also assume a familiarity with the - pear command. - - Shared extensions may be installed by including them inside of php.ini - using the extension PHP directive. See also the extensions_dir - directive, and dl(). The installation methods described below do not - automatically configure PHP to include these extensions, this step - must be done manually. - - When building PHP modules, it's important to have the appropriate - versions of the required tools (autoconf, automake, libtool, etc.) See - the Anonymous CVS Instructions for details on the required tools, and + source distribution, and that extname is the name of the PECL + extension. Adjust accordingly. These instructions also assume a + familiarity with the pear command. The information in the PEAR manual + for the pear command also applies to the pecl command. + + To be useful, a shared extension must be built, installed, and loaded. + The methods described below provide you with various instructions on + how to build and install the extensions, but they do not automatically + load them. Extensions can be loaded by adding an extension directive. + To this php.ini file, or through the use of the dl() function. + + When building PHP modules, it's important to have known-good versions + of the required tools (autoconf, automake, libtool, etc.) See the + Anonymous CVS Instructions for details on the required tools, and required versions. - _________________________________________________________________ + __________________________________________________________________ Downloading PECL extensions There are several options for downloading PECL extensions, such as: * http://pecl.php.net - Listed here is information like the ChangeLog, release - information, requirements, revisions, etc. Although not every PECL - extension has a webpage, most do. - * pear download extname - The pear command may also be used to download source files. + The PECL web site contains information about the different + extensions that are offered by the PHP Development Team. The + information available here includes: ChangeLog, release notes, + requirements and other similar details. + * pecl download extname + PECL extensions that have releases listed on the PECL web site are + available for download and installation using the pecl command. Specific revisions may also be specified. * CVS - All PECL files reside in CVS. A web-based view may be seen at - http://cvs.php.net/pecl/. To download straight from CVS, consider - the following where phpfi is the password for user cvsread: + Most PECL extensions also reside in CVS. A web-based view may be + seen at http://cvs.php.net/pecl/. To download straight from CVS, + the following sequence of commands may be used. Note that phpfi is + the password for user cvsread: $ cvs -d:pserver:cvsread@cvs.php.net:/repository login $ cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/extname * Windows downloads Windows users may find compiled PECL binaries by downloading the - Collection of PECL modules from the PHP Downloads page, and by - retrieving a PECL Snapshot. To compile PHP under Windows, read the - Win32 Build README. - _________________________________________________________________ + Collection of PECL modules from the PHP Downloads page, or by + retrieving a PECL Snapshot or an extension DLL on PECL4WIN. To + compile PHP under Windows, read the appropriate chapter. + __________________________________________________________________ PECL for Windows users - Like with any other PHP extension DLL, to install move the PECL - extension DLLs into the extension_dir folder and include them within - php.ini. For example: + As with any other PHP extension DLL, installation is as simple as + copying the PECL extension DLLs into the extension_dir folder and + loading them from php.ini. For example, add the following line to your + php.ini: extension=php_extname.dll After doing this, restart the web server. - _________________________________________________________________ + __________________________________________________________________ -Compiling shared PECL extensions with PEAR +Compiling shared PECL extensions with the pecl command - PEAR makes it easy to create shared PHP extensions. Using the pear + PECL makes it easy to create shared PHP extensions. Using the pecl command, do the following: - $ pear install extname + $ pecl install extname + + This will download the source for extname, compile, and install + extname.so into your extension_dir. extname.so may then be loaded via + php.ini + + By default, the pecl command will not install packages that are marked + with the alpha or beta state. If no stable packages are available, you + may install a beta package using the following command: + + $ pecl install extname-beta + + You may also install a specific version using this variant: - That will download the source for extname, and compile it on the - system. This results in an extname.so file that may then be included - in php.ini - - In case the systems preferred_state is set higher than an available - extname version, like it's set to stable and the extension is still in - beta, either alter the preferred_state via pear config-set or specify - a specific version of the PECL extension. For example: - - $ pear install extname-0.1.1 - - Regardless, pear will copy this extname.so into the extensions - directory. Adjust php.ini accordingly. - _________________________________________________________________ + $ pecl install extname-0.1 + __________________________________________________________________ Compiling shared PECL extensions with phpize - If using pear is not an option, like for building shared PECL - extensions from CVS, or for unreleased PECL packages, then creating a - shared extension may also be done by manually using the phpize - command. The pear command essentially does this but it may also be - done manually. Assuming the source file is named extname.tgz, and that - it was downloaded into the current directory, consider the following: + Sometimes, using the pecl installer is not an option. This could be + because you're behind a firewall, or it could be because the extension + you want to install is not available as a PECL compatible package, such + as unreleased extensions from CVS. If you need to build such an + extension, you can use the lower-level build tools to perform the build + manually. + + The phpize command is used to prepare the build environment for a PHP + extension. In the following sample, the sources for an extension are in + a directory named extname: -$ pear download extname -$ gzip -d < extname.tgz | tar -xvf - $ cd extname $ phpize -$ ./configure && make +$ ./configure +$ make +# make install + + A successful install will have created extname.so and put it into the + PHP extensions directory. You'll need to and adjust php.ini and add an + extension=extname.so line before you can use the extension. + + If the system is missing the phpize command, and precompiled packages + (like RPM's) are used, be sure to also install the appropriate devel + version of the PHP package as they often include the phpize command + along with the appropriate header files to build PHP and its + extensions. - Upon success, this will create extname.so and put it into the modules/ - and/or .libs/ directory within the extname/ source. Move this shared - extension (extname.so) into the PHP extensions directory, and adjust - php.ini accordingly. - _________________________________________________________________ + Execute phpize --help to display additional usage information. + __________________________________________________________________ Compiling PECL extensions statically into PHP - To statically include the extension within the PHP build, put the - extensions source into the ext/ directory found in the PHP source. For - example: + You might find that you need to build a PECL extension statically into + your PHP binary. To do this, you'll need to place the extension source + under the php-src/ext/ directory and tell the PHP build system to + regenerate its configure script. $ cd /your/phpsrcdir/ext -$ pear download extname +$ pecl download extname $ gzip -d < extname.tgz | tar -xvf - $ mv extname-x.x.x extname -$ rm package.xml This will result in the following directory: /your/phpsrcdir/ext/extname - From here, build PHP as normal: + From here, force PHP to rebuild the configure script, and then build + PHP as normal: $ cd /your/phpsrcdir -$ ./buildconf +$ rm configure +$ ./buildconf --force $ ./configure --help $ ./configure --with-extname --enable-someotherext --with-foobar $ make $ make install + Note: To run the 'buildconf' script you need autoconf 2.13 and + automake 1.4+ (newer versions of autoconf may work, but are not + supported). + Whether --enable-extname or --with-extname is used depends on the extension. Typically an extension that does not require external - libraries uses --enable. To be sure, run the following after - buildconf: + libraries uses --enable. To be sure, run the following after buildconf: $ ./configure --help | grep extname - _________________________________________________________________ + __________________________________________________________________ Chapter 4. Problems? @@ -1450,7 +1571,7 @@ Some problems are more common than others. The most common ones are listed in the PHP FAQ, part of this manual. - _________________________________________________________________ + __________________________________________________________________ Other problems @@ -1468,7 +1589,7 @@ system, what PHP version, what web server, if you are running PHP as CGI or a server module, safe mode, etc...), and preferably enough code to make others able to reproduce and test your problem. - _________________________________________________________________ + __________________________________________________________________ Bug reports @@ -1481,37 +1602,52 @@ Read the How to report a bug document before submitting any bug reports! - _________________________________________________________________ + __________________________________________________________________ Chapter 5. Runtime Configuration The configuration file - The configuration file (called php3.ini in PHP 3, and simply php.ini - as of PHP 4) is read when PHP starts up. For the server module - versions of PHP, this happens only once when the web server is - started. For the CGI and CLI version, it happens on every invocation. - - The default location of php.ini is a compile time option (see the FAQ - entry), but can be changed for the CGI and CLI version with the -c - command line switch, see the chapter about using PHP from the command - line. You can also use the environment variable PHPRC for an - additional path to search for a php.ini file. + The configuration file (called php3.ini in PHP 3, and simply php.ini as + of PHP 4) is read when PHP starts up. For the server module versions of + PHP, this happens only once when the web server is started. For the CGI + and CLI version, it happens on every invocation. + + php.ini is searched in these locations (in order): + + * SAPI module specific location (PHPIniDir directive in Apache 2, -c + command line option in CGI and CLI, php_ini parameter in NSAPI, + PHP_INI_PATH environment variable in THTTPD) + * The PHPRC environment variable. Before PHP 5.2.0 this was checked + after the registry key mentioned below. + * As of PHP 5.2.0, the following registry locations are searched in + order: HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z\IniFilePath, + HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y\IniFilePath and + HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x\IniFilePath, where x, y and z + mean the PHP major, minor and release versions. + * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry + location) + * Current working directory (except CLI) + * The web server's directory (for SAPI modules), or directory of PHP + (otherwise in Windows) + * Windows directory (C:\windows or C:\winnt) (for Windows), or + --with-config-file-path compile time option If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is - e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini. + e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini. SAPI + name can be determined by php_sapi_name(). - Note: The Apache web server changes the directory to root at - startup causing PHP to attempt to read php.ini from the root - filesystem if it exists. + Note: The Apache web server changes the directory to root at startup + causing PHP to attempt to read php.ini from the root filesystem if + it exists. The php.ini directives handled by extensions are documented - respectively on the pages of the extensions themselves. The list of - the core directives is available in the appendix. Probably not all the - PHP directives are documented in the manual though. For a completel - list of directives available in your PHP version, please read your - well commented php.ini file. Alternatively, you may find the the - latest php.ini from CVS helpful too. + respectively on the pages of the extensions themselves. The list of the + core directives is available in the appendix. Probably not all PHP + directives are documented in the manual though. For a complete list of + directives available in your PHP version, please read your well + commented php.ini file. Alternatively, you may find the the latest + php.ini from CVS helpful too. Example 5-1. php.ini example ; any text on a line after an unquoted semicolon (;) is ignored @@ -1527,7 +1663,11 @@ ; backslashes are treated the same as any other character include_path = ".;c:\php\lib" - _________________________________________________________________ + + Since PHP 5.1.0, it is possible to refer to existing .ini variables + from within .ini files. Example: open_basedir = ${open_basedir} + ":/new/dir". + __________________________________________________________________ How to change configuration settings @@ -1540,17 +1680,17 @@ With PHP 4 and PHP 5, there are several Apache directives that allow you to change the PHP configuration from within the Apache - configuration files. For a listing of which directives are - PHP_INI_ALL, PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the - List of php.ini directives appendix. + configuration files. For a listing of which directives are PHP_INI_ALL, + PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the List of php.ini + directives appendix. Note: With PHP 3, there are Apache directives that correspond to each configuration setting in the php3.ini name, except the name is prefixed by "php3_". php_value name value - Sets the value of the specified directive. Can be used only - with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a + Sets the value of the specified directive. Can be used only with + PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a previously set value use none as the value. Note: Don't use php_value to set boolean values. php_flag (see @@ -1563,14 +1703,14 @@ php_admin_value name value Sets the value of the specified directive. This can not be used in .htaccess files. Any directive type set with php_admin_value - can not be overridden by .htaccess or virtualhost directives. - To clear a previously set value use none as the value. + can not be overridden by .htaccess or virtualhost directives. To + clear a previously set value use none as the value. php_admin_flag name on|off Used to set a boolean configuration directive. This can not be used in .htaccess files. Any directive type set with - php_admin_flag can not be overridden by .htaccess or - virtualhost directives. + php_admin_flag can not be overridden by .htaccess or virtualhost + directives. Example 5-2. Apache configuration example <IfModule mod_php5.c> @@ -1593,7 +1733,7 @@ error_reporting directive as they will have no meaning and will evaluate to 0. Use the associated bitmask values instead. These constants can be used in php.ini - _________________________________________________________________ + __________________________________________________________________ Changing PHP configuration via the Windows registry @@ -1607,18 +1747,430 @@ active for any script running from this directory or any subdirectory of it. The values under the key should have the name of the PHP configuration directive and the string value. PHP constants in the - values are not parsed. However, only configuration values changeable - in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not. - _________________________________________________________________ + values are not parsed. However, only configuration values changeable in + PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not. + __________________________________________________________________ Other interfaces to PHP - Regardless of how you run PHP, you can change certain values at - runtime of your scripts through ini_set(). See the documentation on - the ini_set() page for more information. + Regardless of how you run PHP, you can change certain values at runtime + of your scripts through ini_set(). See the documentation on the + ini_set() page for more information. If you are interested in a complete list of configuration settings on your system with their current values, you can execute the phpinfo() - function, and review the resulting page. You can also access the - values of individual configuration directives at runtime using - ini_get() or get_cfg_var(). + function, and review the resulting page. You can also access the values + of individual configuration directives at runtime using ini_get() or + get_cfg_var(). + __________________________________________________________________ + +Chapter 6. Installation FAQ + + 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 Installing PHP. + + 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 get the + message 'Document Contains No Data'! What's going on here? + + 4. Unix: I installed PHP using RPMS, but Apache isn't processing the + PHP pages! What's going on here? + + 5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the + database support I need! What's going on here? + + 6. Unix: I patched Apache with the FrontPage extensions patch, and + suddenly PHP stopped working. Is PHP incompatible with the + Apache FrontPage extensions? + + 7. Unix/Windows: I have installed PHP, but when I try to access a PHP + script file via my browser, I get a blank screen. + + 8. Unix/Windows: I have installed PHP, but when try to access a PHP + script file via my browser, I get a server 500 error. + + 9. Some operating systems: I have installed PHP without errors, but + when I try to start apache I get undefined symbol errors: + +[mybox:user /src/php4] root# apachectl configtest + apachectl: /usr/local/apache/bin/httpd Undefined symbols: + _compress + _uncompress + + 10. Windows: I have installed PHP, but when I to access a PHP script + file via my browser, I get the error: + +cgi error: + The specified CGI application misbehaved by not + returning a complete set of HTTP headers. + The headers it did return are: + + 11. Windows: I've followed all the instructions, but still can't get + PHP and IIS to work together! + + 12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get + the following error: Security Alert! PHP CGI cannot be accessed + directly.. + + 13. How do I know if my php.ini is being found and read? It seems like + it isn't as my changes aren't being implemented. + + 14. How do I add my PHP directory to the PATH on Windows? + 15. How do I make the php.ini file available to PHP on windows? + 16. Is it possible to use Apache content negotiation (MultiViews + option) with PHP? + + 17. Is PHP limited to process GET and POST request methods only? + + 1. 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 + 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, feet of clay are introduced into PHP's system. + + If you feel you have to use a threaded MPM, look at a FastCGI + configuration where PHP is running in its own memory space. + + And finally, this warning against using a threaded MPM is not as strong + for Windows systems because most libraries on that platform tend to be + threadsafe. + + 2. 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 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 + + And then you would copy php.ini-dist from the distribution to + /etc/php.ini and edit it to make any local changes 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 versions of Apache on the same machine. + + See also the chapter about the configuration file. + + 3. Unix: I installed PHP, but every time I load a document, I get the + message 'Document Contains No Data'! What's going on here? + + 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 (ereg() 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 + + 4. Unix: I installed PHP using RPMS, but Apache isn't processing the + PHP pages! What's going on here? + + 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_php3.c +AddModule mod_perl.c + +# Extra Modules +LoadModule php_module modules/mod_php.so +LoadModule php3_module modules/libphp3.so # for PHP 3 +LoadModule php4_module modules/libphp4.so # for PHP 4 +LoadModule perl_module modules/libperl.so + + And add: +AddType application/x-httpd-php3 .php3 # for PHP 3 +AddType application/x-httpd-php .php # for PHP 4 + + ... to the global properties, or to the properties of the VirtualDomain + you want to have PHP support added to. + + 5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the + database support I need! What's going on here? + + Due to the way PHP 3 built, it is not easy to build a complete flexible + PHP RPM. This issue is addressed in PHP 4. For PHP 3, we currently + suggest you use the mechanism described in the INSTALL.REDHAT file in + the PHP distribution. If you insist on using an RPM version of PHP 3, + read on... + + The RPM packagers are setting up the RPMS to install without database + support to simplify installations and because RPMS use /usr/ instead of + the standard /usr/local/ directory for files. You need to tell the RPM + spec file which databases to support and the location of the top-level + of your database server. + + This example will explain the process of adding support for the popular + MySQL database server, using the mod installation for Apache. + + Of course all of this information can be adjusted for any database + server that PHP supports. We will assume you installed MySQL and Apache + completely with RPMS for this example as well. + + * First remove mod_php3 : + +rpm -e mod_php3 + + * Then get the source rpm and INSTALL it, NOT --rebuild + +rpm -Uvh mod_php3-3.0.5-2.src.rpm + + * Then edit the /usr/src/redhat/SPECS/mod_php3.spec file + In the %build section add the database support you want, and the + path. + For MySQL you would add --with-mysql=/usr The %build section will + look something like this: + +./configure --prefix=/usr \ +--with-apxs=/usr/sbin/apxs \ +--with-config-file-path=/usr/lib \ +--enable-debug=no \ +--enable-safe-mode \ +--with-exec-dir=/usr/bin \ +--with-mysql=/usr \ +--with-system-regex + + * Once this modification is made then build the binary rpm as + follows: + +rpm -bb /usr/src/redhat/SPECS/mod_php3.spec + + * Then install the rpm + +rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm + + Make sure you restart Apache, and you now have PHP 3 with MySQL support + using RPM's. Note that it is probably much easier to just build from + the distribution tarball of PHP 3 and follow the instructions in + INSTALL.REDHAT found in that distribution. + + 6. Unix: I patched Apache with the FrontPage extensions patch, and + suddenly PHP stopped working. Is PHP incompatible with the Apache + FrontPage extensions? + + 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. + + 7. Unix/Windows: I have installed PHP, but when I try to access a PHP + script file via my browser, I get a blank 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 check the server + configuration against the PHP installation instructions. + + 8. Unix/Windows: I have installed PHP, but when try to access a PHP + script file via my browser, I get a server 500 error. + + 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. + + 9. Some operating systems: I have installed PHP without errors, but + when I try to start apache I get undefined symbol errors: +[mybox:user /src/php4] 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. + + 10. Windows: I have installed PHP, but when I to access a PHP script + file via my browser, I get the error: +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: + + * File permissions on your PHP script, php.exe, php4ts.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 think + it is relative to your web root directory). Note that for IIS you + can trap this error by ticking the 'check file exists' box when + setting up the script mappings 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 + permissions on your script file. + + 11. Windows: I've followed all the instructions, but still can't get + PHP and IIS to work together! + + 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. + + 12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get + the following error: Security Alert! PHP CGI cannot be accessed + directly.. + + 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. + + 13. How do I know if my php.ini is being found and read? It seems like + it isn't as my changes aren't being implemented. + + To be sure your php.ini is being read by PHP, make a call to phpinfo() + and near the top 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 than it's not being + read and you should put your php.ini in that directory. If php.ini is + included within the PATH than 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 + + 14. How do I add my PHP directory to the PATH on Windows? + + 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 + * 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 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 + * 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 systems PATH. Copying files into the Windows + system directory has long since been deprecated and may cause problems. + + 15. How do I make the php.ini file available to PHP on windows? + + 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 + + 16. Is it possible to use Apache content negotiation (MultiViews + option) with PHP? + + 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: +# PHP 4 +AddHandler php-script php +AddType text/html php + +# PHP 5 +AddHandler php5-script php +AddType text/html php + + This solution doesn't work for Apache 1 as PHP module doesn't catch + php-script. + + 17. Is PHP limited to process GET 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 GET and POST methods + should be handled, it can be achieved with this Apache configuration: +<LimitExcept GET POST> +Deny from all +</LimitExcept>
« previous php.cvs (#44007) next »