xref: /PHP-5.5/win32/install.txt (revision 44b09b80)
1Installing PHP
2     __________________________________________________________________
4   Table of Contents
5   Preface
6   1. General Installation Considerations
7   2. Installation on Windows systems
9        Manual Installation Steps
10        ActiveScript
11        Microsoft IIS
12        Apache 1.3.x on Microsoft Windows
13        Apache 2.0.x on Microsoft Windows
14        Sun, iPlanet and Netscape servers on Microsoft Windows
15        OmniHTTPd Server
16        Sambar Server on Microsoft Windows
17        Xitami on Microsoft Windows
18        Installation of extensions on Windows
20   3. Installation of PECL extensions
22        Introduction to PECL Installations
23        Downloading PECL extensions
24        PECL for Windows users
25        Compiling shared PECL extensions with the pecl command
26        Compiling shared PECL extensions with phpize
27        Compiling PECL extensions statically into PHP
29   4. Problems?
31        Read the FAQ
32        Other problems
33        Bug reports
35   5. Runtime Configuration
37        The configuration file
38        How to change configuration settings
40   6. Installation FAQ
41     __________________________________________________________________
45   These installation instructions were generated from the HTML version of
46   the PHP Manual so formatting and linking have been altered. See the
47   online and updated version at: http://php.net/install.windows
48     __________________________________________________________________
50Chapter 1. General Installation Considerations
52   Before starting the installation, first you need to know what do you
53   want to use PHP for. There are three main fields you can use PHP, as
54   described in the What can PHP do? section:
56     * Websites and web applications (server-side scripting)
57     * Command line scripting
58     * Desktop (GUI) applications
60   For the first and most common form, you need three things: PHP itself,
61   a web server and a web browser. You probably already have a web
62   browser, and depending on your operating system setup, you may also
63   have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows).
64   You may also rent webspace at a company. This way, you don't need to
65   set up anything on your own, only write your PHP scripts, upload it to
66   the server you rent, and see the results in your browser.
68   In case of setting up the server and PHP on your own, you have two
69   choices for the method of connecting PHP to the server. For many
70   servers PHP has a direct module interface (also called SAPI). These
71   servers include Apache, Microsoft Internet Information Server, Netscape
72   and iPlanet servers. Many other servers have support for ISAPI, the
73   Microsoft module interface (OmniHTTPd for example). If PHP has no
74   module support for your web server, you can always use it as a CGI or
75   FastCGI processor. This means you set up your server to use the CGI
76   executable of PHP to process all PHP file requests on the server.
78   If you are also interested to use PHP for command line scripting (e.g.
79   write scripts autogenerating some images for you offline, or processing
80   text files depending on some arguments you pass to them), you always
81   need the command line executable. For more information, read the
82   section about writing command line PHP applications. In this case, you
83   need no server and no browser.
85   With PHP you can also write desktop GUI applications using the PHP-GTK
86   extension. This is a completely different approach than writing web
87   pages, as you do not output any HTML, but manage Windows and objects
88   within them. For more information about PHP-GTK, please visit the site
89   dedicated to this extension. PHP-GTK is not included in the official
90   PHP distribution.
92   From now on, this section deals with setting up PHP for web servers on
93   Unix and Windows with server module interfaces and CGI executables. You
94   will also find information on the command line executable in the
95   following sections.
97   PHP source code and binary distributions for Windows can be found at
98   http://www.php.net/downloads.php. We recommend you to choose a mirror
99   nearest to you for downloading the distributions.
100     __________________________________________________________________
102Chapter 2. Installation on Windows systems
104   This section applies to Windows 98/Me and Windows NT/2000/XP/2003. PHP
105   will not work on 16 bit platforms such as Windows 3.1 and sometimes we
106   refer to the supported Windows platforms as Win32. Windows 95 is no
107   longer supported as of PHP 4.3.0.
109   If you have Microsoft Visual Studio, you can also build PHP from the
110   original source code.
112   Once you have PHP installed on your Windows system, you may also want
113   to load various extensions for added functionality.
115   Warning
117   There are several all-in-one installers over the Internet, but none of
118   those are endorsed by PHP.net, as we believe that the manual
119   installation is the best choice to have your system secure and
120   optimised.
121     __________________________________________________________________
123Manual Installation Steps
125   This install guide will help you manually install and configure PHP
126   with a web server on Microsoft Windows. To get started you'll need to
127   download the zip binary distribution from the downloads page at
128   http://www.php.net/downloads.php.
130   Although there are many all-in-one installation kits, we recommend you
131   take the time to setup PHP yourself as this will provide you with a
132   better understanding of the system, and enables you to install PHP
133   extensions easily when needed.
135     Upgrading from a previous PHP version: Previous editions of the
136     manual suggest moving various ini and DLL files into your SYSTEM
137     (i.e. C:\WINDOWS) folder and while this simplifies the installation
138     procedure it makes upgrading difficult. We advise you remove all of
139     these files (like php.ini and PHP related DLLs from the Windows
140     SYSTEM folder) before moving on with a new PHP installation. Be sure
141     to backup these files as you might break the entire system. The old
142     php.ini might be useful in setting up the new PHP as well. And as
143     you'll soon learn, the preferred method for installing PHP is to
144     keep all PHP related files in one directory and have this directory
145     available to your systems PATH.
147     MDAC requirements: If you use Microsoft Windows 98/NT4 download the
148     latest version of the Microsoft Data Access Components (MDAC) for
149     your platform. MDAC is available at http://msdn.microsoft.com/data/.
150     This requirement exists because ODBC is built into the distributed
151     Windows binaries.
153   The following steps should be completed on all installations before any
154   server specific instructions are performed:
156   Extract the distribution file into a directory of your choice. If you
157   are installing PHP 4, extract to C:\, as the zip file expands to a
158   foldername like php-4.3.7-Win32. If you are installing PHP 5, extract
159   to C:\php as the zip file doesn't expand as in PHP 4. You may choose a
160   different location but do not have spaces in the path (like C:\Program
161   Files\PHP) as some web servers will crash if you do.
163   The directory structure extracted from the zip is different for PHP
164   versions 4 and 5 and look like as follows:
166   Example 2-2. PHP 5 package structure
168   |
169   +--dev
170   |  |
171   |  |-php5ts.lib
172   |
173   +--ext                 -- extension DLLs for PHP
174   |  |
175   |  |-php_bz2.dll
176   |  |
177   |  |-php_cpdf.dll
178   |  |
179   |  |-..
180   |
181   +--extras
182   |  |
183   |  +--mibs             -- support files for SNMP
184   |  |
185   |  +--openssl          -- support files for Openssl
186   |  |
187   |  +--pdf-related      -- support files for PDF
188   |  |
189   |  |-mime.magic
190   |
191   +--pear                -- initial copy of PEAR
192   |
193   |
194   |-go-pear.bat          -- PEAR setup script
195   |
196   |-fdftk.dll
197   |
198   |-..
199   |
200   |-php-cgi.exe          -- CGI executable
201   |
202   |-php-win.exe          -- executes scripts without an opened command prompt
203   |
204   |-php.exe              -- CLI executable - ONLY for command line scripting
205   |
206   |-..
207   |
208   |-php.ini-development  -- development php.ini settings
209   |
210   |-php.ini-production   -- recommended php.ini settings for production
211   |
212   |-php5activescript.dll
213   |
214   |-php5apache.dll
215   |
216   |-php5apache2.dll
217   |
218   |-..
219   |
220   |-php5ts.dll           -- core PHP DLL
221   |
222   |-...
224   Notice the differences and similarities. Both PHP 4 and PHP 5 have a
225   CGI executable, a CLI executable, and server modules, but they are
226   located in different folders and/or have different names. While PHP 4
227   packages have the server modules in the sapi folder, PHP 5
228   distributions have no such directory and instead they're in the PHP
229   folder root. The supporting DLLs for the PHP 5 extensions are also not
230   in a separate directory.
232     Note: In PHP 4, you should move all files located in the dll and
233     sapi folders to the main folder (e.g. C:\php).
235   Here is a list of server modules shipped with PHP 5:
237     * sapi/php5apache2_2.dll - Apache 2.2.x module.
238     * sapi/php5apache.dll (php5apache.dll) - Apache 1.x module
239     * sapi/php5apache2.dll (php5apache2.dll) -  - Apache 2.0.x module.
240     * sapi/php5isapi.dll - ISAPI Module for ISAPI compliant web servers
241       like IIS 5.0 or newer. However the FCGI SAPI is recommended with
242       IIS
243     * sapi/php5nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape server
244       module.
246   Server modules provide significantly better performance and additional
247   functionality compared to the CGI binary. The FastCGI is significantly
248   more stable and can be faster than the ISAPI module with IIS.
249   The CLI version is designed to let you use PHP for command line
250   scripting. More information about CLI is available in the chapter
251   about using PHP from the command line.
253   Warning
255   The SAPI modules have been significantly improved as of the 4.1
256   release, however, in older systems you may encounter server errors or
257   other server modules failing, such as ASP.
259   The CGI and CLI binaries, and the web server modules all require the
260   php5ts.dll file to be available to them. You have to make
261   sure that this file can be found by your PHP installation. The search
262   order for this DLL is as follows:
264     * The same directory from where php.exe is called, or in case you use
265       a SAPI module, the web server's directory (e.g. C:\Program
266       Files\Apache Group\Apache2\bin).
267     * Any directory in your Windows PATH environment variable.
269   To make php5ts.dll available you have three options: copy
270   the file to the Windows system directory, copy the file to the web
271   server's directory, or add your PHP directory, C:\php to the PATH. For
272   better maintenance, we advise you to follow the last option, add C:\php
273   to the PATH, because it will be simpler to upgrade PHP in the future.
274   Read more about how to add your PHP directory to PATH in the
275   corresponding FAQ entry (and then don't forget to restart the computer
276   - logoff isn't enough).
278   The next step is to set up a valid configuration file for PHP, php.ini.
279   There are two ini files distributed in the zip file, php.ini-development
280   and php.ini-production. We advise you to use php.ini-production,
281   because we optimized the default settings in this file for performance,
282   and security. Read this well documented file carefully because it has
283   changes from php.ini-production that will drastically affect your setup.
284   Some examples are display_errors being off and magic_quotes_gpc being off.
285   In addition to reading these, study the ini settings and set every
286   element manually yourself. If you would like to achieve the best
287   security, then this is the way for you, although PHP works fine with
288   these default ini files. Copy your chosen ini-file to a directory that
289   PHP is able to find and rename it to php.ini. PHP searches for php.ini
290   in the locations described in the Section called The configuration file
291   in Chapter 5 section.
293   If you are running Apache 2, the simpler option is to use the PHPIniDir
294   directive (read the installation on Apache 2 page), otherwise your best
295   option is to set the PHPRC environment variable. This process is
296   explained in the following FAQ entry.
298     Note: If you're using NTFS on Windows NT, 2000, XP or 2003, make
299     sure that the user running the web server has read permissions to
300     your php.ini (e.g. make it readable by Everyone).
302   The following steps are optional:
304     * Edit your new php.ini file. If you plan to use OmniHTTPd, do not
305       follow the next step. Set the doc_root to point to your web servers
306       document_root. For example:
308doc_root = c:\inetpub\wwwroot // for IIS
310doc_root = c:\apache\htdocs // for Apache
312     * Choose the extensions you would like to load when PHP starts. See
313       the section about Windows extensions, about how to set up one, and
314       what is already built in. Note that on a new installation it is
315       advisable to first get PHP working and tested without any
316       extensions before enabling them in php.ini.
318   PHP is now setup on your system. The next step is to choose a web
319   server, and enable it to run PHP. Choose a web server from the table of
320   contents.
321     __________________________________________________________________
325   This section contains notes specific to the ActiveScript installation.
327   ActiveScript is a Windows only SAPI that enables you to use PHP script
328   in any ActiveScript compliant host, like Windows Script Host,
329   ASP/ASP.NET, Windows Script Components or Microsoft Scriptlet control.
331   As of PHP 5.0.1, ActiveScript has been moved to the PECL repository.
332   The DLL for this PECL extension may be downloaded from either the PHP
333   Downloads page or from http://pecl4win.php.net/
335     Note: You should read the manual installation steps first!
337   After installing PHP, you should download the ActiveScript DLL
338   (php5activescript.dll) and place it in the main PHP folder (e.g.
339   C:\php).
341   After having all the files needed, you must register the DLL on your
342   system. To achieve this, open a Command Prompt window (located in the
343   Start Menu). Then go to your PHP directory by typing something like cd
344   C:\php. To register the DLL just type regsvr32 php5activescript.dll.
346   To test if ActiveScript is working, create a new file, named test.wsf
347   (the extension is very important) and type:
348<job id="test">
350 <script language="PHPScript">
351  $WScript->Echo("Hello World!");
352 </script>
356   Save and double-click on the file. If you receive a little window
357   saying "Hello World!" you're done.
359     Note: In PHP 4, the engine was named 'ActivePHP', so if you are
360     using PHP 4, you should replace 'PHPScript' with 'ActivePHP' in the
361     above example.
363     Note: ActiveScript doesn't use the default php.ini file. Instead, it
364     will look only in the same directory as the .exe that caused it to
365     load. You should create php-activescript.ini and place it in that
366     folder, if you wish to load extensions, etc.
367     __________________________________________________________________
369Microsoft IIS
371   This section contains notes and hints specific to IIS (Microsoft
372   Internet Information Server).
374   Warning
376   By using the CGI setup, your server is open to several possible
377   attacks. Please read our CGI security section to learn how to defend
378   yourself from those attacks.
379     __________________________________________________________________
381General considerations for all installations of PHP with IIS
383     * First, read the Manual Installation Instructions. Do not skip this
384       step as it provides crucial information for installing PHP on
385       Windows.
386     * CGI users must set the cgi.force_redirect PHP directive to 0 inside
387       php.ini. Read the faq on cgi.force_redirect for important details.
388       Also, CGI users may want to set the cgi.redirect_status_env
389       directive. When using directives, be sure these directives aren't
390       commented out inside php.ini.
391     * The PHP 4 CGI is named php.exe while in PHP 5 it's php-cgi.exe. In
392       PHP 5, php.exe is the CLI, and not the CGI.
393     * Modify the Windows PATH environment variable to include the PHP
394       directory. This way the PHP DLL files and PHP executables can all
395       remain in the PHP directory without cluttering up the Windows
396       system directory. For more details, see the FAQ on Setting the
397       PATH.
398     * The IIS user (usually IUSR_MACHINENAME) needs permission to read
399       various files and directories, such as php.ini, docroot, and the
400       session tmp directory.
401     * Be sure the extension_dir and doc_root PHP directives are
402       appropriately set in php.ini. These directives depend on the system
403       that PHP is being installed on. In PHP 4, the extension_dir is
404       extensions while with PHP 5 it's ext. So, an example PHP 5
405       extensions_dir value is "c:\php\ext" and an example IIS doc_root
406       value is "c:\Inetpub\wwwroot".
407     * PHP extension DLL files, such as php_mysql.dll and php_curl.dll,
408       are found in the zip package of the PHP download. In PHP 5, many
409       extensions are part of PECL and can be downloaded in the
410       "Collection of PECL modules" package. Files such as php_zip.dll and
411       php_ssh2.dll. Download PHP files here.
412     * When defining the executable, the 'check that file exists' box may
413       also be checked. For a small performance penalty, the IIS
414       will check that the script file exists and sort out authentication
415       before firing up PHP. This means that the web server will provide
416       sensible 404 style error messages instead of CGI errors complaining
417       that PHP did not output any data.
418     __________________________________________________________________
420Windows NT/200x/XP and IIS 4 or newer
422   PHP may be installed as a CGI binary, or with the ISAPI module. In
423   either case, you need to start the Microsoft Management Console (may
424   appear as 'Internet Services Manager', either in your Windows NT 4.0
425   Option Pack branch or the Control Panel=>Administrative Tools under
426   Windows 2000/XP). Then right click on your Web server node (this will
427   most probably appear as 'Default Web Server'), and select 'Properties'.
429   If you want to use the CGI binary, do the following:
431     * Under 'Home Directory', 'Virtual Directory', or 'Directory', do the
432       following:
433     * Change the Execute Permissions to 'Scripts only'
434     * Click on the 'Configuration' button, and choose the Application
435       Mappings tab. Click Add and set the Executable path to the
436       appropriate CGI file. An example PHP 5 value is: C:\php\php-cgi.exe
437       Supply .php as the extension. Leave 'Method exclusions' blank, and
438       check the 'Script engine' checkbox. Now, click OK a few times.
439     * Set up the appropriate security. (This is done in Internet Service
440       Manager), and if your NT Server uses NTFS file system, add execute
441       rights for I_USR_ to the directory that contains php.exe /
442       php-cgi.exe.
444   To use the ISAPI module, do the following:
446     * If you don't want to perform HTTP Authentication using PHP, you can
447       (and should) skip this step. Under ISAPI Filters, add a new ISAPI
448       filter. Use PHP as the filter name, and supply a path to the
449       php5isapi.dll.
450     * Under 'Home Directory', 'Virtual Directory', or 'Directory', do the
451       following:
452     * Change the Execute Permissions to 'Scripts only'
453     * Click on the 'Configuration' button, and choose the Application
454       Mappings tab. Click Add and set the Executable path to the
455       appropriate ISAPI DLL. An example PHP 5 value is:
456       C:\php\php5isapi.dll Supply .php as the extension. Leave 'Method
457       exclusions' blank, and check the 'Script engine' checkbox. Now,
458       click OK a few times.
459     * Stop IIS completely (NET STOP iisadmin)
460     * Start IIS again (NET START w3svc)
462   With IIS 6 (2003 Server), open up the IIS Manager, go to Web Service
463   Extensions, choose "Add a new Web service extension", enter in a name
464   such as PHP, choose the Add button and for the value browse to either
465   the ISAPI file (php5isapi.dll) or CGI (php.exe or
466   php-cgi.exe) then check "Set extension status to Allowed" and click OK.
468   In order to use index.php as a default content page, do the following:
469   From within the Documents tab, choose Add. Type in index.php and click
470   OK. Adjust the order by choosing Move Up or Move Down. This is similar
471   to setting DirectoryIndex with Apache.
473   The steps above must be repeated for each extension that is to be
474   associated with PHP scripts. .php is the most common although .php3 may
475   be required for legacy applications.
477   If you experience 100% CPU usage after some time, turn off the IIS
478   setting Cache ISAPI Application.
479     __________________________________________________________________
481Windows and IIS
483See http://www.php.net/install.windows
484     __________________________________________________________________
486Apache 1.3.x on Microsoft Windows
488   This section contains notes and hints specific to Apache 1.3.x installs
489   of PHP on Microsoft Windows systems. There are also instructions and
490   notes for Apache 2 on a separate page.
492     Note: Please read the manual installation steps first!
494   There are two ways to set up PHP to work with Apache 1.3.x on Windows.
495   One is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for PHP
496   5), the other is to use the Apache Module DLL. In either case you need
497   to edit your httpd.conf to configure Apache to work with PHP, and then
498   restart the server.
500   It is worth noting here that now the SAPI module has been made more
501   stable under Windows, we recommend it's use above the CGI binary, since
502   it is more transparent and secure.
504   Although there can be a few variations of configuring PHP under Apache,
505   these are simple enough to be used by the newcomer. Please consult the
506   Apache Documentation for further configuration directives.
508   After changing the configuration file, remember to restart the server,
509   for example, NET STOP APACHE followed by NET START APACHE, if you run
510   Apache as a Windows Service, or use your regular shortcuts.
512     Note: Remember that when adding path values in the Apache
513     configuration files on Windows, all backslashes such as
514     c:\directory\file.ext must be converted to forward slashes, as
515     c:/directory/file.ext. A trailing slash may also be necessary for
516     directories.
517     __________________________________________________________________
519Installing as an Apache module
521   You should add the following lines to your Apache httpd.conf file:
523   Example 2-3. PHP as an Apache 1.3.x module
525   This assumes PHP is installed to c:\php. Adjust the path if this is not
526   the case.
528   For PHP 5:
529# Add to the end of the LoadModule section
530LoadModule php5_module "C:/php/php5apache.dll"
532# Add to the end of the AddModule section
533AddModule mod_php5.c
535   For both:
536# Add this line inside the <IfModule mod_mime.c> conditional brace
537AddType application/x-httpd-php .php
539# For syntax highlighted .phps files, also add
540AddType application/x-httpd-php-source .phps
541     __________________________________________________________________
543Installing as a CGI binary
545   If you unzipped the PHP package to C:\php\ as described in the Manual
546   Installation Steps section, you need to insert these lines to your
547   Apache configuration file to set up the CGI binary:
549   Example 2-4. PHP and Apache 1.3.x as CGI
550ScriptAlias /php/ "c:/php/"
551AddType application/x-httpd-php .php
553# For PHP 4
554Action application/x-httpd-php "/php/php.exe"
556# For PHP 5
557Action application/x-httpd-php "/php/php-cgi.exe"
559# specify the directory where php.ini is
560SetEnv PHPRC C:/php
562   Note that the second line in the list above can be found in the actual
563   versions of httpd.conf, but it is commented out. Remember also to
564   substitute the c:/php/ for your actual path to PHP.
566   Warning
568   By using the CGI setup, your server is open to several possible
569   attacks. Please read our CGI security section to learn how to defend
570   yourself from those attacks.
572   If you would like to present PHP source files syntax highlighted, there
573   is no such convenient option as with the module version of PHP. If you
574   chose to configure Apache to use PHP as a CGI binary, you will need to
575   use the highlight_file() function. To do this simply create a PHP
576   script file and add this code: <?php
577   highlight_file('some_php_script.php'); ?>.
578     __________________________________________________________________
580Apache 2.0.x on Microsoft Windows
582   This section contains notes and hints specific to Apache 2.0.x installs
583   of PHP on Microsoft Windows systems. We also have instructions and
584   notes for Apache 1.3.x users on a separate page.
586     Note: You should read the manual installation steps first!
588     Apache 2.2.x Support: Users of Apache 2.2.x may use the
589     documentation below except the appropriate DLL file is named
590     php5apache2_2.dll and it only exists as of PHP 5.2.0. See also
591     http://snaps.php.net/
593   Warning
595   We do not recommend using a threaded MPM in production with Apache2.
596   Use the prefork MPM instead, or use Apache1. For information on why,
597   read the related FAQ entry on using Apache2 with a threaded MPM
599   You are highly encouraged to take a look at the Apache Documentation to
600   get a basic understanding of the Apache 2.0.x Server. Also consider to
601   read the Windows specific notes for Apache 2.0.x before reading on
602   here.
604     PHP and Apache 2.0.x compatibility notes: The following versions of
605     PHP are known to work with the most recent version of Apache 2.0.x:
607     * PHP 4.3.0 or later available at http://www.php.net/downloads.php.
608     * the latest stable development version. Get the source code
609       http://snaps.php.net/php5-latest.tar.gz or download binaries for
610       Windows http://snaps.php.net/win32/php5-win32-latest.zip.
611     * a prerelease version downloadable from http://qa.php.net/.
612     * you have always the option to obtain PHP through SVN.
614     These versions of PHP are compatible to Apache 2.0.40 and later.
616     Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works with
617     Apache 2.0.39, don't use any other version of Apache with PHP 4.2.3.
618     However, the recommended setup is to use PHP 4.3.0 or later with the
619     most recent version of Apache2.
621     All mentioned versions of PHP will work still with Apache 1.3.x.
623   Warning
625   Apache 2.0.x is designed to run on Windows NT 4.0, Windows 2000 or
626   Windows XP. At this time, support for Windows 9x is incomplete. Apache
627   2.0.x is not expected to work on those platforms at this time.
629   Download the most recent version of Apache 2.0.x and a fitting PHP
630   version. Follow the Manual Installation Steps and come back to go on
631   with the integration of PHP and Apache.
633   There are two ways to set up PHP to work with Apache 2.0.x on Windows.
634   One is to use the CGI binary the other is to use the Apache module DLL.
635   In either case you need to edit your httpd.conf to configure Apache to
636   work with PHP and then restart the server.
638     Note: Remember that when adding path values in the Apache
639     configuration files on Windows, all backslashes such as
640     c:\directory\file.ext must be converted to forward slashes, as
641     c:/directory/file.ext. A trailing slash may also be necessary for
642     directories.
643     __________________________________________________________________
645Installing as a CGI binary
647   You need to insert these three lines to your Apache httpd.conf
648   configuration file to set up the CGI binary:
650   Example 2-5. PHP and Apache 2.0 as CGI
651ScriptAlias /php/ "c:/php/"
652AddType application/x-httpd-php .php
654# For PHP 4
655Action application/x-httpd-php "/php/php.exe"
657# For PHP 5
658Action application/x-httpd-php "/php/php-cgi.exe"
660   Warning
662   By using the CGI setup, your server is open to several possible
663   attacks. Please read our CGI security section to learn how to defend
664   yourself from those attacks.
665     __________________________________________________________________
667Installing as an Apache module
669   You need to insert these two lines to your Apache httpd.conf
670   configuration file to set up the PHP module for Apache 2.0:
672   Example 2-6. PHP and Apache 2.0 as Module
674# For PHP 5 do something like this:
675LoadModule php5_module "c:/php/php5apache2.dll"
676AddType application/x-httpd-php .php
678# configure the path to php.ini
679PHPIniDir "C:/php"
681     Note: Remember to substitute your actual path to PHP for the c:/php/
682     in the above examples. Take care to use either
683     php5apache2.dll in your LoadModule directive and not php5apache.dll
684     as the latter ones are designed to run with Apache 1.3.x.
686     Note: If you want to use content negotiation, read related FAQ.
688   Warning
690   Don't mix up your installation with DLL files from different PHP
691   versions. You have the only choice to use the DLL's and extensions that
692   ship with your downloaded PHP version.
693     __________________________________________________________________
695Sun, iPlanet and Netscape servers on Microsoft Windows
697   This section contains notes and hints specific to Sun Java System Web
698   Server, Sun ONE Web Server, iPlanet and Netscape server installs of PHP
699   on Windows.
701   From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to
702   generate custom directory listings and error pages. Additional
703   functions for Apache compatibility are also available. For support in
704   current web servers read the note about subrequests.
705     __________________________________________________________________
707CGI setup on Sun, iPlanet and Netscape servers
709   To install PHP as a CGI handler, do the following:
711     * Copy php5ts.dll to your systemroot (the directory where you
712       installed Windows)
713     * Make a file association from the command line. Type the following
714       two lines:
716assoc .php=PHPScript
717ftype PHPScript=c:\php\php.exe %1 %*
719     * In the Netscape Enterprise Administration Server create a dummy
720       shellcgi directory and remove it just after (this step creates 5
721       important lines in obj.conf and allow the web server to handle
722       shellcgi scripts).
723     * In the Netscape Enterprise Administration Server create a new mime
724       type (Category: type, Content-Type: magnus-internal/shellcgi, File
725       Suffix:php).
726     * Do it for each web server instance you want PHP to run
728   More details about setting up PHP as a CGI executable can be found
729   here: http://benoit.noss.free.fr/php/install-php.html
730     __________________________________________________________________
732NSAPI setup on Sun, iPlanet and Netscape servers
734   To install PHP with NSAPI, do the following:
736     * Copy php5ts.dll to your systemroot (the directory where you
737       installed Windows)
738     * Make a file association from the command line. Type the following
739       two lines:
741assoc .php=PHPScript
742ftype PHPScript=c:\php\php.exe %1 %*
744     * In the Netscape Enterprise Administration Server create a new mime
745       type (Category: type, Content-Type: magnus-internal/x-httpd-php,
746       File Suffix: php).
747     * Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6)
748       and add the following: You should place the lines after mime types
749       init.
751Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" shlib="c:/
753Init fn="php5_init" LateInit="yes" errorString="Failed to initialise PHP!" [php_
756       The php_ini parameter is optional but with it you
757       can place your php.ini in your web server configuration directory.
758     * Configure the default object in obj.conf (for virtual server
759       classes [Sun Web Server 6.0+] in their vserver.obj.conf): In the
760       <Object name="default"> section, place this line necessarily after
761       all 'ObjectType' and before all 'AddLog' lines:
763Service fn="php5_execute" type="magnus-internal/x-httpd-php" [inikey=value inike
764y=value ...]
766       As additional parameters you can add some special
767       php.ini-values, for example you can set a
768       docroot="/path/to/docroot" specific to the context php5_execute is
769       called. For boolean ini-keys please use 0/1 as value, not
770       "On","Off",... (this will not work correctly), e.g.
771       zlib.output_compression=1 instead of zlib.output_compression="On"
772     * This is only needed if you want to configure a directory that only
773       consists of PHP scripts (same like a cgi-bin directory):
775<Object name="x-httpd-php">
776ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
777Service fn=php5_execute [inikey=value inikey=value ...]
780       After that you can configure a directory in the Administration
781       server and assign it the style x-httpd-php. All files in it will
782       get executed as PHP. This is nice to hide PHP usage by renaming
783       files to .html.
784     * Restart your web service and apply changes
785     * Do it for each web server instance you want PHP to run
787     Note: More details about setting up PHP as an NSAPI filter can be
788     found here: http://benoit.noss.free.fr/php/install-php4.html
790     Note: The stacksize that PHP uses depends on the configuration of
791     the web server. If you get crashes with very large PHP scripts, it
792     is recommended to raise it with the Admin Server (in the section
793     "MAGNUS EDITOR").
794     __________________________________________________________________
796CGI environment and recommended modifications in php.ini
798   Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
799   WS/iPlanet/Netscape is a multithreaded web server. Because of that all
800   requests are running in the same process space (the space of the web
801   server itself) and this space has only one environment. If you want to
802   get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the correct
803   way to try this in the old PHP 3.x way with getenv() or a similar way
804   (register globals to environment, $_ENV). You would only get the
805   environment of the running web server without any valid CGI variables!
807     Note: Why are there (invalid) CGI variables in the environment?
809     Answer: This is because you started the web server process from the
810     admin server which runs the startup script of the web server, you
811     wanted to start, as a CGI script (a CGI script inside of the admin
812     server!). This is why the environment of the started web server has
813     some CGI environment variables in it. You can test this by starting
814     the web server not from the administration server. Use the command
815     line as root user and start it manually - you will see there are no
816     CGI-like environment variables.
817     __________________________________________________________________
819Special use for error pages or self-made directory listings (PHP >= 4.3.3)
821   You can use PHP to generate the error pages for "404 Not Found" or
822   similar. Add the following line to the object in obj.conf for every
823   error page you want to overwrite:
824Error fn="php5_execute" code=XXX script="/path/to/script.php" [inikey=value inik
827   where XXX is the HTTP error code. Please delete any other Error
828   directives which could interfere with yours. If you want to place a
829   page for all errors that could exist, leave the code parameter out.
830   Your script can get the HTTP status code with $_SERVER['ERROR_TYPE'].
832   Another possibility is to generate self-made directory listings. Just
833   create a PHP script which displays a directory listing and replace the
834   corresponding default Service line for type="magnus-internal/directory"
835   in obj.conf with the following:
836Service fn="php5_execute" type="magnus-internal/directory" script="/path/to/scri
837pt.php" [inikey=value inikey=value...]
839   For both error and directory listing pages the original URI and
840   translated URI are in the variables $_SERVER['PATH_INFO'] and
842     __________________________________________________________________
844Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)
846   The NSAPI module now supports the nsapi_virtual() function (alias:
847   virtual()) to make subrequests on the web server and insert the result
848   in the web page. The problem is, that this function uses some
849   undocumented features from the NSAPI library.
851   Under Unix this is not a problem, because the module automatically
852   looks for the needed functions and uses them if available. If not,
853   nsapi_virtual() is disabled.
855   Under Windows limitations in the DLL handling need the use of a
856   automatic detection of the most recent ns-httpdXX.dll file. This is
857   tested for servers till version 6.1. If a newer version of the Sun
858   server is used, the detection fails and nsapi_virtual() is disabled.
860   If this is the case, try the following: Add the following parameter to
861   php5_init in magnus.conf/obj.conf:
862   Init fn=php5_init ... server_lib="ns-httpdXX.dll"
864   where XX is the correct DLL version number. To get it, look in the
865   server-root for the correct DLL name. The DLL with the biggest filesize
866   is the right one.
868   You can check the status by using the phpinfo() function.
870     Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!
871     __________________________________________________________________
873OmniHTTPd Server
875   This section contains notes and hints specific to OmniHTTPd on Windows.
877     Note: You should read the manual installation steps first!
879   Warning
881   By using the CGI setup, your server is open to several possible
882   attacks. Please read our CGI security section to learn how to defend
883   yourself from those attacks.
885   You need to complete the following steps to make PHP work with
886   OmniHTTPd. This is a CGI executable setup. SAPI is supported by
887   OmniHTTPd, but some tests have shown that it is not so stable to use
888   PHP as an ISAPI module.
890     Important for CGI users: Read the faq on cgi.force_redirect for
891     important details. This directive needs to be set to 0.
893    1. Install OmniHTTPd server.
894    2. Right click on the blue OmniHTTPd icon in the system tray and
895       select Properties
896    3. Click on Web Server Global Settings
897    4. On the 'External' tab, enter: virtual = .php | actual =
898       c:\php\php.exe (use php-cgi.exe if installing PHP 5), and use the
899       Add button.
900    5. On the Mime tab, enter: virtual = wwwserver/stdcgi | actual = .php,
901       and use the Add button.
902    6. Click OK
904   Repeat steps 2 - 6 for each extension you want to associate with PHP.
906     __________________________________________________________________
908Xitami on Microsoft Windows
910   This section contains notes and hints specific to Xitami on Windows.
912     Note: You should read the manual installation steps first!
914   This list describes how to set up the PHP CGI binary to work with
915   Xitami on Windows.
917     Important for CGI users: Read the faq on cgi.force_redirect for
918     important details. This directive needs to be set to 0. If you want
919     to use $_SERVER['PHP_SELF'] you have to enable the cgi.fix_pathinfo
920     directive.
922   Warning
924   By using the CGI setup, your server is open to several possible
925   attacks. Please read our CGI security section to learn how to defend
926   yourself from those attacks.
928     * Make sure the web server is running, and point your browser to
929       xitamis admin console (usually, and click
930       on Configuration.
931     * Navigate to the Filters, and put the extension which PHP should
932       parse (i.e. .php) into the field File extensions (.xxx).
933     * In Filter command or script put the path and name of your PHP CGI
934       executable i.e. C:\php\php-cgi.exe.
935     * Press the 'Save' icon.
936     * Restart the server to reflect changes.
937     __________________________________________________________________
939Installation of extensions on Windows
941   After installing PHP and a web server on Windows, you will probably
942   want to install some extensions for added functionality. You can choose
943   which extensions you would like to load when PHP starts by modifying
944   your php.ini. You can also load a module dynamically in your script
945   using dl().
947   The DLLs for PHP extensions are prefixed with php_.
949   Many extensions are built into the Windows version of PHP. This means
950   additional DLL files, and the extension directive, are not used to load
951   these extensions. The Windows PHP Extensions table lists extensions
952   that require, or used to require, additional PHP DLL files. Here's a
953   list of built in extensions:
955   In PHP 5 (updated PHP 5.0.4), the following changes exist. Built in:
956   DOM, LibXML, Iconv, SimpleXML, SPL and SQLite. And the following are no
957   longer built in: MySQL and Overload.
959   The default location PHP searches for extensions is C:\php5 in PHP 5.
960   To change this setting to reflect your setup of PHP edit your php.ini
961   file:
963     * You will need to change the extension_dir setting to point to the
964       directory where your extensions lives, or where you have placed
965       your php_*.dll files. For example:
967extension_dir = C:\php\extensions
969     * Enable the extension(s) in php.ini you want to use by uncommenting
970       the extension=php_*.dll lines in php.ini. This is done by deleting
971       the leading ; from the extension you want to load.
973   Example 2-8. Enable Bzip2 extension for PHP-Windows
974// change the following line from ...
977// ... to
980     * Some of the extensions need extra DLLs to work. Couple of them can
981       be found in the distribution package, in in the main folder in PHP 5,
982       but some, for example Oracle (php_oci8.dll) require DLLs which are
983       not bundled with the distribution package.
984     * Some of these DLLs are not bundled with the PHP distribution. See
985       each extensions documentation page for details. Also, read the
986       manual section titled Installation of PECL extensions for details
987       on PECL. An increasingly large number of PHP extensions are found
988       in PECL, and these extensions require a separate download.
990     Note: If you are running a server module version of PHP remember to
991     restart your web server to reflect your changes to php.ini.
993   The following table describes some of the extensions available and
994   required additional dlls.
996   Table 2-1. PHP Extensions
997   Extension Description Notes
998   php_bz2.dll bzip2 compression functions None
999   php_calendar.dll Calendar conversion functions
1000   php_cpdf.dll ClibPDF functions None
1001   php_crack.dll Crack functions None
1002   php_ctype.dll ctype family functions
1003   php_curl.dll CURL, Client URL library functions Requires: libeay32.dll,
1004   ssleay32.dll (bundled)
1005   php_db.dll DBM functions Deprecated. Use DBA instead (php_dba.dll)
1006   php_dba.dll DBA: DataBase (dbm-style) Abstraction layer functions None
1007   php_dbase.dll dBase functions None
1008   php_dbx.dll dbx functions
1009   php_exif.dll EXIF functions php_mbstring.dll. And, php_exif.dll must be
1010   loaded after php_mbstring.dll in php.ini.
1011   php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll
1012   (bundled)
1013   php_filepro.dll filePro functions Read-only access
1014   php_ftp.dll FTP functions
1015   php_gd2.dll GD library image functions GD2
1016   php_gettext.dll Gettext functions, requires libintl-1.dll,
1017   iconv.dll (bundled).
1018   php_iconv.dll ICONV characterset conversion Requires: iconv.dll
1019   php_imap.dll IMAP POP3 and NNTP functions None
1020   php_interbase.dll InterBase functions Requires: gds32.dll (bundled)
1021   php_ldap.dll LDAP functions requires libeay32.dll, ssleay32.dll (bundled)
1022   php_mbstring.dll Multi-Byte String functions None
1023   php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
1024   php_mime_magic.dll Mimetype functions Requires: magic.mime (bundled)
1025   php_ming.dll Ming functions for Flash None
1026   php_msql.dll mSQL functions Requires: msql.dll (bundled)
1027   php_mssql.dll MSSQL functions Requires: ntwdblib.dll (bundled)
1028   php_mysql.dll MySQL functions PHP >= 5.0.0, requires libmysql.dll
1029   (bundled)
1030   php_mysqli.dll MySQLi functions PHP >= 5.0.0, requires libmysql.dll
1031   (libmysqli.dll in PHP <= 5.0.2) (bundled)
1032   php_oci8.dll Oracle 8 functions Requires: Oracle 8.1+ client libraries
1033   php_openssl.dll OpenSSL functions Requires: libeay32.dll (bundled)
1034   php_oracle.dll Oracle functions Requires: Oracle 7 client libraries
1035   php_pgsql.dll PostgreSQL functions None
1036   php_printer.dll Printer functions None
1037   php_shmop.dll Shared Memory functions None
1038   php_snmp.dll SNMP get and walk functions NT only!
1039   php_soap.dll SOAP functions PHP >= 5.0.0
1040   php_sockets.dll Socket functions None
1041   php_sybase_ct.dll Sybase functions Requires: Sybase client libraries
1042   php_tidy.dll Tidy functions PHP >= 5.0.0
1043   php_tokenizer.dll Tokenizer functions Built in since PHP 4.3.0
1044   php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll
1045   (bundled)
1046   php_xslt.dll XSLT requires libxslt.dll, iconv.dll (bundled).
1047   php_zip.dll Zip File functions
1048   php_zlib.dll ZLib compression functions
1049     __________________________________________________________________
1051Chapter 3. Installation of PECL extensions
1053Introduction to PECL Installations
1055   PECL is a repository of PHP extensions that are made available to you
1056   via the PEAR packaging system. This section of the manual is intended
1057   to demonstrate how to obtain and install PECL extensions.
1059   These instructions assume /your/phpsrcdir/ is the path to the PHP
1060   source distribution, and that extname is the name of the PECL
1061   extension. Adjust accordingly. These instructions also assume a
1062   familiarity with the pear command. The information in the PEAR manual
1063   for the pear command also applies to the pecl command.
1065   To be useful, a shared extension must be built, installed, and loaded.
1066   The methods described below provide you with various instructions on
1067   how to build and install the extensions, but they do not automatically
1068   load them. Extensions can be loaded by adding an extension directive.
1069   To this php.ini file, or through the use of the dl() function.
1071   When building PHP modules, it's important to have known-good versions
1072   of the required tools (autoconf, automake, libtool, etc.) See the
1073   SVN Instructions for details on the required tools, and required
1074   versions.
1075     __________________________________________________________________
1077Downloading PECL extensions
1079   There are several options for downloading PECL extensions, such as:
1081     * http://pecl.php.net
1082       The PECL web site contains information about the different
1083       extensions that are offered by the PHP Development Team. The
1084       information available here includes: ChangeLog, release notes,
1085       requirements and other similar details.
1086     * pecl download extname
1087       PECL extensions that have releases listed on the PECL web site are
1088       available for download and installation using the pecl command.
1089       Specific revisions may also be specified.
1090     * SVN
1091       Most PECL extensions also reside in SVN. A web-based view may be
1092       seen at http://svn.php.net/pecl/. To download straight from SVN,
1093       the following sequence of commands may be used.
1095$ svn  co http://svn.php.net/repository/pecl/<extname>/trunk
1097     * Windows downloads
1098       Windows users may find compiled PECL binaries by downloading the
1099       Collection of PECL modules from the PHP Downloads page, or by
1100       retrieving a PECL Snapshot or an extension DLL on PECL4WIN. To
1101       compile PHP under Windows, read the appropriate chapter.
1102     __________________________________________________________________
1104PECL for Windows users
1106   As with any other PHP extension DLL, installation is as simple as
1107   copying the PECL extension DLLs into the extension_dir folder and
1108   loading them from php.ini. For example, add the following line to your
1109   php.ini:
1111   extension=php_extname.dll
1113   After doing this, restart the web server.
1114     __________________________________________________________________
1116Compiling shared PECL extensions with the pecl command
1118   PECL makes it easy to create shared PHP extensions. Using the pecl
1119   command, do the following:
1121   $ pecl install extname
1123   This will download the source for extname, compile, and install
1124   extname.so into your extension_dir. extname.so may then be loaded via
1125   php.ini
1127   By default, the pecl command will not install packages that are marked
1128   with the alpha or beta state. If no stable packages are available, you
1129   may install a beta package using the following command:
1131   $ pecl install extname-beta
1133   You may also install a specific version using this variant:
1135   $ pecl install extname-0.1
1136     __________________________________________________________________
1138Compiling shared PECL extensions with phpize
1140   Sometimes, using the pecl installer is not an option. This could be
1141   because you're behind a firewall, or it could be because the extension
1142   you want to install is not available as a PECL compatible package, such
1143   as unreleased extensions from SVN. If you need to build such an
1144   extension, you can use the lower-level build tools to perform the build
1145   manually.
1147   The phpize command is used to prepare the build environment for a PHP
1148   extension. In the following sample, the sources for an extension are in
1149   a directory named extname:
1151$ cd extname
1152$ phpize
1153$ ./configure
1154$ make
1155# make install
1157   A successful install will have created extname.so and put it into the
1158   PHP extensions directory. You'll need to and adjust php.ini and add an
1159   extension=extname.so line before you can use the extension.
1161   If the system is missing the phpize command, and precompiled packages
1162   (like RPM's) are used, be sure to also install the appropriate devel
1163   version of the PHP package as they often include the phpize command
1164   along with the appropriate header files to build PHP and its
1165   extensions.
1167   Execute phpize --help to display additional usage information.
1168     __________________________________________________________________
1170Compiling PECL extensions statically into PHP
1172   You might find that you need to build a PECL extension statically into
1173   your PHP binary. To do this, you'll need to place the extension source
1174   under the php-src/ext/ directory and tell the PHP build system to
1175   regenerate its configure script.
1177$ cd /your/phpsrcdir/ext
1178$ pecl download extname
1179$ gzip -d < extname.tgz | tar -xvf -
1180$ mv extname-x.x.x extname
1182   This will result in the following directory:
1184   /your/phpsrcdir/ext/extname
1186   From here, force PHP to rebuild the configure script, and then build
1187   PHP as normal:
1189$ cd /your/phpsrcdir
1190$ rm configure
1191$ ./buildconf --force
1192$ ./configure --help
1193$ ./configure --with-extname --enable-someotherext --with-foobar
1194$ make
1195$ make install
1197     Note: To run the 'buildconf' script you need autoconf 2.13 and
1198     automake 1.4+ (newer versions of autoconf may work, but are not
1199     supported).
1201   Whether --enable-extname or --with-extname is used depends on the
1202   extension. Typically an extension that does not require external
1203   libraries uses --enable. To be sure, run the following after buildconf:
1205   $ ./configure --help | grep extname
1206     __________________________________________________________________
1208Chapter 4. Problems?
1210Read the FAQ
1212   Some problems are more common than others. The most common ones are
1213   listed in the PHP FAQ, part of this manual.
1214     __________________________________________________________________
1216Other problems
1218   If you are still stuck, someone on the PHP installation mailing list
1219   may be able to help you. You should check out the archive first, in
1220   case someone already answered someone else who had the same problem as
1221   you. The archives are available from the support page on
1222   http://www.php.net/support.php. To subscribe to the PHP installation
1223   mailing list, send an empty mail to
1224   php-install-subscribe@lists.php.net. The mailing list address is
1225   php-install@lists.php.net.
1227   If you want to get help on the mailing list, please try to be precise
1228   and give the necessary details about your environment (which operating
1229   system, what PHP version, what web server, if you are running PHP as
1230   CGI or a server module, safe mode, etc...), and preferably enough code
1231   to make others able to reproduce and test your problem.
1232     __________________________________________________________________
1234Bug reports
1236   If you think you have found a bug in PHP, please report it. The PHP
1237   developers probably don't know about it, and unless you report it,
1238   chances are it won't be fixed. You can report bugs using the
1239   bug-tracking system at http://bugs.php.net/. Please do not send bug
1240   reports in mailing list or personal letters. The bug system is also
1241   suitable to submit feature requests.
1243   Read the How to report a bug document before submitting any bug
1244   reports!
1245     __________________________________________________________________
1247Chapter 5. Runtime Configuration
1249The configuration file
1251   The configuration file (called php3.ini in PHP 3, and simply php.ini as
1252   of PHP 4) is read when PHP starts up. For the server module versions of
1253   PHP, this happens only once when the web server is started. For the CGI
1254   and CLI version, it happens on every invocation.
1256   php.ini is searched in these locations (in order):
1258     * SAPI module specific location (PHPIniDir directive in Apache 2, -c
1259       command line option in CGI and CLI, php_ini parameter in NSAPI,
1260       PHP_INI_PATH environment variable in THTTPD)
1261     * The PHPRC environment variable. Before PHP 5.2.0 this was checked
1262       after the registry key mentioned below.
1263     * As of PHP 5.2.0, the following registry locations are searched in
1264       order: HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z\IniFilePath,
1265       HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y\IniFilePath and
1266       HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x\IniFilePath, where x, y and z
1267       mean the PHP major, minor and release versions.
1268     * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry
1269       location)
1270     * Current working directory (except CLI)
1271     * The web server's directory (for SAPI modules), or directory of PHP
1272       (otherwise in Windows)
1273     * Windows directory (C:\windows or C:\winnt) (for Windows), or
1274       --with-config-file-path compile time option
1276   If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
1277   e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini. SAPI
1278   name can be determined by php_sapi_name().
1280     Note: The Apache web server changes the directory to root at startup
1281     causing PHP to attempt to read php.ini from the root filesystem if
1282     it exists.
1284   The php.ini directives handled by extensions are documented
1285   respectively on the pages of the extensions themselves. The list of the
1286   core directives is available in the appendix. Probably not all PHP
1287   directives are documented in the manual though. For a complete list of
1288   directives available in your PHP version, please read your well
1289   commented php.ini file. Alternatively, you may find the latest
1290   php.ini from SVN helpful too.
1292   Example 5-1. php.ini example
1293; any text on a line after an unquoted semicolon (;) is ignored
1294[php] ; section markers (text within square brackets) are also ignored
1295; Boolean values can be set to either:
1296;    true, on, yes
1297; or false, off, no, none
1298html_errors = off
1299track_errors = yes
1301; you can enclose strings in double-quotes
1302include_path = ".:/usr/local/lib/php"
1304; backslashes are treated the same as any other character
1305include_path = ".;c:\php\lib"
1307   Since PHP 5.1.0, it is possible to refer to existing .ini variables
1308   from within .ini files. Example: open_basedir = ${open_basedir}
1309   ":/new/dir".
1310     __________________________________________________________________
1312How to change configuration settings
1314Running PHP as an Apache module
1316   When using PHP as an Apache module, you can also change the
1317   configuration settings using directives in Apache configuration files
1318   (e.g. httpd.conf) and .htaccess files. You will need "AllowOverride
1319   Options" or "AllowOverride All" privileges to do so.
1321   With PHP 4 and PHP 5, there are several Apache directives that allow
1322   you to change the PHP configuration from within the Apache
1323   configuration files. For a listing of which directives are PHP_INI_ALL,
1324   PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the List of php.ini
1325   directives appendix.
1327     Note: With PHP 3, there are Apache directives that correspond to
1328     each configuration setting in the php3.ini name, except the name is
1329     prefixed by "php3_".
1331   php_value name value
1332          Sets the value of the specified directive. Can be used only with
1333          PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a
1334          previously set value use none as the value.
1336     Note: Don't use php_value to set boolean values. php_flag (see
1337     below) should be used instead.
1339   php_flag name on|off
1340          Used to set a boolean configuration directive. Can be used only
1341          with PHP_INI_ALL and PHP_INI_PERDIR type directives.
1343   php_admin_value name value
1344          Sets the value of the specified directive. This can not be used
1345          in .htaccess files. Any directive type set with php_admin_value
1346          can not be overridden by .htaccess or virtualhost directives. To
1347          clear a previously set value use none as the value.
1349   php_admin_flag name on|off
1350          Used to set a boolean configuration directive. This can not be
1351          used in .htaccess files. Any directive type set with
1352          php_admin_flag can not be overridden by .htaccess or virtualhost
1353          directives.
1355   Example 5-2. Apache configuration example
1356<IfModule mod_php5.c>
1357  php_value include_path ".:/usr/local/lib/php"
1358  php_admin_flag engine on
1361   Caution
1363   PHP constants do not exist outside of PHP. For example, in httpd.conf
1364   you can not use PHP constants such as E_ALL or E_NOTICE to set the
1365   error_reporting directive as they will have no meaning and will
1366   evaluate to 0. Use the associated bitmask values instead. These
1367   constants can be used in php.ini
1368     __________________________________________________________________
1370Changing PHP configuration via the Windows registry
1372   When running PHP on Windows, the configuration values can be modified
1373   on a per-directory basis using the Windows registry. The configuration
1374   values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory
1375   Values, in the sub-keys corresponding to the path names. For example,
1376   configuration values for the directory c:\inetpub\wwwroot would be
1377   stored in the key HKLM\SOFTWARE\PHP\Per Directory
1378   Values\c\inetpub\wwwroot. The settings for the directory would be
1379   active for any script running from this directory or any subdirectory
1380   of it. The values under the key should have the name of the PHP
1381   configuration directive and the string value. PHP constants in the
1382   values are not parsed. However, only configuration values changeable in
1383   PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.
1384     __________________________________________________________________
1386Other interfaces to PHP
1388   Regardless of how you run PHP, you can change certain values at runtime
1389   of your scripts through ini_set(). See the documentation on the
1390   ini_set() page for more information.
1392   If you are interested in a complete list of configuration settings on
1393   your system with their current values, you can execute the phpinfo()
1394   function, and review the resulting page. You can also access the values
1395   of individual configuration directives at runtime using ini_get() or
1396   get_cfg_var().
1397     __________________________________________________________________
1399Chapter 6. Installation FAQ
1401   This section holds common questions about the way to install PHP. PHP
1402   is available for almost any OS (except maybe for MacOS before OSX), and
1403   almost any web server.
1405   To install PHP, follow the instructions in Installing PHP.
1407   1. Why shouldn't I use Apache2 with a threaded MPM in a production
1408          environment?
1410   2. Unix/Windows: Where should my php.ini file be located?
1411   3. Unix: I installed PHP, but every time I load a document, I get the
1412          message 'Document Contains No Data'! What's going on here?
1414   4. Unix: I installed PHP using RPMS, but Apache isn't processing the
1415          PHP pages! What's going on here?
1417   5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the
1418          database support I need! What's going on here?
1420   6. Unix: I patched Apache with the FrontPage extensions patch, and
1421          suddenly PHP stopped working. Is PHP incompatible with the
1422          Apache FrontPage extensions?
1424   7. Unix/Windows: I have installed PHP, but when I try to access a PHP
1425          script file via my browser, I get a blank screen.
1427   8. Unix/Windows: I have installed PHP, but when try to access a PHP
1428          script file via my browser, I get a server 500 error.
1430   9. Some operating systems: I have installed PHP without errors, but
1431          when I try to start apache I get undefined symbol errors:
1433[mybox:user /src/php5] root# apachectl configtest
1434 apachectl: /usr/local/apache/bin/httpd Undefined symbols:
1435  _compress
1436  _uncompress
1438   10. Windows: I have installed PHP, but when I to access a PHP script
1439          file via my browser, I get the error:
1441cgi error:
1442 The specified CGI application misbehaved by not
1443 returning a complete set of HTTP headers.
1444 The headers it did return are:
1446   11. Windows: I've followed all the instructions, but still can't get
1447          PHP and IIS to work together!
1449   12. When running PHP as CGI with IIS, OmniHTTPD or Xitami, I get
1450          the following error: Security Alert! PHP CGI cannot be accessed
1451          directly..
1453   13. How do I know if my php.ini is being found and read? It seems like
1454          it isn't as my changes aren't being implemented.
1456   14. How do I add my PHP directory to the PATH on Windows?
1457   15. How do I make the php.ini file available to PHP on windows?
1458   16. Is it possible to use Apache content negotiation (MultiViews
1459          option) with PHP?
1461   17. Is PHP limited to process GET and POST request methods only?
1463   1. Why shouldn't I use Apache2 with a threaded MPM in a production
1464   environment?
1466   PHP is glue. It is the glue used to build cool web applications by
1467   sticking dozens of 3rd-party libraries together and making it all
1468   appear as one coherent entity through an intuitive and easy to learn
1469   language interface. The flexibility and power of PHP relies on the
1470   stability and robustness of the underlying platform. It needs a working
1471   OS, a working web server and working 3rd-party libraries to glue
1472   together. When any of these stop working PHP needs ways to identify the
1473   problems and fix them quickly. When you make the underlying framework
1474   more complex by not having completely separate execution threads,
1475   completely separate memory segments and a strong sandbox for each
1476   request to play in, feet of clay are introduced into PHP's system.
1478   If you feel you have to use a threaded MPM, look at a FastCGI
1479   configuration where PHP is running in its own memory space.
1481   And finally, this warning against using a threaded MPM is not as strong
1482   for Windows systems because most libraries on that platform tend to be
1483   threadsafe.
1485   2. Unix/Windows: Where should my php.ini file be located?
1487   By default on Unix it should be in /usr/local/lib which is
1488   <install-path>/lib. Most people will want to change this at
1489   compile-time with the --with-config-file-path flag. You would, for
1490   example, set it with something like:
1491   --with-config-file-path=/etc
1493   And then you would copy php.ini-production from the distribution to
1494   /etc/php.ini and edit it to make any local changes you want.
1495   --with-config-file-scan-dir=PATH
1497   On Windows the default path for the php.ini file is the Windows
1498   directory. If you're using the Apache webserver, php.ini is first
1499   searched in the Apaches install directory, e.g. c:\program files\apache
1500   group\apache. This way you can have different php.ini files for
1501   different versions of Apache on the same machine.
1503   See also the chapter about the configuration file.
1505   3. Unix: I installed PHP, but every time I load a document, I get the
1506   message 'Document Contains No Data'! What's going on here?
1508   This probably means that PHP is having some sort of problem and is
1509   core-dumping. Look in your server error log to see if this is the case,
1510   and then try to reproduce the problem with a small test case. If you
1511   know how to use 'gdb', it is very helpful when you can provide a
1512   backtrace with your bug report to help the developers pinpoint the
1513   problem. If you are using PHP as an Apache module try something like:
1515     * Stop your httpd processes
1516     * gdb httpd
1517     * Stop your httpd processes
1518     * > run -X -f /path/to/httpd.conf
1519     * Then fetch the URL causing the problem with your browser
1520     * > run -X -f /path/to/httpd.conf
1521     * If you are getting a core dump, gdb should inform you of this now
1522     * type: bt
1523     * You should include your backtrace in your bug report. This should
1524       be submitted to http://bugs.php.net/
1526   If your script uses the regular expression functions (ereg() and
1527   friends), you should make sure that you compiled PHP and Apache with
1528   the same regular expression package. This should happen automatically
1529   with PHP and Apache 1.3.x
1531   4. Unix: I installed PHP using RPMS, but Apache isn't processing the
1532   PHP pages! What's going on here?
1534   Assuming you installed both Apache and PHP from RPM packages, you need
1535   to uncomment or add some or all of the following lines in your
1536   httpd.conf file:
1537# Extra Modules
1538AddModule mod_php.c
1539AddModule mod_php3.c
1540AddModule mod_perl.c
1542# Extra Modules
1543LoadModule php_module         modules/mod_php.so
1544LoadModule perl_module        modules/libperl.so
1546   And add:
1547AddType application/x-httpd-php3 .php3    # for PHP 3
1548AddType application/x-httpd-php .php      # for PHP 4
1550   ... to the global properties, or to the properties of the VirtualDomain
1551   you want to have PHP support added to.
1553   5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the
1554   database support I need! What's going on here?
1556   Due to the way PHP 3 built, it is not easy to build a complete flexible
1557   PHP RPM. This issue is addressed in PHP 4. For PHP 3, we currently
1558   suggest you use the mechanism described in the INSTALL.REDHAT file in
1559   the PHP distribution. If you insist on using an RPM version of PHP 3,
1560   read on...
1562   The RPM packagers are setting up the RPMS to install without database
1563   support to simplify installations and because RPMS use /usr/ instead of
1564   the standard /usr/local/ directory for files. You need to tell the RPM
1565   spec file which databases to support and the location of the top-level
1566   of your database server.
1568   This example will explain the process of adding support for the popular
1569   MySQL database server, using the mod installation for Apache.
1571   Of course all of this information can be adjusted for any database
1572   server that PHP supports. We will assume you installed MySQL and Apache
1573   completely with RPMS for this example as well.
1575     * First remove mod_php3 :
1577rpm -e mod_php3
1579     * Then get the source rpm and INSTALL it, NOT --rebuild
1581rpm -Uvh mod_php3-3.0.5-2.src.rpm
1583     * Then edit the /usr/src/redhat/SPECS/mod_php3.spec file
1584       In the %build section add the database support you want, and the
1585       path.
1586       For MySQL you would add --with-mysql=/usr The %build section will
1587       look something like this:
1589./configure --prefix=/usr \
1590--with-apxs=/usr/sbin/apxs \
1591--with-config-file-path=/usr/lib \
1592--enable-debug=no \
1593--enable-safe-mode \
1594--with-exec-dir=/usr/bin \
1595--with-mysql=/usr \
1598     * Once this modification is made then build the binary rpm as
1599       follows:
1601rpm -bb /usr/src/redhat/SPECS/mod_php3.spec
1603     * Then install the rpm
1605rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm
1607   Make sure you restart Apache, and you now have PHP 3 with MySQL support
1608   using RPM's. Note that it is probably much easier to just build from
1609   the distribution tarball of PHP 3 and follow the instructions in
1610   INSTALL.REDHAT found in that distribution.
1612   6. Unix: I patched Apache with the FrontPage extensions patch, and
1613   suddenly PHP stopped working. Is PHP incompatible with the Apache
1614   FrontPage extensions?
1616   No, PHP works fine with the FrontPage extensions. The problem is that
1617   the FrontPage patch modifies several Apache structures, that PHP relies
1618   on. Recompiling PHP (using 'make clean ; make') after the FP patch is
1619   applied would solve the problem.
1621   7. Unix/Windows: I have installed PHP, but when I try to access a PHP
1622   script file via my browser, I get a blank screen.
1624   Do a 'view source' in the web browser and you will probably find that
1625   you can see the source code of your PHP script. This means that the web
1626   server did not send the script to PHP for interpretation. Something is
1627   wrong with the server configuration - double check the server
1628   configuration against the PHP installation instructions.
1630   8. Unix/Windows: I have installed PHP, but when try to access a PHP
1631   script file via my browser, I get a server 500 error.
1633   Something went wrong when the server tried to run PHP. To get to see a
1634   sensible error message, from the command line, change to the directory
1635   containing the PHP executable (php.exe on Windows) and run php -i. If
1636   PHP has any problems running, then a suitable error message will be
1637   displayed which will give you a clue as to what needs to be done next.
1638   If you get a screen full of HTML codes (the output of the phpinfo()
1639   function) then PHP is working, and your problem may be related to your
1640   server configuration which you should double check.
1642   9. Some operating systems: I have installed PHP without errors, but
1643   when I try to start apache I get undefined symbol errors:
1644[mybox:user /src/php5] root# apachectl configtest
1645 apachectl: /usr/local/apache/bin/httpd Undefined symbols:
1646  _compress
1647  _uncompress
1649   This has actually nothing to do with PHP, but with the MySQL client
1650   libraries. Some need --with-zlib, others do not. This is also covered
1651   in the MySQL FAQ.
1653   10. Windows: I have installed PHP, but when I to access a PHP script
1654   file via my browser, I get the error:
1655cgi error:
1656 The specified CGI application misbehaved by not
1657 returning a complete set of HTTP headers.
1658 The headers it did return are:
1660   This error message means that PHP failed to output anything at all. To
1661   get to see a sensible error message, from the command line, change to
1662   the directory containing the PHP executable (php.exe on Windows) and
1663   run php -i. If PHP has any problems running, then a suitable error
1664   message will be displayed which will give you a clue as to what needs
1665   to be done next. If you get a screen full of HTML codes (the output of
1666   the phpinfo() function) then PHP is working.
1668   Once PHP is working at the command line, try accessing the script via
1669   the browser again. If it still fails then it could be one of the
1670   following:
1672     * File permissions on your PHP script, php.exe, php5ts.dll, php.ini
1673       or any PHP extensions you are trying to load are such that the
1674       anonymous internet user ISUR_<machinename> cannot access them.
1675     * The script file does not exist (or possibly isn't where you think
1676       it is relative to your web root directory). Note that for IIS you
1677       can trap this error by ticking the 'check file exists' box when
1678       setting up the script mappings in the Internet Services Manager. If
1679       a script file does not exist then the server will return a 404
1680       error instead. There is also the additional benefit that IIS will
1681       do any authentication required for you based on the NTLanMan
1682       permissions on your script file.
1684   11. Windows: I've followed all the instructions, but still can't get
1685   PHP and IIS to work together!
1687   Make sure any user who needs to run a PHP script has the rights to run
1688   php.exe! IIS uses an anonymous user which is added at the time IIS is
1689   installed. This user needs rights to php.exe. Also, any authenticated
1690   user will also need rights to execute php.exe. And for IIS4 you need to
1691   tell it that PHP is a script engine. Also, you will want to read this
1692   faq.
1694   12. When running PHP as CGI with IIS, OmniHTTPD or Xitami, I get
1695   the following error: Security Alert! PHP CGI cannot be accessed
1696   directly..
1698   You must set the cgi.force_redirect directive to 0. It defaults to 1 so
1699   be sure the directive isn't commented out (with a ;). Like all
1700   directives, this is set in php.ini
1702   Because the default is 1, it's critical that you're 100% sure that the
1703   correct php.ini file is being read. Read this faq for details.
1705   13. How do I know if my php.ini is being found and read? It seems like
1706   it isn't as my changes aren't being implemented.
1708   To be sure your php.ini is being read by PHP, make a call to phpinfo()
1709   and near the top will be a listing called Configuration File (php.ini).
1710   This will tell you where PHP is looking for php.ini and whether or not
1711   it's being read. If just a directory PATH exists than it's not being
1712   read and you should put your php.ini in that directory. If php.ini is
1713   included within the PATH than it is being read.
1715   If php.ini is being read and you're running PHP as a module, then be
1716   sure to restart your web server after making changes to php.ini
1718   14. How do I add my PHP directory to the PATH on Windows?
1720   On Windows NT, 2000, XP and 2003:
1722     * Go to Control Panel and open the System icon (Start -> Settings ->
1723       Control Panel -> System, or just Start -> Control Panel -> System
1724       for Windows XP/2003)
1725     * Go to the Advanced tab
1726     * Click on the 'Environment Variables' button
1727     * Look into the 'System Variables' pane
1728     * Find the Path entry (you may need to scroll to find it)
1729     * Double click on the Path entry
1730     * Enter your PHP directory at the end, including ';' before (e.g.
1731       ;C:\php)
1732     * Press OK and restart your computer
1734   On Windows 98/Me you need to edit the autoexec.bat file:
1736     * Open the Notepad (Start -> Run and enter notepad)
1737     * Open the C:\autoexec.bat file
1738     * Locate the line with PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;..... and
1739       add: ;C:\php to the end of the line
1740     * Save the file and restart your computer
1742     Note: Be sure to reboot after following the steps above to ensure
1743     that the PATH changes are applied.
1745   The PHP manual used to promote the copying of files into the Windows
1746   system directory, this is because this directory (C:\Windows, C:\WINNT,
1747   etc.) is by default in the systems PATH. Copying files into the Windows
1748   system directory has long since been deprecated and may cause problems.
1750   15. How do I make the php.ini file available to PHP on windows?
1752   There are several ways of doing this. If you are using Apache, read
1753   their installation specific instructions (Apache 1, Apache 2),
1754   otherwise you must set the PHPRC environment variable:
1756   On Windows NT, 2000, XP and 2003:
1758     * Go to Control Panel and open the System icon (Start -> Settings ->
1759       Control Panel -> System, or just Start -> Control Panel -> System
1760       for Windows XP/2003)
1761     * Go to the Advanced tab
1762     * Click on the 'Environment Variables' button
1763     * Look into the 'System variables' pane
1764     * Click on 'New' and enter 'PHPRC' as the variable name and the
1765       directory where php.ini is located as the variable value (e.g.
1766       C:\php)
1767     * Press OK and restart your computer
1769   On Windows 98/Me you need to edit the autoexec.bat file:
1771     * Open the Notepad (Start -> Run and enter notepad)
1772     * Open the C:\autoexec.bat file
1773     * Add a new line to the end of the file: set PHPRC=C:\php (replace
1774       C:\php with the directory where php.ini is located). Please note
1775       that the path cannot contain spaces. For instance, if you have
1776       installed PHP in C:\Program Files\PHP, you would enter
1777       C:\PROGRA~1\PHP instead.
1778     * Save the file and restart your computer
1780   16. Is it possible to use Apache content negotiation (MultiViews
1781   option) with PHP?
1783   If links to PHP files include extension, everything works perfect. This
1784   FAQ is only for the case when links to PHP files don't include
1785   extension and you want to use content negotiation to choose PHP files
1786   from URL with no extension. In this case, replace the line AddType
1787   application/x-httpd-php .php with:
1788# PHP 4
1789AddHandler php-script php
1790AddType text/html php
1792# PHP 5
1793AddHandler php5-script php
1794AddType text/html php
1796   This solution doesn't work for Apache 1 as PHP module doesn't catch
1797   php-script.
1799   17. Is PHP limited to process GET and POST request methods only?
1801   No, it is possible to handle any request method, e.g. CONNECT. Proper
1802   response status can be sent with header(). If only GET and POST methods
1803   should be handled, it can be achieved with this Apache configuration:
1804<LimitExcept GET POST>
1805Deny from all