Advertisement
gsavix

step-by-step-php-install

Oct 27th, 2014
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.26 KB | None | 0 0
  1. howto install php 5.0.4 for windows; unix;
  2.  
  3. from museum php. Please read all topics for install on windows apache1 e apache2.
  4.  
  5. special attention for extension modules like mcrypt on weberp mailing
  6.  
  7. url http://weberp-accounting.1478800.n4.nabble.com/PHP-VERSION-ID-50500-not-work-tp4657758p4657762.html
  8.  
  9.  
  10. Installing PHP (this doc date is from 2005)
  11. _________________________________________________________________
  12.  
  13. Table of Contents
  14. Preface
  15. 1. General Installation Considerations
  16. 2. Installation on Windows systems
  17.  
  18. Windows Installer
  19. Manual Installation Steps
  20. ActiveScript
  21. Microsoft IIS / PWS
  22. Apache 1.3.x on Microsoft Windows
  23. Apache 2.0.x on Microsoft Windows
  24. Sun, iPlanet and Netscape servers on Microsoft Windows
  25. OmniHTTPd Server
  26. Sambar Server on Microsoft Windows
  27. Xitami on Microsoft Windows
  28. Installation of extensions on Windows
  29.  
  30. 3. Installation of PECL extensions
  31.  
  32. Introduction to PECL Installations
  33. Downloading PECL extensions
  34. PECL for Windows users
  35. Compiling shared PECL extensions with PEAR
  36. Compiling shared PECL extensions with phpize
  37. Compiling PECL extensions statically into PHP
  38.  
  39. 4. Problems?
  40.  
  41. Read the FAQ
  42. Other problems
  43. Bug reports
  44.  
  45. 5. Runtime Configuration
  46.  
  47. The configuration file
  48. How to change configuration settings
  49. _________________________________________________________________
  50.  
  51. Preface
  52.  
  53. These installation instructions were generated from the HTML version
  54. of the PHP Manual so formatting and linking have been altered. See the
  55. online and updated version at: http://php.net/install.windows
  56. _________________________________________________________________
  57.  
  58. Chapter 1. General Installation Considerations
  59.  
  60. Before starting the installation, first you need to know what do you
  61. want to use PHP for. There are three main fields you can use PHP, as
  62. described in the What can PHP do? section:
  63.  
  64. * Server-side scripting
  65. * Command line scripting
  66. * Client-side GUI applications
  67.  
  68. For the first and most common form, you need three things: PHP itself,
  69. a web server and a web browser. You probably already have a web
  70. browser, and depending on your operating system setup, you may also
  71. have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows).
  72. You may also rent webspace at a company. This way, you don't need to
  73. set up anything on your own, only write your PHP scripts, upload it to
  74. the server you rent, and see the results in your browser.
  75.  
  76. While setting up the server and PHP on your own, you have two choices
  77. for the method of connecting PHP to the server. For many servers PHP
  78. has a direct module interface (also called SAPI). These servers
  79. include Apache, Microsoft Internet Information Server, Netscape and
  80. iPlanet servers. Many other servers have support for ISAPI, the
  81. Microsoft module interface (OmniHTTPd for example). If PHP has no
  82. module support for your web server, you can always use it as a CGI or
  83. FastCGI processor. This means you set up your server to use the CGI
  84. executable of PHP to process all PHP file requests on the server.
  85.  
  86. If you are also interested to use PHP for command line scripting (e.g.
  87. write scripts autogenerating some images for you offline, or
  88. processing text files depending on some arguments you pass to them),
  89. you always need the command line executable. For more information,
  90. read the section about writing command line PHP applications. In this
  91. case, you need no server and no browser.
  92.  
  93. With PHP you can also write desktop GUI applications using the PHP-GTK
  94. extension. This is a completely different approach than writing web
  95. pages, as you do not output any HTML, but manage windows and objects
  96. within them. For more information about PHP-GTK, please visit the site
  97. dedicated to this extension. PHP-GTK is not included in the official
  98. PHP distribution.
  99.  
  100. From now on, this section deals with setting up PHP for web servers on
  101. Unix and Windows with server module interfaces and CGI executables.
  102. You will also find information on the command line executable in the
  103. following sections.
  104.  
  105. PHP source code and binary distributions for Windows can be found at
  106. http://www.php.net/downloads.php. We recommend you to choose a mirror
  107. nearest to you for downloading the distributions.
  108. _________________________________________________________________
  109.  
  110. Chapter 2. Installation on Windows systems
  111.  
  112. This section applies to Windows 98/Me and Windows NT/2000/XP/2003. PHP
  113. will not work on 16 bit platforms such as Windows 3.1 and sometimes we
  114. refer to the supported Windows platforms as Win32. Windows 95 is no
  115. longer supported as of PHP 4.3.0.
  116.  
  117. There are two main ways to install PHP for Windows: either manually or
  118. by using the installer.
  119.  
  120. If you have Microsoft Visual Studio, you can also build PHP from the
  121. original source code.
  122.  
  123. Once you have PHP installed on your Windows system, you may also want
  124. to load various extensions for added functionality.
  125.  
  126. Warning
  127.  
  128. There are several all-in-one installers over the Internet, but none of
  129. those are endorsed by PHP.net, as we believe that the manual
  130. installation is the best choice to have your system secure and
  131. optimised.
  132. _________________________________________________________________
  133.  
  134. Windows Installer
  135.  
  136. The Windows PHP installer is available from the downloads page at
  137. http://www.php.net/downloads.php. This installs the CGI version of PHP
  138. and for IIS, PWS, and Xitami, it configures the web server as well.
  139. The installer does not include any extra external PHP extensions
  140. (php_*.dll) as you'll only find those in the Windows Zip Package and
  141. PECL downloads.
  142.  
  143. Note: While the Windows installer is an easy way to make PHP work,
  144. it is restricted in many aspects as, for example, the automatic
  145. setup of extensions is not supported. Use of the installer isn't
  146. the preferred method for installing PHP.
  147.  
  148. First, install your selected HTTP (web) server on your system, and
  149. make sure that it works.
  150.  
  151. Run the executable installer and follow the instructions provided by
  152. the installation wizard. Two types of installation are supported -
  153. standard, which provides sensible defaults for all the settings it
  154. can, and advanced, which asks questions as it goes along.
  155.  
  156. The installation wizard gathers enough information to set up the
  157. php.ini file, and configure certain web servers to use PHP. One of the
  158. web servers the PHP installer does not configure for is Apache, so
  159. you'll need to configure it manually.
  160.  
  161. Once the installation has completed, the installer will inform you if
  162. you need to restart your system, restart the server, or just start
  163. using PHP.
  164.  
  165. Warning
  166.  
  167. Be aware, that this setup of PHP is not secure. If you would like to
  168. have a secure PHP setup, you'd better go on the manual way, and set
  169. every option carefully. This automatically working setup gives you an
  170. instantly working PHP installation, but it is not meant to be used on
  171. online servers.
  172. _________________________________________________________________
  173.  
  174. Manual Installation Steps
  175.  
  176. This install guide will help you manually install and configure PHP
  177. with a web server on Microsoft Windows. To get started you'll need to
  178. download the zip binary distribution from the downloads page at
  179. http://www.php.net/downloads.php.
  180.  
  181. Although there are many all-in-one installation kits, and we also
  182. distribute a PHP installer for Microsoft Windows, we recommend you
  183. take the time to setup PHP yourself as this will provide you with a
  184. better understanding of the system, and enables you to install PHP
  185. extensions easily when needed.
  186.  
  187. Upgrading from a previous PHP version: Previous editions of the
  188. manual suggest moving various ini and DLL files into your SYSTEM
  189. (i.e. C:\WINDOWS) folder and while this simplifies the installation
  190. procedure it makes upgrading difficult. We advise you remove all of
  191. these files (like php.ini and PHP related DLLs from the Windows
  192. SYSTEM folder) before moving on with a new PHP installation. Be
  193. sure to backup these files as you might break the entire system.
  194. The old php.ini might be useful in setting up the new PHP as well.
  195. And as you'll soon learn, the preferred method for installing PHP
  196. is to keep all PHP related files in one directory and have this
  197. directory available to your systems PATH.
  198.  
  199. MDAC requirements: If you use Microsoft Windows 98/NT4 download the
  200. latest version of the Microsoft Data Access Components (MDAC) for
  201. your platform. MDAC is available at
  202. http://msdn.microsoft.com/data/. This requirement exists because
  203. ODBC is built into the distributed Windows binaries.
  204.  
  205. The following steps should be completed on all installations before
  206. any server specific instructions are performed:
  207.  
  208. Extract the distribution file into a directory of your choice. If you
  209. are installing PHP 4, extract to C:\, as the zip file expands to a
  210. foldername like php-4.3.7-Win32. If you are installing PHP 5, extract
  211. to C:\php as the zip file doesn't expand as in PHP 4. You may choose a
  212. different location but do not have spaces in the path (like C:\Program
  213. Files\PHP) as some web servers will crash if you do.
  214.  
  215. The directory structure extracted from the zip is different for PHP
  216. versions 4 and 5 and look like as follows:
  217.  
  218. Example 2-1. PHP 4 package structure
  219. c:\php
  220. |
  221. +--cli
  222. | |
  223. | |-php.exe -- CLI executable - ONLY for commandline scripting
  224. |
  225. +--dlls -- support DLLs required by some extensions
  226. | |
  227. | |-expat.dll
  228. | |
  229. | |-fdftk.dll
  230. | |
  231. | |-...
  232. |
  233. +--extensions -- extension DLLs for PHP
  234. | |
  235. | |-php_bz2.dll
  236. | |
  237. | |-php_cpdf.dll
  238. | |
  239. | |-..
  240. |
  241. +--mibs -- support files for SNMP
  242. |
  243. +--openssl -- support files for Openssl
  244. |
  245. +--pdf-related -- support files for PDF
  246. |
  247. +--sapi -- SAPI (server module support) DLLs
  248. | |
  249. | |-php4activescript.dll
  250. | |
  251. | |-php4apache.dll
  252. | |
  253. | |-php4apache2.dll
  254. | |
  255. | |-..
  256. |
  257. +--PEAR -- initial copy of PEAR
  258. |
  259. |
  260. |-go-pear.bat -- PEAR setup script
  261. |
  262. |-..
  263. |
  264. |-php.exe -- CGI executable
  265. |
  266. |-..
  267. |
  268. |-php.ini-dist -- default php.ini settings
  269. |
  270. |-php.ini-recommended -- recommended php.ini settings
  271. |
  272. |-php4ts.dll -- core PHP DLL
  273. |
  274. |-...
  275.  
  276. Or:
  277.  
  278. Example 2-2. PHP 5 package structure
  279. c:\php
  280. |
  281. +--dev
  282. | |
  283. | |-php5ts.lib
  284. |
  285. +--ext -- extension DLLs for PHP
  286. | |
  287. | |-php_bz2.dll
  288. | |
  289. | |-php_cpdf.dll
  290. | |
  291. | |-..
  292. |
  293. +--extras
  294. | |
  295. | +--mibs -- support files for SNMP
  296. | |
  297. | +--openssl -- support files for Openssl
  298. | |
  299. | +--pdf-related -- support files for PDF
  300. | |
  301. | |-mime.magic
  302. |
  303. +--pear -- initial copy of PEAR
  304. |
  305. |
  306. |-go-pear.bat -- PEAR setup script
  307. |
  308. |-fdftk.dll
  309. |
  310. |-..
  311. |
  312. |-php-cgi.exe -- CGI executable
  313. |
  314. |-php-win.exe -- executes scripts without an opened command prompt
  315. |
  316. |-php.exe -- CLI executable - ONLY for command line scripting
  317. |
  318. |-..
  319. |
  320. |-php.ini-dist -- default php.ini settings
  321. |
  322. |-php.ini-recommended -- recommended php.ini settings
  323. |
  324. |-php5activescript.dll
  325. |
  326. |-php5apache.dll
  327. |
  328. |-php5apache2.dll
  329. |
  330. |-..
  331. |
  332. |-php5ts.dll -- core PHP DLL
  333. |
  334. |-...
  335.  
  336. Notice the differences and similarities. Both PHP 4 and PHP 5 have a
  337. CGI executable, a CLI executable, and server modules, but they are
  338. located in different folders and/or have different names. While PHP 4
  339. packages have the server modules in the sapi folder, PHP 5
  340. distributions have no such directory and instead they're in the PHP
  341. folder root. The supporting DLLs for the PHP 5 extensions are also not
  342. in a seperate directory.
  343.  
  344. Note: In PHP 4, you should move all files located in the dll and
  345. sapi folders to the main folder (e.g. C:\php).
  346.  
  347. Here is a list of server modules shipped with PHP 4 and PHP 5:
  348.  
  349. * sapi/php4activescript.dll (php5activescript.dll) - ActiveScript
  350. engine, allowing you to embed PHP in your Windows applications.
  351. * sapi/php4apache.dll (php5apache.dll) - Apache 1.3.x module.
  352. * sapi/php4apache2.dll (php5apache2.dll) - Apache 2.0.x module.
  353. * sapi/php4isapi.dll (php5isapi.dll) - ISAPI Module for ISAPI
  354. compliant web servers like IIS 4.0/PWS 4.0 or newer.
  355. * sapi/php4nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape server
  356. module.
  357. * sapi/php4pi3web.dll (no equivalent in PHP 5) - Pi3Web server
  358. module.
  359.  
  360. Server modules provide significantly better performance and additional
  361. functionality compared to the CGI binary. The CLI version is designed
  362. to let you use PHP for command line scripting. More information about
  363. CLI is available in the chapter about using PHP from the command line.
  364.  
  365. Warning
  366.  
  367. The SAPI modules have been significantly improved as of the 4.1
  368. release, however, in older systems you may encounter server errors or
  369. other server modules failing, such as ASP.
  370.  
  371. The CGI and CLI binaries, and the web server modules all require the
  372. php4ts.dll (php5ts.dll) file to be available to them. You have to make
  373. sure that this file can be found by your PHP installation. The search
  374. order for this DLL is as follows:
  375.  
  376. * The same directory from where php.exe is called, or in case you
  377. use a SAPI module, the web server's directory (e.g. C:\Program
  378. Files\Apache Group\Apache2\bin).
  379. * Any directory in your Windows PATH environment variable.
  380.  
  381. To make php4ts.dll / php5ts.dll available you have three options: copy
  382. the file to the Windows system directory, copy the file to the web
  383. server's directory, or add your PHP directory, C:\php to the PATH. For
  384. better maintenance, we advise you to follow the last option, add
  385. C:\php to the PATH, because it will be simpler to upgrade PHP in the
  386. future. Read more about how to add your PHP directory to PATH in the
  387. corresponding FAQ entry.
  388.  
  389. The next step is to set up a valid configuration file for PHP,
  390. php.ini. There are two ini files distributed in the zip file,
  391. php.ini-dist and php.ini-recommended. We advise you to use
  392. php.ini-recommended, because we optimized the default settings in this
  393. file for performance, and security. Read this well documented file
  394. carefully because it has changes from php.ini-dist that will
  395. drastically affect your setup. Some examples are display_errors being
  396. off and magic_quotes_gpc being off. In addition to reading these,
  397. study the ini settings and set every element manually yourself. If you
  398. would like to achieve the best security, then this is the way for you,
  399. although PHP works fine with these default ini files. Copy your chosen
  400. ini-file to a directory that PHP is able to find and rename it to
  401. php.ini. PHP searches for php.ini in the following locations (in
  402. order):
  403.  
  404. * PHPIniDir directive (Apache 2 module only)
  405. * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath
  406. * The PHPRC environment variable
  407. * Directory of PHP (for CLI), or the web server's directory (for
  408. SAPI modules)
  409. * Windows directory (C:\windows or C:\winnt)
  410.  
  411. If you are running Apache 2, the simpler option is to use the
  412. PHPIniDir directive (read the installation on Apache 2 page),
  413. otherwise your best option is to set the PHPRC environment variable.
  414. This process is explained in the following FAQ entry.
  415.  
  416. Note: If you're using NTFS on Windows NT, 2000, XP or 2003, make
  417. sure that the user running the web server has read permissions to
  418. your php.ini (e.g. make it readable by Everyone).
  419.  
  420. The following steps are optional:
  421.  
  422. * Edit your new php.ini file. If you plan to use OmniHTTPd, do not
  423. follow the next step. Set the doc_root to point to your web
  424. servers document_root. For example:
  425.  
  426. doc_root = c:\inetpub\wwwroot // for IIS/PWS
  427.  
  428. doc_root = c:\apache\htdocs // for Apache
  429.  
  430. * Choose the extensions you would like to load when PHP starts. See
  431. the section about Windows extensions, about how to set up one, and
  432. what is already built in. Note that on a new installation it is
  433. advisable to first get PHP working and tested without any
  434. extensions before enabling them in php.ini.
  435. * On PWS and IIS, you can set the browscap configuration setting to
  436. point to: c:\windows\system\inetsrv\browscap.ini on Windows 9x/Me,
  437. c:\winnt\system32\inetsrv\browscap.ini on NT/2000, and
  438. c:\windows\system32\inetsrv\browscap.ini on XP. For an up-to-date
  439. browscap.ini, read the following FAQ.
  440.  
  441. PHP is now setup on your system. The next step is to choose a web
  442. server, and enable it to run PHP. Choose a webserver from the table of
  443. contents.
  444. _________________________________________________________________
  445.  
  446. ActiveScript
  447.  
  448. This section contains notes specific to the ActiveScript installation.
  449.  
  450. ActiveScript is a windows only SAPI that enables you to use PHP script
  451. in any ActiveScript compliant host, like Windows Script Host,
  452. ASP/ASP.NET, Windows Script Components or Microsoft Scriptlet control.
  453.  
  454. As of PHP 5.0.1, ActiveScript has been moved to the PECL repository.
  455. You may download this PECL extension DLL from the PHP Downloads page
  456. or at http://snaps.php.net/.
  457.  
  458. Note: You should read the manual installation steps first!
  459.  
  460. After installing PHP, you should download the ActiveScript DLL
  461. (php5activescript.dll) and place it in the main PHP folder (e.g.
  462. C:\php).
  463.  
  464. After having all the files needed, you must register the DLL on your
  465. system. To achieve this, open a Command Prompt window (located in the
  466. Start Menu). Then go to your PHP directory by typing something like cd
  467. C:\php. To register the DLL just type regsvr32 php5activescript.dll.
  468.  
  469. To test if ActiveScript is working, create a new file, named test.wsf
  470. (the extension is very important) and type:
  471. <job id="test">
  472.  
  473. <script language="PHPScript">
  474. $WScript->Echo("Hello World!");
  475. </script>
  476.  
  477. </job>
  478.  
  479. Save and double-click on the file. If you receive a little window
  480. saying "Hello World!" you're done.
  481.  
  482. Note: ActiveScript doesn't use the default php.ini file. Instead,
  483. it will look only in the same directory as the .exe that caused it
  484. to load. You should create php-activescript.ini and place it in
  485. that folder, if you wish to load extensions, etc.
  486. _________________________________________________________________
  487.  
  488. Microsoft IIS / PWS
  489.  
  490. This section contains notes and hints specific to IIS (Microsoft
  491. Internet Information Server).
  492.  
  493. Warning
  494.  
  495. By using the CGI setup, your server is open to several possible
  496. attacks. Please read our CGI security section to learn how to defend
  497. yourself from those attacks.
  498. _________________________________________________________________
  499.  
  500. General considerations for all installations of PHP with IIS
  501.  
  502. * First, read the Manual Installation Instructions. Do not skip this
  503. step as it provides crucial information for installing PHP on
  504. Windows.
  505. * CGI users must set the cgi.force_redirect PHP directive to 0
  506. inside php.ini. Read the faq on cgi.force_redirect for important
  507. details. Also, CGI users should set the cgi.redirect_status_env
  508. directive to ENV_VAR_NAME. Be sure these directives aren't
  509. commented out inside php.ini.
  510. * The PHP 4 CGI is named php.exe while in PHP 5 it's php-cgi.exe. In
  511. PHP 5, php.exe is the CLI, and not the CGI.
  512. * Modify the Windows PATH environment variable to include the PHP
  513. directory. This way the PHP DLL files, PHP executables, and
  514. php.ini can all remain in the PHP directory without cluttering up
  515. the Windows system directory. For more details, see the FAQ on
  516. Setting the PATH.
  517. * Be sure the extension_dir and doc_root PHP directives are
  518. appropriately set in php.ini. These directives depend on the
  519. system that PHP is being installed on. In PHP 4, the extension_dir
  520. is extensions while with PHP 5 it's ext. So, an example PHP 5
  521. extensions_dir value is "c:\php\ext" and an example IIS doc_root
  522. value is "c:\Inetpub\wwwroot".
  523. * PHP extension DLL files, such as php_mysql.dll and php_curl.dll,
  524. are found in the zip package of the PHP download (not the PHP
  525. installer). In PHP 5, many extensions are part of PECL and can be
  526. downloaded in the "Collection of PECL modules" package. Files such
  527. as php_zip.dll and php_ssh2.dll. Download PHP files here.
  528. * When defining the executable, the 'check that file exists' box may
  529. also be checked. For a small performance penalty, the IIS (or PWS)
  530. will check that the script file exists and sort out authentication
  531. before firing up PHP. This means that the web server will provide
  532. sensible 404 style error messages instead of CGI errors
  533. complaining that PHP did not output any data.
  534. _________________________________________________________________
  535.  
  536. Windows NT/200x/XP and IIS 4 or newer
  537.  
  538. PHP may be installed as a CGI binary, or with the ISAPI module. In
  539. either case, you need to start the Microsoft Management Console (may
  540. appear as 'Internet Services Manager', either in your Windows NT 4.0
  541. Option Pack branch or the Control Panel=>Administrative Tools under
  542. Windows 2000/XP). Then right click on your Web server node (this will
  543. most probably appear as 'Default Web Server'), and select
  544. 'Properties'.
  545.  
  546. If you want to use the CGI binary, do the following:
  547.  
  548. * Under 'Home Directory', 'Virtual Directory', or 'Directory', do
  549. the following:
  550. * Change the Execute Permissions to 'Scripts only'
  551. * Click on the 'Configuration' button, and choose the Application
  552. Mappings tab. Click Add and set the Executable path to the
  553. appropriate CGI file. An example PHP 5 value is:
  554. C:\php\php-cgi.exe Supply .php as the extension. Leave 'Method
  555. exclusions' blank, and check the 'Script engine' checkbox. Now,
  556. click OK a few times.
  557. * Set up the appropriate security. (This is done in Internet Service
  558. Manager), and if your NT Server uses NTFS file system, add execute
  559. rights for I_USR_ to the directory that contains php.exe /
  560. php-cgi.exe.
  561.  
  562. To use the ISAPI module, do the following:
  563.  
  564. * If you don't want to perform HTTP Authentication using PHP, you
  565. can (and should) skip this step. Under ISAPI Filters, add a new
  566. ISAPI filter. Use PHP as the filter name, and supply a path to the
  567. php4isapi.dll / php5isapi.dll.
  568. * Under 'Home Directory', 'Virtual Directory', or 'Directory', do
  569. the following:
  570. * Change the Execute Permissions to 'Scripts only'
  571. * Click on the 'Configuration' button, and choose the Application
  572. Mappings tab. Click Add and set the Executable path to the
  573. appropriate ISAPI DLL. An example PHP 5 value is:
  574. C:\php\php5isapi.dll Supply .php as the extension. Leave 'Method
  575. exclusions' blank, and check the 'Script engine' checkbox. Now,
  576. click OK a few times.
  577. * Stop IIS completely (NET STOP iisadmin)
  578. * Start IIS again (NET START w3svc)
  579.  
  580. With IIS 6 (2003 Server), open up the IIS Manager, go to Web Service
  581. Extensions, choose "Add a new Web service extension", enter in a name
  582. such as PHP, choose the Add button and for the value browse to either
  583. the ISAPI file (php4isapi.dll or php5isapi.dll) or CGI (php.exe or
  584. php-cgi.exe) then check "Set extension status to Allowed" and click
  585. OK.
  586.  
  587. In order to use index.php as a default content page, do the following:
  588. From within the Documents tab, choose Add. Type in index.php and click
  589. OK. Adjust the order by choosing Move Up or Move Down. This is similar
  590. to setting DirectoryIndex with Apache.
  591.  
  592. The steps above must be repeated for each extension that is to be
  593. associated with PHP scripts. .php is the most common although .php3
  594. may be required for legacy applications.
  595.  
  596. If you experience 100% CPU usage after some time, turn off the IIS
  597. setting Cache ISAPI Application.
  598. _________________________________________________________________
  599.  
  600. Windows and PWS 4
  601.  
  602. PWS 4 does not support ISAPI, only PHP CGI should be used.
  603.  
  604. * Edit the enclosed pws-php4cgi.reg / pws-php5cgi.reg file (look
  605. into the SAPI folder for PHP 4, or in the main folder for PHP 5)
  606. to reflect the location of your php.exe / php-cgi.exe. Backslashes
  607. should be escaped, for example:
  608. [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parame
  609. ters\Script Map] ".php"="C:\\php\\php.exe" (change to
  610. C:\\php\\php-cgi.exe if you are using PHP 5) Now merge this
  611. registery file into your system; you may do this by
  612. double-clicking it.
  613. * In the PWS Manager, right click on a given directory you want to
  614. add PHP support to, and select Properties. Check the 'Execute'
  615. checkbox, and confirm.
  616. _________________________________________________________________
  617.  
  618. Windows and PWS/IIS 3
  619.  
  620. The recommended method for configuring these servers is to use the REG
  621. file included with the distribution (pws-php4cgi.reg in the SAPI
  622. folder for PHP 4, or pws-php5cgi.reg in the main folder for PHP 5).
  623. You may want to edit this file and make sure the extensions and PHP
  624. install directories match your configuration. Or you can follow the
  625. steps below to do it manually.
  626.  
  627. Warning
  628.  
  629. These steps involve working directly with the Windows registry. One
  630. error here can leave your system in an unstable state. We highly
  631. recommend that you back up your registry first. The PHP Development
  632. team will not be held responsible if you damage your registry.
  633.  
  634. * Run Regedit.
  635. * Navigate to: HKEY_LOCAL_MACHINE /System /CurrentControlSet
  636. /Services /W3Svc /Parameters /ScriptMap.
  637. * On the edit menu select: New->String Value.
  638. * Type in the extension you wish to use for your php scripts. For
  639. example .php
  640. * Double click on the new string value and enter the path to php.exe
  641. in the value data field. ex: C:\php\php.exe for PHP 4, or
  642. C:\php\php-cgi.exe for PHP 5.
  643. * Repeat these steps for each extension you wish to associate with
  644. PHP scripts.
  645.  
  646. The following steps do not affect the web server installation and only
  647. apply if you want your PHP scripts to be executed when they are run
  648. from the command line (ex. run C:\myscripts\test.php) or by double
  649. clicking on them in a directory viewer window. You may wish to skip
  650. these steps as you might prefer the PHP files to load into a text
  651. editor when you double click on them.
  652.  
  653. * Navigate to: HKEY_CLASSES_ROOT
  654. * On the edit menu select: New->Key.
  655. * Name the key to the extension you setup in the previous section.
  656. ex: .php
  657. * Highlight the new key and in the right side pane, double click the
  658. "default value" and enter phpfile.
  659. * Repeat the last step for each extension you set up in the previous
  660. section.
  661. * Now create another New->Key under HKEY_CLASSES_ROOT and name it
  662. phpfile.
  663. * Highlight the new key phpfile and in the right side pane, double
  664. click the "default value" and enter PHP Script.
  665. * Right click on the phpfile key and select New->Key, name it Shell.
  666. * Right click on the Shell key and select New->Key, name it open.
  667. * Right click on the open key and select New->Key, name it command.
  668. * Highlight the new key command and in the right side pane, double
  669. click the "default value" and enter the path to php.exe. ex:
  670. c:\php\php.exe -q %1. (don't forget the %1).
  671. * Exit Regedit.
  672. * If using PWS on Windows, reboot to reload the registry.
  673.  
  674. PWS and IIS 3 users now have a fully operational system. IIS 3 users
  675. can use a nifty tool from Steven Genusa to configure their script
  676. maps.
  677. _________________________________________________________________
  678.  
  679. Apache 1.3.x on Microsoft Windows
  680.  
  681. This section contains notes and hints specific to Apache 1.3.x
  682. installs of PHP on Microsoft Windows systems. There are also
  683. instructions and notes for Apache 2 on a separate page.
  684.  
  685. Note: Please read the manual installation steps first!
  686.  
  687. There are two ways to set up PHP to work with Apache 1.3.x on Windows.
  688. One is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for
  689. PHP 5), the other is to use the Apache Module DLL. In either case you
  690. need to edit your httpd.conf to configure Apache to work with PHP, and
  691. then restart the server.
  692.  
  693. It is worth noting here that now the SAPI module has been made more
  694. stable under Windows, we recommend it's use above the CGI binary,
  695. since it is more transparent and secure.
  696.  
  697. Although there can be a few variations of configuring PHP under
  698. Apache, these are simple enough to be used by the newcomer. Please
  699. consult the Apache Documentation for further configuration directives.
  700.  
  701. After changing the configuration file, remember to restart the server,
  702. for example, NET STOP APACHE followed by NET START APACHE, if you run
  703. Apache as a Windows Service, or use your regular shortcuts.
  704.  
  705. Note: Remember that when adding path values in the Apache
  706. configuration files on Windows, all backslashes such as
  707. c:\directory\file.ext must be converted to forward slashes, as
  708. c:/directory/file.ext.
  709. _________________________________________________________________
  710.  
  711. Installing as an Apache module
  712.  
  713. You should add the following lines to your Apache httpd.conf file:
  714.  
  715. Example 2-3. PHP as an Apache 1.3.x module
  716.  
  717. This assumes PHP is installed to c:\php. Adjust the path if this is
  718. not the case.
  719.  
  720. For PHP 4:
  721. # Add to the end of the LoadModule section
  722. LoadModule php4_module "c:/php/php4apache.dll"
  723.  
  724. # Add to the end of the AddModule section
  725. AddModule mod_php4.c
  726.  
  727. For PHP 5:
  728. # Add to the end of the LoadModule section
  729. LoadModule php5_module "c:/php/php5apache.dll"
  730.  
  731. # Add to the end of the AddModule section
  732. AddModule mod_php5.c
  733.  
  734. For both:
  735. # Add this line inside the <IfModule mod_mime.c> conditional brace
  736. AddType application/x-httpd-php .php
  737.  
  738. # For syntax highlighted .phps files, also add
  739. AddType application/x-httpd-php-source .phps
  740. _________________________________________________________________
  741.  
  742. Installing as a CGI binary
  743.  
  744. If you unzipped the PHP package to C:\php\ as described in the Manual
  745. Installation Steps section, you need to insert these lines to your
  746. Apache configuration file to set up the CGI binary:
  747.  
  748. Example 2-4. PHP and Apache 1.3.x as CGI
  749. ScriptAlias /php/ "c:/php/"
  750. AddType application/x-httpd-php .php
  751.  
  752. # For PHP 4
  753. Action application/x-httpd-php "/php/php.exe"
  754.  
  755. # For PHP 5
  756. Action application/x-httpd-php "/php/php-cgi.exe"
  757.  
  758. # specify the directory where php.ini is
  759. SetEnv PHPRC C:/php
  760.  
  761. Note that the second line in the list above can be found in the actual
  762. versions of httpd.conf, but it is commented out. Remember also to
  763. substitute the c:/php/ for your actual path to PHP.
  764.  
  765. Warning
  766.  
  767. By using the CGI setup, your server is open to several possible
  768. attacks. Please read our CGI security section to learn how to defend
  769. yourself from those attacks.
  770.  
  771. If you would like to present PHP source files syntax highlighted,
  772. there is no such convenient option as with the module version of PHP.
  773. If you chose to configure Apache to use PHP as a CGI binary, you will
  774. need to use the highlight_file() function. To do this simply create a
  775. PHP script file and add this code: <?php
  776. highlight_file('some_php_script.php'); ?>.
  777. _________________________________________________________________
  778.  
  779. Apache 2.0.x on Microsoft Windows
  780.  
  781. This section contains notes and hints specific to Apache 2.0.x
  782. installs of PHP on Microsoft Windows systems. We also have
  783. instructions and notes for Apache 1.3.x users on a separate page.
  784.  
  785. Note: You should read the manual installation steps first!
  786.  
  787. Warning
  788.  
  789. We do not recommend using a threaded MPM in production with Apache2.
  790. Use the prefork MPM instead, or use Apache1. For information on why,
  791. read the following FAQ entry
  792.  
  793. You are highly encouraged to take a look at the Apache Documentation
  794. to get a basic understanding of the Apache 2.0.x Server. Also consider
  795. to read the Windows specific notes for Apache 2.0.x before reading on
  796. here.
  797.  
  798. PHP and Apache 2.0.x compatibility notes: The following versions of
  799. PHP are known to work with the most recent version of Apache 2.0.x:
  800.  
  801. * PHP 4.3.0 or later available at http://www.php.net/downloads.php.
  802. * the latest stable development version. Get the source code
  803. http://snaps.php.net/php4-latest.tar.gz or download binaries for
  804. Windows http://snaps.php.net/win32/php4-win32-latest.zip.
  805. * a prerelease version downloadable from http://qa.php.net/.
  806. * you have always the option to obtain PHP through anonymous CVS.
  807.  
  808. These versions of PHP are compatible to Apache 2.0.40 and later.
  809.  
  810. Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works
  811. with Apache 2.0.39, don't use any other version of Apache with PHP
  812. 4.2.3. However, the recommended setup is to use PHP 4.3.0 or later
  813. with the most recent version of Apache2.
  814.  
  815. All mentioned versions of PHP will work still with Apache 1.3.x.
  816.  
  817. Warning
  818.  
  819. Apache 2.0.x is designed to run on Windows NT 4.0, Windows 2000 or
  820. Windows XP. At this time, support for Windows 9x is incomplete. Apache
  821. 2.0.x is not expected to work on those platforms at this time.
  822.  
  823. Download the most recent version of Apache 2.0.x and a fitting PHP
  824. version. Follow the Manual Installation Steps and come back to go on
  825. with the integration of PHP and Apache.
  826.  
  827. There are two ways to set up PHP to work with Apache 2.0.x on Windows.
  828. One is to use the CGI binary the other is to use the Apache module
  829. DLL. In either case you need to edit your httpd.conf to configure
  830. Apache to work with PHP and then restart the server.
  831.  
  832. Note: Remember that when adding path values in the Apache
  833. configuration files on Windows, all backslashes such as
  834. c:\directory\file.ext must be converted to forward slashes, as
  835. c:/directory/file.ext.
  836. _________________________________________________________________
  837.  
  838. Installing as a CGI binary
  839.  
  840. You need to insert these three lines to your Apache httpd.conf
  841. configuration file to set up the CGI binary:
  842.  
  843. Example 2-5. PHP and Apache 2.0 as CGI
  844. ScriptAlias /php/ "c:/php/"
  845. AddType application/x-httpd-php .php
  846.  
  847. # For PHP 4
  848. Action application/x-httpd-php "/php/php.exe"
  849.  
  850. # For PHP 5
  851. Action application/x-httpd-php "/php/php-cgi.exe"
  852.  
  853. Warning
  854.  
  855. By using the CGI setup, your server is open to several possible
  856. attacks. Please read our CGI security section to learn how to defend
  857. yourself from those attacks.
  858. _________________________________________________________________
  859.  
  860. Installing as an Apache module
  861.  
  862. You need to insert these two lines to your Apache httpd.conf
  863. configuration file to set up the PHP module for Apache 2.0:
  864.  
  865. Example 2-6. PHP and Apache 2.0 as Module
  866. # For PHP 4 do something like this:
  867. LoadModule php4_module "c:/php/php4apache2.dll"
  868. AddType application/x-httpd-php .php
  869.  
  870. # For PHP 5 do something like this:
  871. LoadModule php5_module "c:/php/php5apache2.dll"
  872. AddType application/x-httpd-php .php
  873.  
  874. # configure the path to php.ini
  875. PHPIniDir "C:/php"
  876.  
  877. Note: Remember to substitute the c:/php/ for your actual path to
  878. PHP in the above examples. Take care to use either php4apache2.dll
  879. or php5apache2.dll in your LoadModule directive and not
  880. php4apache.dll or php5apache.dll as the latter ones are designed to
  881. run with Apache 1.3.x.
  882.  
  883. Note: If you want to use content negotiation, read related FAQ.
  884.  
  885. Warning
  886.  
  887. Don't mix up your installation with DLL files from different PHP
  888. versions. You have the only choice to use the DLL's and extensions
  889. that ship with your downloaded PHP version.
  890. _________________________________________________________________
  891.  
  892. Sun, iPlanet and Netscape servers on Microsoft Windows
  893.  
  894. This section contains notes and hints specific to Sun Java System Web
  895. Server, Sun ONE Web Server, iPlanet and Netscape server installs of
  896. PHP on Windows.
  897.  
  898. From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to
  899. generate custom directory listings and error pages. Additional
  900. functions for Apache compatibility are also available. For support in
  901. current webservers read the note about subrequests.
  902. _________________________________________________________________
  903.  
  904. CGI setup on Sun, iPlanet and Netscape servers
  905.  
  906. To install PHP as a CGI handler, do the following:
  907.  
  908. * Copy php4ts.dll to your systemroot (the directory where you
  909. installed Windows)
  910. * Make a file association from the command line. Type the following
  911. two lines:
  912.  
  913. assoc .php=PHPScript
  914. ftype PHPScript=c:\php\php.exe %1 %*
  915.  
  916. * In the Netscape Enterprise Administration Server create a dummy
  917. shellcgi directory and remove it just after (this step creates 5
  918. important lines in obj.conf and allow the web server to handle
  919. shellcgi scripts).
  920. * In the Netscape Enterprise Administration Server create a new mime
  921. type (Category: type, Content-Type: magnus-internal/shellcgi, File
  922. Suffix:php).
  923. * Do it for each web server instance you want PHP to run
  924.  
  925. More details about setting up PHP as a CGI executable can be found
  926. here: http://benoit.noss.free.fr/php/install-php.html
  927. _________________________________________________________________
  928.  
  929. NSAPI setup on Sun, iPlanet and Netscape servers
  930.  
  931. To install PHP with NSAPI, do the following:
  932.  
  933. * Copy php4ts.dll to your systemroot (the directory where you
  934. installed Windows)
  935. * Make a file association from the command line. Type the following
  936. two lines:
  937.  
  938. assoc .php=PHPScript
  939. ftype PHPScript=c:\php\php.exe %1 %*
  940.  
  941. * In the Netscape Enterprise Administration Server create a new mime
  942. type (Category: type, Content-Type: magnus-internal/x-httpd-php,
  943. File Suffix: php).
  944. * Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6)
  945. and add the following: You should place the lines after mime types
  946. init.
  947.  
  948. Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:
  949. /php/sapi/php4nsapi.dll"
  950. Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php
  951. _ini="c:/path/to/php.ini"]
  952.  
  953. (PHP >= 4.3.3) The php_ini parameter is optional but with it you
  954. can place your php.ini in your webserver config directory.
  955. * Configure the default object in obj.conf (for virtual server
  956. classes [Sun Web Server 6.0+] in their vserver.obj.conf): In the
  957. <Object name="default"> section, place this line necessarily after
  958. all 'ObjectType' and before all 'AddLog' lines:
  959.  
  960. Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inik
  961. ey=value ...]
  962.  
  963. (PHP >= 4.3.3) As additional parameters you can add some special
  964. php.ini-values, for example you can set a
  965. docroot="/path/to/docroot" specific to the context php4_execute is
  966. called. For boolean ini-keys please use 0/1 as value, not
  967. "On","Off",... (this will not work correctly), e.g.
  968. zlib.output_compression=1 instead of zlib.output_compression="On"
  969. * This is only needed if you want to configure a directory that only
  970. consists of PHP scripts (same like a cgi-bin directory):
  971.  
  972. <Object name="x-httpd-php">
  973. ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
  974. Service fn=php4_execute [inikey=value inikey=value ...]
  975. </Object>
  976.  
  977. After that you can configure a directory in the Administration
  978. server and assign it the style x-httpd-php. All files in it will
  979. get executed as PHP. This is nice to hide PHP usage by renaming
  980. files to .html.
  981. * Restart your web service and apply changes
  982. * Do it for each web server instance you want PHP to run
  983.  
  984. Note: More details about setting up PHP as an NSAPI filter can be
  985. found here: http://benoit.noss.free.fr/php/install-php4.html
  986.  
  987. Note: The stacksize that PHP uses depends on the configuration of
  988. the webserver. If you get crashes with very large PHP scripts, it
  989. is recommended to raise it with the Admin Server (in the section
  990. "MAGNUS EDITOR").
  991. _________________________________________________________________
  992.  
  993. CGI environment and recommended modifications in php.ini
  994.  
  995. Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
  996. WS/iPlanet/Netscape is a multithreaded web server. Because of that all
  997. requests are running in the same process space (the space of the
  998. webserver itself) and this space has only one environment. If you want
  999. to get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the
  1000. correct way to try this in the old PHP 3.x way with getenv() or a
  1001. similar way (register globals to environment, $_ENV). You would only
  1002. get the environment of the running webserver without any valid CGI
  1003. variables!
  1004.  
  1005. Note: Why are there (invalid) CGI variables in the environment?
  1006.  
  1007. Answer: This is because you started the webserver process from the
  1008. admin server which runs the startup script of the webserver, you
  1009. wanted to start, as a CGI script (a CGI script inside of the admin
  1010. server!). This is why the environment of the started webserver has
  1011. some CGI environment variables in it. You can test this by starting
  1012. the webserver not from the administration server. Use the command
  1013. line as root user and start it manually - you will see there are no
  1014. CGI-like environment variables.
  1015.  
  1016. Simply change your scripts to get CGI variables in the correct way for
  1017. PHP 4.x by using the superglobal $_SERVER. If you have older scripts
  1018. which use $HTTP_HOST, etc., you should turn on register_globals in
  1019. php.ini and change the variable order too (important: remove "E" from
  1020. it, because you do not need the environment here):
  1021. variables_order = "GPCS"
  1022. register_globals = On
  1023. _________________________________________________________________
  1024.  
  1025. Special use for error pages or self-made directory listings (PHP >= 4.3.3)
  1026.  
  1027. You can use PHP to generate the error pages for "404 Not Found" or
  1028. similar. Add the following line to the object in obj.conf for every
  1029. error page you want to overwrite:
  1030. Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value ini
  1031. key=value...]
  1032.  
  1033. where XXX is the HTTP error code. Please delete any other Error
  1034. directives which could interfere with yours. If you want to place a
  1035. page for all errors that could exist, leave the code parameter out.
  1036. Your script can get the HTTP status code with $_SERVER['ERROR_TYPE'].
  1037.  
  1038. Another possibility is to generate self-made directory listings. Just
  1039. create a PHP script which displays a directory listing and replace the
  1040. corresponding default Service line for
  1041. type="magnus-internal/directory" in obj.conf with the following:
  1042. Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scr
  1043. ipt.php" [inikey=value inikey=value...]
  1044.  
  1045. For both error and directory listing pages the original URI and
  1046. translated URI are in the variables $_SERVER['PATH_INFO'] and
  1047. $_SERVER['PATH_TRANSLATED'].
  1048. _________________________________________________________________
  1049.  
  1050. Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)
  1051.  
  1052. The NSAPI module now supports the nsapi_virtual() function (alias:
  1053. virtual()) to make subrequests on the webserver and insert the result
  1054. in the webpage. The problem is, that this function uses some
  1055. undocumented features from the NSAPI library.
  1056.  
  1057. Under Unix this is not a problem, because the module automatically
  1058. looks for the needed functions and uses them if available. If not,
  1059. nsapi_virtual() is disabled.
  1060.  
  1061. Under Windows limitations in the DLL handling need the use of a
  1062. automatic detection of the most recent ns-httpdXX.dll file. This is
  1063. tested for servers till version 6.1. If a newer version of the Sun
  1064. server is used, the detection fails and nsapi_virtual() is disabled.
  1065.  
  1066. If this is the case, try the following: Add the following parameter to
  1067. php4_init in magnus.conf/obj.conf:
  1068. Init fn=php4_init ... server_lib="ns-httpdXX.dll"
  1069.  
  1070. where XX is the correct DLL version number. To get it, look in the
  1071. server-root for the correct DLL name. The DLL with the biggest
  1072. filesize is the right one.
  1073.  
  1074. You can check the status by using the phpinfo() function.
  1075.  
  1076. Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!
  1077. _________________________________________________________________
  1078.  
  1079. OmniHTTPd Server
  1080.  
  1081. This section contains notes and hints specific to OmniHTTPd on
  1082. Windows.
  1083.  
  1084. Note: You should read the manual installation steps first!
  1085.  
  1086. Warning
  1087.  
  1088. By using the CGI setup, your server is open to several possible
  1089. attacks. Please read our CGI security section to learn how to defend
  1090. yourself from those attacks.
  1091.  
  1092. You need to complete the following steps to make PHP work with
  1093. OmniHTTPd. This is a CGI executable setup. SAPI is supported by
  1094. OmniHTTPd, but some tests have shown that it is not so stable to use
  1095. PHP as an ISAPI module.
  1096.  
  1097. Important for CGI users: Read the faq on cgi.force_redirect for
  1098. important details. This directive needs to be set to 0.
  1099.  
  1100. 1. Install OmniHTTPd server.
  1101. 2. Right click on the blue OmniHTTPd icon in the system tray and
  1102. select Properties
  1103. 3. Click on Web Server Global Settings
  1104. 4. On the 'External' tab, enter: virtual = .php | actual =
  1105. c:\php\php.exe (use php-cgi.exe if installing PHP 5), and use the
  1106. Add button.
  1107. 5. On the Mime tab, enter: virtual = wwwserver/stdcgi | actual =
  1108. .php, and use the Add button.
  1109. 6. Click OK
  1110.  
  1111. Repeat steps 2 - 6 for each extension you want to associate with PHP.
  1112.  
  1113. Note: Some OmniHTTPd packages come with built in PHP support. You
  1114. can choose at setup time to do a custom setup, and uncheck the PHP
  1115. component. We recommend you to use the latest PHP binaries. Some
  1116. OmniHTTPd servers come with PHP 4 beta distributions, so you should
  1117. choose not to set up the built in support, but install your own. If
  1118. the server is already on your machine, use the Replace button in
  1119. Step 4 and 5 to set the new, correct information.
  1120. _________________________________________________________________
  1121.  
  1122. Sambar Server on Microsoft Windows
  1123.  
  1124. This section contains notes and hints specific to the Sambar Server
  1125. for Windows.
  1126.  
  1127. Note: You should read the manual installation steps first!
  1128.  
  1129. This list describes how to set up the ISAPI module to work with the
  1130. Sambar server on Windows.
  1131.  
  1132. * Find the file called mappings.ini (in the config directory) in the
  1133. Sambar install directory.
  1134. * Open mappings.ini and add the following line under [ISAPI]:
  1135.  
  1136. Example 2-7. ISAPI configuration of Sambar
  1137. #for PHP 4
  1138. *.php = c:\php\php4isapi.dll
  1139.  
  1140. #for PHP 5
  1141. *.php = c:\php\php5isapi.dll
  1142.  
  1143. (This line assumes that PHP was installed in c:\php.)
  1144. * Now restart the Sambar server for the changes to take effect.
  1145. _________________________________________________________________
  1146.  
  1147. Xitami on Microsoft Windows
  1148.  
  1149. This section contains notes and hints specific to Xitami on Windows.
  1150.  
  1151. Note: You should read the manual installation steps first!
  1152.  
  1153. This list describes how to set up the PHP CGI binary to work with
  1154. Xitami on Windows.
  1155.  
  1156. Important for CGI users: Read the faq on cgi.force_redirect for
  1157. important details. This directive needs to be set to 0. If you want
  1158. to use $_SERVER['PHP_SELF'] you have to enable the cgi.fix_pathinfo
  1159. directive.
  1160.  
  1161. Warning
  1162.  
  1163. By using the CGI setup, your server is open to several possible
  1164. attacks. Please read our CGI security section to learn how to defend
  1165. yourself from those attacks.
  1166.  
  1167. * Make sure the webserver is running, and point your browser to
  1168. xitamis admin console (usually http://127.0.0.1/admin), and click
  1169. on Configuration.
  1170. * Navigate to the Filters, and put the extension which PHP should
  1171. parse (i.e. .php) into the field File extensions (.xxx).
  1172. * In Filter command or script put the path and name of your PHP CGI
  1173. executable i.e. C:\php\php.exe for PHP 4, or C:\php\php-cgi.exe
  1174. for PHP 5.
  1175. * Press the 'Save' icon.
  1176. * Restart the server to reflect changes.
  1177. _________________________________________________________________
  1178.  
  1179. Installation of extensions on Windows
  1180.  
  1181. After installing PHP and a webserver on Windows, you will probably
  1182. want to install some extensions for added functionality. You can
  1183. choose which extensions you would like to load when PHP starts by
  1184. modifying your php.ini. You can also load a module dynamically in your
  1185. script using dl().
  1186.  
  1187. The DLLs for PHP extensions are prefixed with php_.
  1188.  
  1189. Note: In PHP 4.3.1 BCMath, Calendar, COM, Ctype, FTP, MySQL, ODBC,
  1190. Overload, PCRE, Session, Tokenizer, WDDX, XML and Zlib support is
  1191. built in. You don't need to load any additional extensions in order
  1192. to use these functions. See your distributions README.txt or
  1193. install.txt or this table for a list of built in modules.
  1194.  
  1195. The default location PHP searches for extensions is c:\php4\extensions
  1196. in PHP 4 and c:\php5 in PHP 5. To change this setting to reflect your
  1197. setup of PHP edit your php.ini file:
  1198.  
  1199. * You will need to change the extension_dir setting to point to the
  1200. directory where your extensions lives, or where you have placed
  1201. your php_*.dll files. Please do not forget the last backslash. For
  1202. example:
  1203.  
  1204. extension_dir = c:/php/extensions/
  1205.  
  1206. * Enable the extension(s) in php.ini you want to use by uncommenting
  1207. the extension=php_*.dll lines in php.ini. This is done by deleting
  1208. the leading ; from the extension you want to load.
  1209.  
  1210. Example 2-8. Enable Bzip2 extension for PHP-Windows
  1211. // change the following line from ...
  1212. ;extension=php_bz2.dll
  1213.  
  1214. // ... to
  1215. extension=php_bz2.dll
  1216.  
  1217. * Some of the extensions need extra DLLs to work. Couple of them can
  1218. be found in the distribution package, in the C:\php\dlls\ folder
  1219. in PHP 4 or in the main folder in PHP 5, but some, for example
  1220. Oracle (php_oci8.dll) require DLLs which are not bundled with the
  1221. distribution package. If you are installing PHP 4, copy the
  1222. bundled DLLs from C:\php\dlls folder to the main C:\php folder.
  1223. Don't forget to include C:\php in the system PATH (this process is
  1224. explained in a separate FAQ entry).
  1225. * Some of these DLLs are not bundled with the PHP distribution. See
  1226. each extensions documentation page for details. Also, read the
  1227. manual section titled Installation of PECL extensions for details
  1228. on PECL. An increasingly large number of PHP extensions are found
  1229. in PECL, and these extensions require a separate download.
  1230.  
  1231. Note: If you are running a server module version of PHP remember to
  1232. restart your webserver to reflect your changes to php.ini.
  1233.  
  1234. The following table describes some of the extensions available and
  1235. required additional dlls.
  1236.  
  1237. Table 2-1. PHP Extensions
  1238. Extension Description Notes
  1239. php_bz2.dll bzip2 compression functions None
  1240. php_calendar.dll Calendar conversion functions Built in since PHP
  1241. 4.0.3
  1242. php_cpdf.dll ClibPDF functions None
  1243. php_crack.dll Crack functions None
  1244. php_ctype.dll ctype family functions Built in since PHP 4.3.0
  1245. php_curl.dll CURL, Client URL library functions Requires:
  1246. libeay32.dll, ssleay32.dll (bundled)
  1247. php_cybercash.dll Cybercash payment functions PHP <= 4.2.0
  1248. php_db.dll DBM functions Deprecated. Use DBA instead (php_dba.dll)
  1249. php_dba.dll DBA: DataBase (dbm-style) Abstraction layer functions None
  1250. php_dbase.dll dBase functions None
  1251. php_dbx.dll dbx functions
  1252. php_domxml.dll DOM XML functions PHP <= 4.2.0 requires: libxml2.dll
  1253. (bundled) PHP >= 4.3.0 requires: iconv.dll (bundled)
  1254. php_dotnet.dll .NET functions PHP <= 4.1.1
  1255. php_exif.dll EXIF functions php_mbstring.dll. And, php_exif.dll must
  1256. be loaded after php_mbstring.dll in php.ini.
  1257. php_fbsql.dll FrontBase functions PHP <= 4.2.0
  1258. php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll
  1259. (bundled)
  1260. php_filepro.dll filePro functions Read-only access
  1261. php_ftp.dll FTP functions Built-in since PHP 4.0.3
  1262. php_gd.dll GD library image functions Removed in PHP 4.3.2. Also note
  1263. that truecolor functions are not available in GD1, instead, use
  1264. php_gd2.dll.
  1265. php_gd2.dll GD library image functions GD2
  1266. php_gettext.dll Gettext functions PHP <= 4.2.0 requires
  1267. gnu_gettext.dll (bundled), PHP >= 4.2.3 requires libintl-1.dll,
  1268. iconv.dll (bundled).
  1269. php_hyperwave.dll HyperWave functions None
  1270. php_iconv.dll ICONV characterset conversion Requires: iconv-1.3.dll
  1271. (bundled), PHP >=4.2.1 iconv.dll
  1272. php_ifx.dll Informix functions Requires: Informix libraries
  1273. php_iisfunc.dll IIS management functions None
  1274. php_imap.dll IMAP POP3 and NNTP functions None
  1275. php_ingres.dll Ingres II functions Requires: Ingres II libraries
  1276. php_interbase.dll InterBase functions Requires: gds32.dll (bundled)
  1277. php_java.dll Java functions PHP <= 4.0.6 requires: jvm.dll (bundled)
  1278. php_ldap.dll LDAP functions PHP <= 4.2.0 requires libsasl.dll
  1279. (bundled), PHP >= 4.3.0 requires libeay32.dll, ssleay32.dll (bundled)
  1280. php_mbstring.dll Multi-Byte String functions None
  1281. php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
  1282. php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll
  1283. (bundled)
  1284. php_mime_magic.dll Mimetype functions Requires: magic.mime (bundled)
  1285. php_ming.dll Ming functions for Flash None
  1286. php_msql.dll mSQL functions Requires: msql.dll (bundled)
  1287. php_mssql.dll MSSQL functions Requires: ntwdblib.dll (bundled)
  1288. php_mysql.dll MySQL functions PHP >= 5.0.0, requires libmysql.dll
  1289. (bundled)
  1290. php_mysqli.dll MySQLi functions PHP >= 5.0.0, requires libmysql.dll
  1291. (libmysqli.dll in PHP <= 5.0.2) (bundled)
  1292. php_oci8.dll Oracle 8 functions Requires: Oracle 8.1+ client libraries
  1293. php_openssl.dll OpenSSL functions Requires: libeay32.dll (bundled)
  1294. php_oracle.dll Oracle functions Requires: Oracle 7 client libraries
  1295. php_overload.dll Object overloading functions Built in since PHP 4.3.0
  1296. php_pdf.dll PDF functions None
  1297. php_pgsql.dll PostgreSQL functions None
  1298. php_printer.dll Printer functions None
  1299. php_shmop.dll Shared Memory functions None
  1300. php_snmp.dll SNMP get and walk functions NT only!
  1301. php_soap.dll SOAP functions PHP >= 5.0.0
  1302. php_sockets.dll Socket functions None
  1303. php_sybase_ct.dll Sybase functions Requires: Sybase client libraries
  1304. php_tidy.dll Tidy functions PHP >= 5.0.0
  1305. php_tokenizer.dll Tokenizer functions Built in since PHP 4.3.0
  1306. php_w32api.dll W32api functions None
  1307. php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll
  1308. (bundled)
  1309. php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll,
  1310. expat.dll (bundled). PHP >= 4.2.1 requires sablot.dll, expat.dll,
  1311. iconv.dll (bundled).
  1312. php_yaz.dll YAZ functions Requires: yaz.dll (bundled)
  1313. php_zip.dll Zip File functions Read only access
  1314. php_zlib.dll ZLib compression functions Built in since PHP 4.3.0
  1315. _________________________________________________________________
  1316.  
  1317. Chapter 3. Installation of PECL extensions
  1318.  
  1319. Introduction to PECL Installations
  1320.  
  1321. PHP extensions may be installed in a variety of ways. PECL is a
  1322. repository of PHP extensions living within the PEAR structure, and the
  1323. following demonstrates how to install these extensions.
  1324.  
  1325. These instructions assume /your/phpsrcdir/ is the path to the PHP
  1326. source, and extname is the name of the PECL extension. Adjust
  1327. accordingly. These instructions also assume a familiarity with the
  1328. pear command.
  1329.  
  1330. Shared extensions may be installed by including them inside of php.ini
  1331. using the extension PHP directive. See also the extensions_dir
  1332. directive, and dl(). The installation methods described below do not
  1333. automatically configure PHP to include these extensions, this step
  1334. must be done manually.
  1335.  
  1336. When building PHP modules, it's important to have the appropriate
  1337. versions of the required tools (autoconf, automake, libtool, etc.) See
  1338. the Anonymous CVS Instructions for details on the required tools, and
  1339. required versions.
  1340. _________________________________________________________________
  1341.  
  1342. Downloading PECL extensions
  1343.  
  1344. There are several options for downloading PECL extensions, such as:
  1345.  
  1346. * http://pecl.php.net
  1347. Listed here is information like the ChangeLog, release
  1348. information, requirements, revisions, etc. Although not every PECL
  1349. extension has a webpage, most do.
  1350. * pear download extname
  1351. The pear command may also be used to download source files.
  1352. Specific revisions may also be specified.
  1353. * CVS
  1354. All PECL files reside in CVS. A web-based view may be seen at
  1355. http://cvs.php.net/pecl/. To download straight from CVS, consider
  1356. the following where phpfi is the password for user cvsread:
  1357.  
  1358. $ cvs -d:pserver:cvsread@cvs.php.net:/repository login
  1359. $ cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/extname
  1360.  
  1361. * Windows downloads
  1362. Windows users may find compiled PECL binaries by downloading the
  1363. Collection of PECL modules from the PHP Downloads page, and by
  1364. retrieving a PECL Snapshot. To compile PHP under Windows, read the
  1365. Win32 Build README.
  1366. _________________________________________________________________
  1367.  
  1368. PECL for Windows users
  1369.  
  1370. Like with any other PHP extension DLL, to install move the PECL
  1371. extension DLLs into the extension_dir folder and include them within
  1372. php.ini. For example:
  1373.  
  1374. extension=php_extname.dll
  1375.  
  1376. After doing this, restart the web server.
  1377. _________________________________________________________________
  1378.  
  1379. Compiling shared PECL extensions with PEAR
  1380.  
  1381. PEAR makes it easy to create shared PHP extensions. Using the pear
  1382. command, do the following:
  1383.  
  1384. $ pear install extname
  1385.  
  1386. That will download the source for extname, and compile it on the
  1387. system. This results in an extname.so file that may then be included
  1388. in php.ini
  1389.  
  1390. In case the systems preferred_state is set higher than an available
  1391. extname version, like it's set to stable and the extension is still in
  1392. beta, either alter the preferred_state via pear config-set or specify
  1393. a specific version of the PECL extension. For example:
  1394.  
  1395. $ pear install extname-0.1.1
  1396.  
  1397. Regardless, pear will copy this extname.so into the extensions
  1398. directory. Adjust php.ini accordingly.
  1399. _________________________________________________________________
  1400.  
  1401. Compiling shared PECL extensions with phpize
  1402.  
  1403. If using pear is not an option, like for building shared PECL
  1404. extensions from CVS, or for unreleased PECL packages, then creating a
  1405. shared extension may also be done by manually using the phpize
  1406. command. The pear command essentially does this but it may also be
  1407. done manually. Assuming the source file is named extname.tgz, and that
  1408. it was downloaded into the current directory, consider the following:
  1409.  
  1410. $ pear download extname
  1411. $ gzip -d < extname.tgz | tar -xvf -
  1412. $ cd extname
  1413. $ phpize
  1414. $ ./configure && make
  1415.  
  1416. Upon success, this will create extname.so and put it into the modules/
  1417. and/or .libs/ directory within the extname/ source. Move this shared
  1418. extension (extname.so) into the PHP extensions directory, and adjust
  1419. php.ini accordingly.
  1420. _________________________________________________________________
  1421.  
  1422. Compiling PECL extensions statically into PHP
  1423.  
  1424. To statically include the extension within the PHP build, put the
  1425. extensions source into the ext/ directory found in the PHP source. For
  1426. example:
  1427.  
  1428. $ cd /your/phpsrcdir/ext
  1429. $ pear download extname
  1430. $ gzip -d < extname.tgz | tar -xvf -
  1431. $ mv extname-x.x.x extname
  1432. $ rm package.xml
  1433.  
  1434. This will result in the following directory:
  1435.  
  1436. /your/phpsrcdir/ext/extname
  1437.  
  1438. From here, build PHP as normal:
  1439.  
  1440. $ cd /your/phpsrcdir
  1441. $ ./buildconf
  1442. $ ./configure --help
  1443. $ ./configure --with-extname --enable-someotherext --with-foobar
  1444. $ make
  1445. $ make install
  1446.  
  1447. Whether --enable-extname or --with-extname is used depends on the
  1448. extension. Typically an extension that does not require external
  1449. libraries uses --enable. To be sure, run the following after
  1450. buildconf:
  1451.  
  1452. $ ./configure --help | grep extname
  1453. _________________________________________________________________
  1454.  
  1455. Chapter 4. Problems?
  1456.  
  1457. Read the FAQ
  1458.  
  1459. Some problems are more common than others. The most common ones are
  1460. listed in the PHP FAQ, part of this manual.
  1461. _________________________________________________________________
  1462.  
  1463. Other problems
  1464.  
  1465. If you are still stuck, someone on the PHP installation mailing list
  1466. may be able to help you. You should check out the archive first, in
  1467. case someone already answered someone else who had the same problem as
  1468. you. The archives are available from the support page on
  1469. http://www.php.net/support.php. To subscribe to the PHP installation
  1470. mailing list, send an empty mail to
  1471. php-install-subscribe@lists.php.net. The mailing list address is
  1472. php-install@lists.php.net.
  1473.  
  1474. If you want to get help on the mailing list, please try to be precise
  1475. and give the necessary details about your environment (which operating
  1476. system, what PHP version, what web server, if you are running PHP as
  1477. CGI or a server module, safe mode, etc...), and preferably enough code
  1478. to make others able to reproduce and test your problem.
  1479. _________________________________________________________________
  1480.  
  1481. Bug reports
  1482.  
  1483. If you think you have found a bug in PHP, please report it. The PHP
  1484. developers probably don't know about it, and unless you report it,
  1485. chances are it won't be fixed. You can report bugs using the
  1486. bug-tracking system at http://bugs.php.net/. Please do not send bug
  1487. reports in mailing list or personal letters. The bug system is also
  1488. suitable to submit feature requests.
  1489.  
  1490. Read the How to report a bug document before submitting any bug
  1491. reports!
  1492. _________________________________________________________________
  1493.  
  1494. Chapter 5. Runtime Configuration
  1495.  
  1496. The configuration file
  1497.  
  1498. The configuration file (called php3.ini in PHP 3, and simply php.ini
  1499. as of PHP 4) is read when PHP starts up. For the server module
  1500. versions of PHP, this happens only once when the web server is
  1501. started. For the CGI and CLI version, it happens on every invocation.
  1502.  
  1503. The default location of php.ini is a compile time option (see the FAQ
  1504. entry), but can be changed for the CGI and CLI version with the -c
  1505. command line switch, see the chapter about using PHP from the command
  1506. line. You can also use the environment variable PHPRC for an
  1507. additional path to search for a php.ini file.
  1508.  
  1509. If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
  1510. e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini.
  1511.  
  1512. Note: The Apache web server changes the directory to root at
  1513. startup causing PHP to attempt to read php.ini from the root
  1514. filesystem if it exists.
  1515.  
  1516. The php.ini directives handled by extensions are documented
  1517. respectively on the pages of the extensions themselves. The list of
  1518. the core directives is available in the appendix. Probably not all the
  1519. PHP directives are documented in the manual though. For a completel
  1520. list of directives available in your PHP version, please read your
  1521. well commented php.ini file. Alternatively, you may find the the
  1522. latest php.ini from CVS helpful too.
  1523.  
  1524. Example 5-1. php.ini example
  1525. ; any text on a line after an unquoted semicolon (;) is ignored
  1526. [php] ; section markers (text within square brackets) are also ignored
  1527. ; Boolean values can be set to either:
  1528. ; true, on, yes
  1529. ; or false, off, no, none
  1530. register_globals = off
  1531. track_errors = yes
  1532.  
  1533. ; you can enclose strings in double-quotes
  1534. include_path = ".:/usr/local/lib/php"
  1535.  
  1536. ; backslashes are treated the same as any other character
  1537. include_path = ".;c:\php\lib"
  1538. _________________________________________________________________
  1539.  
  1540. How to change configuration settings
  1541.  
  1542. Running PHP as an Apache module
  1543.  
  1544. When using PHP as an Apache module, you can also change the
  1545. configuration settings using directives in Apache configuration files
  1546. (e.g. httpd.conf) and .htaccess files. You will need "AllowOverride
  1547. Options" or "AllowOverride All" privileges to do so.
  1548.  
  1549. With PHP 4 and PHP 5, there are several Apache directives that allow
  1550. you to change the PHP configuration from within the Apache
  1551. configuration files. For a listing of which directives are
  1552. PHP_INI_ALL, PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the
  1553. List of php.ini directives appendix.
  1554.  
  1555. Note: With PHP 3, there are Apache directives that correspond to
  1556. each configuration setting in the php3.ini name, except the name is
  1557. prefixed by "php3_".
  1558.  
  1559. php_value name value
  1560. Sets the value of the specified directive. Can be used only
  1561. with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a
  1562. previously set value use none as the value.
  1563.  
  1564. Note: Don't use php_value to set boolean values. php_flag (see
  1565. below) should be used instead.
  1566.  
  1567. php_flag name on|off
  1568. Used to set a boolean configuration directive. Can be used only
  1569. with PHP_INI_ALL and PHP_INI_PERDIR type directives.
  1570.  
  1571. php_admin_value name value
  1572. Sets the value of the specified directive. This can not be used
  1573. in .htaccess files. Any directive type set with php_admin_value
  1574. can not be overridden by .htaccess or virtualhost directives.
  1575. To clear a previously set value use none as the value.
  1576.  
  1577. php_admin_flag name on|off
  1578. Used to set a boolean configuration directive. This can not be
  1579. used in .htaccess files. Any directive type set with
  1580. php_admin_flag can not be overridden by .htaccess or
  1581. virtualhost directives.
  1582.  
  1583. Example 5-2. Apache configuration example
  1584. <IfModule mod_php5.c>
  1585. php_value include_path ".:/usr/local/lib/php"
  1586. php_admin_flag safe_mode on
  1587. </IfModule>
  1588. <IfModule mod_php4.c>
  1589. php_value include_path ".:/usr/local/lib/php"
  1590. php_admin_flag safe_mode on
  1591. </IfModule>
  1592. <IfModule mod_php3.c>
  1593. php3_include_path ".:/usr/local/lib/php"
  1594. php3_safe_mode on
  1595. </IfModule>
  1596.  
  1597. Caution
  1598.  
  1599. PHP constants do not exist outside of PHP. For example, in httpd.conf
  1600. you can not use PHP constants such as E_ALL or E_NOTICE to set the
  1601. error_reporting directive as they will have no meaning and will
  1602. evaluate to 0. Use the associated bitmask values instead. These
  1603. constants can be used in php.ini
  1604. _________________________________________________________________
  1605.  
  1606. Changing PHP configuration via the Windows registry
  1607.  
  1608. When running PHP on Windows, the configuration values can be modified
  1609. on a per-directory basis using the Windows registry. The configuration
  1610. values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory
  1611. Values, in the sub-keys corresponding to the path names. For example,
  1612. configuration values for the directory c:\inetpub\wwwroot would be
  1613. stored in the key HKLM\SOFTWARE\PHP\Per Directory
  1614. Values\c\inetpub\wwwroot. The settings for the directory would be
  1615. active for any script running from this directory or any subdirectory
  1616. of it. The values under the key should have the name of the PHP
  1617. configuration directive and the string value. PHP constants in the
  1618. values are not parsed. However, only configuration values changeable
  1619. in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.
  1620. _________________________________________________________________
  1621.  
  1622. Other interfaces to PHP
  1623.  
  1624. Regardless of how you run PHP, you can change certain values at
  1625. runtime of your scripts through ini_set(). See the documentation on
  1626. the ini_set() page for more information.
  1627.  
  1628. If you are interested in a complete list of configuration settings on
  1629. your system with their current values, you can execute the phpinfo()
  1630. function, and review the resulting page. You can also access the
  1631. values of individual configuration directives at runtime using
  1632. ini_get() or get_cfg_var().
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement