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