install.txt 82 KB

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