You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2053 lines
86 KiB

22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
21 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
21 years ago
21 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
27 years ago
27 years ago
22 years ago
27 years ago
22 years ago
27 years ago
22 years ago
27 years ago
22 years ago
22 years ago
21 years ago
22 years ago
17 years ago
22 years ago
27 years ago
27 years ago
22 years ago
27 years ago
22 years ago
22 years ago
27 years ago
22 years ago
27 years ago
22 years ago
27 years ago
22 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
17 years ago
22 years ago
17 years ago
17 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
17 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
17 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
  1. Installing PHP
  2. __________________________________________________________________
  3. Table of Contents
  4. Preface
  5. 1. General Installation Considerations
  6. 2. Installation on Unix systems
  7. Apache 1.3.x on Unix systems
  8. Apache 2.0 on Unix systems
  9. Caudium
  10. fhttpd related notes
  11. Sun, iPlanet and Netscape servers on Sun Solaris
  12. CGI and command line setups
  13. HP-UX specific installation notes
  14. OpenBSD installation notes
  15. Solaris specific installation tips
  16. Debian GNU/Linux installation notes
  17. 3. Installation on Mac OS X
  18. Using Packages
  19. Using the bundled PHP
  20. Compiling for OS X Server
  21. Compiling for MacOS X Client
  22. 4. Installation of PECL extensions
  23. Introduction to PECL Installations
  24. Downloading PECL extensions
  25. PECL for Windows users
  26. Compiling shared PECL extensions with the pecl command
  27. Compiling shared PECL extensions with phpize
  28. Compiling PECL extensions statically into PHP
  29. 5. Problems?
  30. Read the FAQ
  31. Other problems
  32. Bug reports
  33. 6. Runtime Configuration
  34. The configuration file
  35. How to change configuration settings
  36. 7. Installation FAQ
  37. __________________________________________________________________
  38. Preface
  39. These installation instructions were generated from the HTML version of
  40. the PHP Manual so formatting and linking have been altered. See the
  41. online and updated version at: http://php.net/install.unix
  42. __________________________________________________________________
  43. Chapter 1. General Installation Considerations
  44. Before starting the installation, first you need to know what do you
  45. want to use PHP for. There are three main fields you can use PHP, as
  46. described in the What can PHP do? section:
  47. * Websites and web applications (server-side scripting)
  48. * Command line scripting
  49. * Desktop (GUI) applications
  50. For the first and most common form, you need three things: PHP itself,
  51. a web server and a web browser. You probably already have a web
  52. browser, and depending on your operating system setup, you may also
  53. have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows).
  54. You may also rent webspace at a company. This way, you don't need to
  55. set up anything on your own, only write your PHP scripts, upload it to
  56. the server you rent, and see the results in your browser.
  57. In case of setting up the server and PHP on your own, you have two
  58. choices for the method of connecting PHP to the server. For many
  59. servers PHP has a direct module interface (also called SAPI). These
  60. servers include Apache, Microsoft Internet Information Server, Netscape
  61. and iPlanet servers. Many other servers have support for ISAPI, the
  62. Microsoft module interface (OmniHTTPd for example). If PHP has no
  63. module support for your web server, you can always use it as a CGI or
  64. FastCGI processor. This means you set up your server to use the CGI
  65. executable of PHP to process all PHP file requests on the server.
  66. If you are also interested to use PHP for command line scripting (e.g.
  67. write scripts autogenerating some images for you offline, or processing
  68. text files depending on some arguments you pass to them), you always
  69. need the command line executable. For more information, read the
  70. section about writing command line PHP applications. In this case, you
  71. need no server and no browser.
  72. With PHP you can also write desktop GUI applications using the PHP-GTK
  73. extension. This is a completely different approach than writing web
  74. pages, as you do not output any HTML, but manage Windows and objects
  75. within them. For more information about PHP-GTK, please visit the site
  76. dedicated to this extension. PHP-GTK is not included in the official
  77. PHP distribution.
  78. From now on, this section deals with setting up PHP for web servers on
  79. Unix and Windows with server module interfaces and CGI executables. You
  80. will also find information on the command line executable in the
  81. following sections.
  82. PHP source code and binary distributions for Windows can be found at
  83. http://www.php.net/downloads.php. We recommend you to choose a mirror
  84. nearest to you for downloading the distributions.
  85. __________________________________________________________________
  86. Chapter 2. Installation on Unix systems
  87. This section will guide you through the general configuration and
  88. installation of PHP on Unix systems. Be sure to investigate any
  89. sections specific to your platform or web server before you begin the
  90. process.
  91. As our manual outlines in the General Installation Considerations
  92. section, we are mainly dealing with web centric setups of PHP in this
  93. section, although we will cover setting up PHP for command line usage
  94. as well.
  95. There are several ways to install PHP for the Unix platform, either
  96. with a compile and configure process, or through various pre-packaged
  97. methods. This documentation is mainly focused around the process of
  98. compiling and configuring PHP. Many Unix like systems have some sort of
  99. package installation system. This can assist in setting up a standard
  100. configuration, but if you need to have a different set of features
  101. (such as a secure server, or a different database driver), you may need
  102. to build PHP and/or your web server. If you are unfamiliar with
  103. building and compiling your own software, it is worth checking to see
  104. whether somebody has already built a packaged version of PHP with the
  105. features you need.
  106. Prerequisite knowledge and software for compiling:
  107. * Basic Unix skills (being able to operate "make" and a C compiler)
  108. * An ANSI C compiler
  109. * flex: Version 2.5.4
  110. * bison: Version 1.28 (preferred), 1.35, or 1.75
  111. * A web server
  112. * Any module specific components (such as gd, pdf libs, etc.)
  113. The initial PHP setup and configuration process is controlled by the
  114. use of the command line options of the configure script. You could get
  115. a list of all available options along with short explanations running
  116. ./configure --help. Our manual documents the different options
  117. separately. You will find the core options in the appendix, while the
  118. different extension specific options are descibed on the reference
  119. pages.
  120. When PHP is configured, you are ready to build the module and/or
  121. executables. The command make should take care of this. If it fails and
  122. you can't figure out why, see the Problems section.
  123. __________________________________________________________________
  124. Apache 1.3.x on Unix systems
  125. This section contains notes and hints specific to Apache installs of
  126. PHP on Unix platforms. We also have instructions and notes for Apache 2
  127. on a separate page.
  128. You can select arguments to add to the configure on line 10 below from
  129. the list of core configure options and from extension specific options
  130. described at the respective places in the manual. The version numbers
  131. have been omitted here, to ensure the instructions are not incorrect.
  132. You will need to replace the 'xxx' here with the correct values from
  133. your files.
  134. Example 2-1. Installation Instructions (Apache Shared Module Version)
  135. for PHP
  136. 1. gunzip apache_xxx.tar.gz
  137. 2. tar -xvf apache_xxx.tar
  138. 3. gunzip php-xxx.tar.gz
  139. 4. tar -xvf php-xxx.tar
  140. 5. cd apache_xxx
  141. 6. ./configure --prefix=/www --enable-module=so
  142. 7. make
  143. 8. make install
  144. 9. cd ../php-xxx
  145. 10. Now, configure your PHP. This is where you customize your PHP
  146. with various options, like which extensions will be enabled. Do a
  147. ./configure --help for a list of available options. In our example
  148. we'll do a simple configure with Apache 1 and MySQL support. Your
  149. path to apxs may differ from our example.
  150. ./configure --with-mysql --with-apxs=/www/bin/apxs
  151. 11. make
  152. 12. make install
  153. If you decide to change your configure options after installation,
  154. you only need to repeat the last three steps. You only need to
  155. restart apache for the new module to take effect. A recompile of
  156. Apache is not needed.
  157. Note that unless told otherwise, 'make install' will also install PEAR,
  158. various PHP tools such as phpize, install the PHP CLI, and more.
  159. 13. Setup your php.ini file:
  160. PHP will use the built-in default values if no php.ini file was
  161. placed in the configuration directory. The default location is
  162. /usr/local/lib, if you prefer your php.ini in another location, use
  163. --with-config-file-path=/some/path in step 10.
  164. The PHP distribution provides two sample php.ini files, you can use them
  165. by
  166. cp php.ini-development /usr/local/lib/php.ini
  167. or
  168. cp php.ini-production /usr/local/lib/php.ini
  169. If you choose one of these php.ini files be certain to read the list
  170. of changes within, as they affect how PHP behaves.
  171. 14. Edit your httpd.conf to load the PHP module. The path on the right hand
  172. side of the LoadModule statement must point to the path of the PHP
  173. module on your system. The make install from above may have already
  174. added this for you, but be sure to check.
  175. For PHP 4:
  176. LoadModule php4_module libexec/libphp4.so
  177. For PHP 5:
  178. LoadModule php5_module libexec/libphp5.so
  179. 15. And in the AddModule section of httpd.conf, somewhere under the
  180. ClearModuleList, add this:
  181. For PHP 4:
  182. AddModule mod_php4.c
  183. For PHP 5:
  184. AddModule mod_php5.c
  185. 16. Tell Apache to parse certain extensions as PHP. For example,
  186. let's have Apache parse the .php extension as PHP. You could
  187. have any extension(s) parse as PHP by simply adding more, with
  188. each separated by a space. We'll add .phtml to demonstrate.
  189. AddType application/x-httpd-php .php .phtml
  190. It's also common to setup the .phps extension to show highlighted PHP
  191. source, this can be done with:
  192. AddType application/x-httpd-php-source .phps
  193. 17. Use your normal procedure for starting the Apache server. (You must
  194. stop and restart the server, not just cause the server to reload by
  195. using a HUP or USR1 signal.)
  196. Alternatively, to install PHP as a static object:
  197. Example 2-2. Installation Instructions (Static Module Installation for
  198. Apache) for PHP
  199. 1. gunzip -c apache_1.3.x.tar.gz | tar xf -
  200. 2. cd apache_1.3.x
  201. 3. ./configure
  202. 4. cd ..
  203. 5. gunzip -c php-5.x.y.tar.gz | tar xf -
  204. 6. cd php-5.x.y
  205. 7. ./configure --with-mysql --with-apache=../apache_1.3.x
  206. 8. make
  207. 9. make install
  208. 10. cd ../apache_1.3.x
  209. 11. ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a
  210. (The above line is correct! Yes, we know libphp5.a does not exist at this
  211. stage. It isn't supposed to. It will be created.)
  212. 12. make
  213. (you should now have an httpd binary which you can copy to your Apache bin d
  214. ir if
  215. it is your first install then you need to "make install" as well)
  216. 13. cd ../php-5.x.y
  217. 14. cp php.ini-dist /usr/local/lib/php.ini
  218. 15. You can edit /usr/local/lib/php.ini file to set PHP options.
  219. Edit your httpd.conf or srm.conf file and add:
  220. AddType application/x-httpd-php .php
  221. Note: Replace php-5 by php-4 and php5 by php4 in PHP 4.
  222. Depending on your Apache install and Unix variant, there are many
  223. possible ways to stop and restart the server. Below are some typical
  224. lines used in restarting the server, for different apache/unix
  225. installations. You should replace /path/to/ with the path to these
  226. applications on your systems.
  227. Example 2-3. Example commands for restarting Apache
  228. 1. Several Linux and SysV variants:
  229. /etc/rc.d/init.d/httpd restart
  230. 2. Using apachectl scripts:
  231. /path/to/apachectl stop
  232. /path/to/apachectl start
  233. 3. httpdctl and httpsdctl (Using OpenSSL), similar to apachectl:
  234. /path/to/httpsdctl stop
  235. /path/to/httpsdctl start
  236. 4. Using mod_ssl, or another SSL server, you may want to manually
  237. stop and start:
  238. /path/to/apachectl stop
  239. /path/to/apachectl startssl
  240. The locations of the apachectl and http(s)dctl binaries often vary. If
  241. your system has locate or whereis or which commands, these can assist
  242. you in finding your server control programs.
  243. Different examples of compiling PHP for apache are as follows:
  244. ./configure --with-apxs --with-pgsql
  245. This will create a libphp5.so (or libphp4.so in PHP 4) shared library
  246. that is loaded into Apache using a LoadModule line in Apache's
  247. httpd.conf file. The PostgreSQL support is embedded into this library.
  248. ./configure --with-apxs --with-pgsql=shared
  249. This will create a libphp4.so shared library for Apache, but it will
  250. also create a pgsql.so shared library that is loaded into PHP either by
  251. using the extension directive in php.ini file or by loading it
  252. explicitly in a script using the dl() function.
  253. ./configure --with-apache=/path/to/apache_source --with-pgsql
  254. This will create a libmodphp5.a library, a mod_php5.c and some
  255. accompanying files and copy this into the src/modules/php5 directory in
  256. the Apache source tree. Then you compile Apache using
  257. --activate-module=src/modules/php5/libphp5.a and the Apache build
  258. system will create libphp5.a and link it statically into the httpd
  259. binary (replace php5 by php4 in PHP 4). The PostgreSQL support is
  260. included directly into this httpd binary, so the final result here is a
  261. single httpd binary that includes all of Apache and all of PHP.
  262. ./configure --with-apache=/path/to/apache_source --with-pgsql=shared
  263. Same as before, except instead of including PostgreSQL support directly
  264. into the final httpd you will get a pgsql.so shared library that you
  265. can load into PHP from either the php.ini file or directly using dl().
  266. When choosing to build PHP in different ways, you should consider the
  267. advantages and drawbacks of each method. Building as a shared object
  268. will mean that you can compile apache separately, and don't have to
  269. recompile everything as you add to, or change, PHP. Building PHP into
  270. apache (static method) means that PHP will load and run faster. For
  271. more information, see the Apache web page on DSO support.
  272. Note: Apache's default httpd.conf currently ships with a section
  273. that looks like this:
  274. User nobody
  275. Group "#-1"
  276. Unless you change that to "Group nogroup" or something like that
  277. ("Group daemon" is also very common) PHP will not be able to open
  278. files.
  279. Note: Make sure you specify the installed version of apxs when using
  280. --with-apxs=/path/to/apxs. You must NOT use the apxs version that is
  281. in the apache sources but the one that is actually installed on your
  282. system.
  283. __________________________________________________________________
  284. Apache 2.0 on Unix systems
  285. This section contains notes and hints specific to Apache 2.0 installs
  286. of PHP on Unix systems.
  287. Warning
  288. We do not recommend using a threaded MPM in production with Apache2.
  289. Use the prefork MPM instead, or use Apache1. For information on why,
  290. read the related FAQ entry on using Apache2 with a threaded MPM
  291. You are highly encouraged to take a look at the Apache Documentation to
  292. get a basic understanding of the Apache 2.0 Server.
  293. PHP and Apache 2.0.x compatibility notes: The following versions of
  294. PHP are known to work with the most recent version of Apache 2.0.x:
  295. * PHP 4.3.0 or later available at http://www.php.net/downloads.php.
  296. * the latest stable development version. Get the source code
  297. http://snaps.php.net/php5-latest.tar.gz or download binaries for
  298. Windows http://snaps.php.net/win32/php5-win32-latest.zip.
  299. * a prerelease version downloadable from http://qa.php.net/.
  300. * you have always the option to obtain PHP through SVN.
  301. These versions of PHP are compatible to Apache 2.0.40 and later.
  302. Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works with
  303. Apache 2.0.39, don't use any other version of Apache with PHP 4.2.3.
  304. However, the recommended setup is to use PHP 4.3.0 or later with the
  305. most recent version of Apache2.
  306. All mentioned versions of PHP will work still with Apache 1.3.x.
  307. Download the most recent version of Apache 2.0 and a fitting PHP
  308. version from the above mentioned places. This quick guide covers only
  309. the basics to get started with Apache 2.0 and PHP. For more information
  310. read the Apache Documentation. The version numbers have been omitted
  311. here, to ensure the instructions are not incorrect. You will need to
  312. replace the 'NN' here with the correct values from your files.
  313. Example 2-4. Installation Instructions (Apache 2 Shared Module Version)
  314. 1. gzip -d httpd-2_0_NN.tar.gz
  315. 2. tar xvf httpd-2_0_NN.tar
  316. 3. gunzip php-NN.tar.gz
  317. 4. tar -xvf php-NN.tar
  318. 5. cd httpd-2_0_NN
  319. 6. ./configure --enable-so
  320. 7. make
  321. 8. make install
  322. Now you have Apache 2.0.NN available under /usr/local/apache2,
  323. configured with loadable module support and the standard MPM prefork.
  324. To test the installation use your normal procedure for starting
  325. the Apache server, e.g.:
  326. /usr/local/apache2/bin/apachectl start
  327. and stop the server to go on with the configuration for PHP:
  328. /usr/local/apache2/bin/apachectl stop.
  329. 9. cd ../php-NN
  330. 10. Now, configure your PHP. This is where you customize your PHP
  331. with various options, like which extensions will be enabled. Do a
  332. ./configure --help for a list of available options. In our example
  333. we'll do a simple configure with Apache 2 and MySQL support. Your
  334. path to apxs may differ, in fact, the binary may even be named apxs2 on
  335. your system.
  336. ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
  337. 11. make
  338. 12. make install
  339. If you decide to change your configure options after installation,
  340. you only need to repeat the last three steps. You only need to
  341. restart apache for the new module to take effect. A recompile of
  342. Apache is not needed.
  343. Note that unless told otherwise, 'make install' will also install PEAR,
  344. various PHP tools such as phpize, install the PHP CLI, and more.
  345. 13. Setup your php.ini
  346. cp php.ini-dist /usr/local/lib/php.ini
  347. You may edit your .ini file to set PHP options. If you prefer having
  348. php.ini in another location, use --with-config-file-path=/some/path in
  349. step 10.
  350. If you instead choose php.ini-recommended, be certain to read the list
  351. of changes within, as they affect how PHP behaves.
  352. 14. Edit your httpd.conf to load the PHP module. The path on the right hand
  353. side of the LoadModule statement must point to the path of the PHP
  354. module on your system. The make install from above may have already
  355. added this for you, but be sure to check.
  356. For PHP 4:
  357. LoadModule php4_module modules/libphp4.so
  358. For PHP 5:
  359. LoadModule php5_module modules/libphp5.so
  360. 15. Tell Apache to parse certain extensions as PHP. For example,
  361. let's have Apache parse the .php extension as PHP. You could
  362. have any extension(s) parse as PHP by simply adding more, with
  363. each separated by a space. We'll add .phtml to demonstrate.
  364. AddType application/x-httpd-php .php .phtml
  365. It's also common to setup the .phps extension to show highlighted PHP
  366. source, this can be done with:
  367. AddType application/x-httpd-php-source .phps
  368. 16. Use your normal procedure for starting the Apache server, e.g.:
  369. /usr/local/apache2/bin/apachectl start
  370. Following the steps above you will have a running Apache 2.0 with
  371. support for PHP as SAPI module. Of course there are many more
  372. configuration options available for both, Apache and PHP. For more
  373. information use ./configure --help in the corresponding source tree. In
  374. case you wish to build a multithreaded version of Apache 2.0 you must
  375. overwrite the standard MPM-Module prefork either with worker or
  376. perchild. To do so append to your configure line in step 6 above either
  377. the option --with-mpm=worker or --with-mpm=perchild. Take care about
  378. the consequences and understand what you are doing. For more
  379. information read the Apache documentation about the MPM-Modules.
  380. Note: If you want to use content negotiation, read the Apache
  381. MultiViews FAQ.
  382. Note: To build a multithreaded version of Apache your system must
  383. support threads. This also implies to build PHP with experimental
  384. Zend Thread Safety (ZTS). Therefore not all extensions might be
  385. available. The recommended setup is to build Apache with the
  386. standard prefork MPM-Module.
  387. __________________________________________________________________
  388. Caudium
  389. PHP 4 can be built as a Pike module for the Caudium webserver. Note
  390. that this is not supported with PHP 3. Follow the simple instructions
  391. below to install PHP 4 for Caudium.
  392. Example 2-5. Caudium Installation Instructions
  393. 1. Make sure you have Caudium installed prior to attempting to
  394. install PHP 4. For PHP 4 to work correctly, you will need Pike
  395. 7.0.268 or newer. For the sake of this example we assume that
  396. Caudium is installed in /opt/caudium/server/.
  397. 2. Change directory to php-x.y.z (where x.y.z is the version number).
  398. 3. ./configure --with-caudium=/opt/caudium/server
  399. 4. make
  400. 5. make install
  401. 6. Restart Caudium if it's currently running.
  402. 7. Log into the graphical configuration interface and go to the
  403. virtual server where you want to add PHP 4 support.
  404. 8. Click Add Module and locate and then add the PHP 4 Script Support module.
  405. 9. If the documentation says that the 'PHP 4 interpreter isn't
  406. available', make sure that you restarted the server. If you did
  407. check /opt/caudium/logs/debug/default.1 for any errors related to
  408. <filename>PHP4.so</filename>. Also make sure that
  409. <filename>caudium/server/lib/[pike-version]/PHP4.so</filename>
  410. is present.
  411. 10. Configure the PHP Script Support module if needed.
  412. You can of course compile your Caudium module with support for the
  413. various extensions available in PHP 4. See the reference pages for
  414. extension specific configure options.
  415. Note: When compiling PHP 4 with MySQL support you must make sure
  416. that the normal MySQL client code is used. Otherwise there might be
  417. conflicts if your Pike already has MySQL support. You do this by
  418. specifying a MySQL install directory the --with-mysql option.
  419. __________________________________________________________________
  420. fhttpd related notes
  421. To build PHP as an fhttpd module, answer "yes" to "Build as an fhttpd
  422. module?" (the --with-fhttpd=DIR option to configure) and specify the
  423. fhttpd source base directory. The default directory is
  424. /usr/local/src/fhttpd. If you are running fhttpd, building PHP as a
  425. module will give better performance, more control and remote execution
  426. capability.
  427. Note: Support for fhttpd is no longer available as of PHP 4.3.0.
  428. __________________________________________________________________
  429. Sun, iPlanet and Netscape servers on Sun Solaris
  430. This section contains notes and hints specific to Sun Java System Web
  431. Server, Sun ONE Web Server, iPlanet and Netscape server installs of PHP
  432. on Sun Solaris.
  433. From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to
  434. generate custom directory listings and error pages. Additional
  435. functions for Apache compatibility are also available. For support in
  436. current web servers read the note about subrequests.
  437. You can find more information about setting up PHP for the Netscape
  438. Enterprise Server (NES) here:
  439. http://benoit.noss.free.fr/php/install-php4.html
  440. To build PHP with Sun JSWS/Sun ONE WS/iPlanet/Netscape web servers,
  441. enter the proper install directory for the --with-nsapi=[DIR] option.
  442. The default directory is usually /opt/netscape/suitespot/. Please also
  443. read /php-xxx-version/sapi/nsapi/nsapi-readme.txt.
  444. 1. Install the following packages from http://www.sunfreeware.com/ or
  445. another download site:
  446. autoconf-2.13
  447. automake-1.4
  448. bison-1_25-sol26-sparc-local
  449. flex-2_5_4a-sol26-sparc-local
  450. gcc-2_95_2-sol26-sparc-local
  451. gzip-1.2.4-sol26-sparc-local
  452. m4-1_4-sol26-sparc-local
  453. make-3_76_1-sol26-sparc-local
  454. mysql-3.23.24-beta (if you want mysql support)
  455. perl-5_005_03-sol26-sparc-local
  456. tar-1.13 (GNU tar)
  457. 2. Make sure your path includes the proper directories
  458. PATH=.:/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin and make it
  459. available to your system export PATH.
  460. 3. gunzip php-x.x.x.tar.gz (if you have a .gz dist, otherwise go to
  461. 4).
  462. 4. tar xvf php-x.x.x.tar
  463. 5. Change to your extracted PHP directory: cd ../php-x.x.x
  464. 6. For the following step, make sure /opt/netscape/suitespot/ is where
  465. your netscape server is installed. Otherwise, change to the correct
  466. path and run:
  467. ./configure --with-mysql=/usr/local/mysql \
  468. --with-nsapi=/opt/netscape/suitespot/ \
  469. --enable-libgcc
  470. 7. Run make followed by make install.
  471. After performing the base install and reading the appropriate readme
  472. file, you may need to perform some additional configuration steps.
  473. Configuration Instructions for Sun/iPlanet/Netscape. Firstly you may
  474. need to add some paths to the LD_LIBRARY_PATH environment for the
  475. server to find all the shared libs. This can best done in the start
  476. script for your web server. The start script is often located in:
  477. /path/to/server/https-servername/start. You may also need to edit the
  478. configuration files that are located in:
  479. /path/to/server/https-servername/config/.
  480. 1. Add the following line to mime.types (you can do that by the
  481. administration server):
  482. type=magnus-internal/x-httpd-php exts=php
  483. 2. Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6)
  484. and add the following, shlib will vary depending on your system, it
  485. will be something like /opt/netscape/suitespot/bin/libphp4.so. You
  486. should place the following lines after mime types init.
  487. Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="/op
  488. t/netscape/suitespot/bin/libphp4.so"
  489. Init fn="php4_init" LateInit="yes" errorString="Failed to initialize PHP!" [php_
  490. ini="/path/to/php.ini"]
  491. (PHP >= 4.3.3) The php_ini parameter is optional but with it you
  492. can place your php.ini in your web server config directory.
  493. 3. Configure the default object in obj.conf (for virtual server
  494. classes [version 6.0+] in their vserver.obj.conf):
  495. <Object name="default">
  496. .
  497. .
  498. .
  499. .#NOTE this next line should happen after all 'ObjectType' and before all 'AddLo
  500. g' lines
  501. Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inike
  502. y=value ...]
  503. .
  504. .
  505. </Object>
  506. (PHP >= 4.3.3) As additional parameters you can add some special
  507. php.ini-values, for example you can set a
  508. docroot="/path/to/docroot" specific to the context php4_execute is
  509. called. For boolean ini-keys please use 0/1 as value, not
  510. "On","Off",... (this will not work correctly), e.g.
  511. zlib.output_compression=1 instead of zlib.output_compression="On"
  512. 4. This is only needed if you want to configure a directory that only
  513. consists of PHP scripts (same like a cgi-bin directory):
  514. <Object name="x-httpd-php">
  515. ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
  516. Service fn=php4_execute [inikey=value inikey=value ...]
  517. </Object>
  518. After that you can configure a directory in the Administration
  519. server and assign it the style x-httpd-php. All files in it will
  520. get executed as PHP. This is nice to hide PHP usage by renaming
  521. files to .html.
  522. 5. Setup of authentication: PHP authentication cannot be used with any
  523. other authentication. ALL AUTHENTICATION IS PASSED TO YOUR PHP
  524. SCRIPT. To configure PHP Authentication for the entire server, add
  525. the following line to your default object:
  526. <Object name="default">
  527. AuthTrans fn=php4_auth_trans
  528. .
  529. .
  530. .
  531. </Object>
  532. 6. To use PHP Authentication on a single directory, add the following:
  533. <Object ppath="d:\path\to\authenticated\dir\*">
  534. AuthTrans fn=php4_auth_trans
  535. </Object>
  536. Note: The stacksize that PHP uses depends on the configuration of
  537. the web server. If you get crashes with very large PHP scripts, it
  538. is recommended to raise it with the Admin Server (in the section
  539. "MAGNUS EDITOR").
  540. __________________________________________________________________
  541. CGI environment and recommended modifications in php.ini
  542. Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
  543. WS/iPlanet/Netscape is a multithreaded web server. Because of that all
  544. requests are running in the same process space (the space of the web
  545. server itself) and this space has only one environment. If you want to
  546. get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the correct
  547. way to try this in the old PHP 3.x way with getenv() or a similar way
  548. (register globals to environment, $_ENV). You would only get the
  549. environment of the running web server without any valid CGI variables!
  550. Note: Why are there (invalid) CGI variables in the environment?
  551. Answer: This is because you started the web server process from the
  552. admin server which runs the startup script of the web server, you
  553. wanted to start, as a CGI script (a CGI script inside of the admin
  554. server!). This is why the environment of the started web server has
  555. some CGI environment variables in it. You can test this by starting
  556. the web server not from the administration server. Use the command
  557. line as root user and start it manually - you will see there are no
  558. CGI-like environment variables.
  559. Simply change your scripts to get CGI variables in the correct way for
  560. PHP 4.x by using the superglobal $_SERVER. If you have older scripts
  561. which use $HTTP_HOST, etc., you should turn on register_globals in
  562. php.ini and change the variable order too (important: remove "E" from
  563. it, because you do not need the environment here):
  564. variables_order = "GPCS"
  565. register_globals = On
  566. __________________________________________________________________
  567. Special use for error pages or self-made directory listings (PHP >= 4.3.3)
  568. You can use PHP to generate the error pages for "404 Not Found" or
  569. similar. Add the following line to the object in obj.conf for every
  570. error page you want to overwrite:
  571. Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inik
  572. ey=value...]
  573. where XXX is the HTTP error code. Please delete any other Error
  574. directives which could interfere with yours. If you want to place a
  575. page for all errors that could exist, leave the code parameter out.
  576. Your script can get the HTTP status code with $_SERVER['ERROR_TYPE'].
  577. Another possibility is to generate self-made directory listings. Just
  578. create a PHP script which displays a directory listing and replace the
  579. corresponding default Service line for type="magnus-internal/directory"
  580. in obj.conf with the following:
  581. Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scri
  582. pt.php" [inikey=value inikey=value...]
  583. For both error and directory listing pages the original URI and
  584. translated URI are in the variables $_SERVER['PATH_INFO'] and
  585. $_SERVER['PATH_TRANSLATED'].
  586. __________________________________________________________________
  587. Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)
  588. The NSAPI module now supports the nsapi_virtual() function (alias:
  589. virtual()) to make subrequests on the web server and insert the result
  590. in the web page. This function uses some undocumented features from the
  591. NSAPI library. On Unix the module automatically looks for the needed
  592. functions and uses them if available. If not, nsapi_virtual() is
  593. disabled.
  594. Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!
  595. __________________________________________________________________
  596. CGI and command line setups
  597. The default is to build PHP as a CGI program. This creates a command
  598. line interpreter, which can be used for CGI processing, or for
  599. non-web-related PHP scripting. If you are running a web server PHP has
  600. module support for, you should generally go for that solution for
  601. performance reasons. However, the CGI version enables users to run
  602. different PHP-enabled pages under different user-ids.
  603. Warning
  604. By using the CGI setup, your server is open to several possible
  605. attacks. Please read our CGI security section to learn how to defend
  606. yourself from those attacks.
  607. As of PHP 4.3.0, some important additions have happened to PHP. A new
  608. SAPI named CLI also exists and it has the same name as the CGI binary.
  609. What is installed at {PREFIX}/bin/php depends on your configure line
  610. and this is described in detail in the manual section named Using PHP
  611. from the command line. For further details please read that section of
  612. the manual.
  613. __________________________________________________________________
  614. Testing
  615. If you have built PHP as a CGI program, you may test your build by
  616. typing make test. It is always a good idea to test your build. This way
  617. you may catch a problem with PHP on your platform early instead of
  618. having to struggle with it later.
  619. __________________________________________________________________
  620. Benchmarking
  621. If you have built PHP 3 as a CGI program, you may benchmark your build
  622. by typing make bench. Note that if safe mode is on by default, the
  623. benchmark may not be able to finish if it takes longer then the 30
  624. seconds allowed. This is because the set_time_limit() can not be used
  625. in safe mode. Use the max_execution_time configuration setting to
  626. control this time for your own scripts. make bench ignores the
  627. configuration file.
  628. Note: make bench is only available for PHP 3.
  629. __________________________________________________________________
  630. Using Variables
  631. Some server supplied environment variables are not defined in the
  632. current CGI/1.1 specification. Only the following variables are defined
  633. there: AUTH_TYPE, CONTENT_LENGTH, CONTENT_TYPE, GATEWAY_INTERFACE,
  634. PATH_INFO, PATH_TRANSLATED, QUERY_STRING, REMOTE_ADDR, REMOTE_HOST,
  635. REMOTE_IDENT, REMOTE_USER, REQUEST_METHOD, SCRIPT_NAME, SERVER_NAME,
  636. SERVER_PORT, SERVER_PROTOCOL, and SERVER_SOFTWARE. Everything else
  637. should be treated as 'vendor extensions'.
  638. __________________________________________________________________
  639. HP-UX specific installation notes
  640. This section contains notes and hints specific to installing PHP on
  641. HP-UX systems.
  642. There are two main options for installing PHP on HP-UX systems. Either
  643. compile it, or install a pre-compiled binary.
  644. Official pre-compiled packages are located here:
  645. http://software.hp.com/
  646. Until this manual section is rewritten, the documentation about
  647. compiling PHP (and related extensions) on HP-UX systems has been
  648. removed. For now, consider reading the following external resource:
  649. Building Apache and PHP on HP-UX 11.11
  650. __________________________________________________________________
  651. OpenBSD installation notes
  652. This section contains notes and hints specific to installing PHP on
  653. OpenBSD 3.6.
  654. __________________________________________________________________
  655. Using Binary Packages
  656. Using binary packages to install PHP on OpenBSD is the recommended and
  657. simplest method. The core package has been separated from the various
  658. modules, and each can be installed and removed independently from the
  659. others. The files you need can be found on your OpenBSD CD or on the
  660. FTP site.
  661. The main package you need to install is php4-core-4.3.8.tgz, which
  662. contains the basic engine (plus gettext and iconv). Next, take a look
  663. at the module packages, such as php4-mysql-4.3.8.tgz or
  664. php4-imap-4.3.8.tgz. You need to use the phpxs command to activate and
  665. deactivate these modules in your php.ini.
  666. Example 2-6. OpenBSD Package Install Example
  667. # pkg_add php4-core-4.3.8.tgz
  668. # /usr/local/sbin/phpxs -s
  669. # cp /usr/local/share/doc/php4/php.ini-recommended /var/www/conf/php.ini
  670. (add in mysql)
  671. # pkg_add php4-mysql-4.3.8.tgz
  672. # /usr/local/sbin/phpxs -a mysql
  673. (add in imap)
  674. # pkg_add php4-imap-4.3.8.tgz
  675. # /usr/local/sbin/phpxs -a imap
  676. (remove mysql as a test)
  677. # pkg_delete php4-mysql-4.3.8
  678. # /usr/local/sbin/phpxs -r mysql
  679. (install the PEAR libraries)
  680. # pkg_add php4-pear-4.3.8.tgz
  681. Read the packages(7) manual page for more information about binary
  682. packages on OpenBSD.
  683. __________________________________________________________________
  684. Using Ports
  685. You can also compile up PHP from source using the ports tree. However,
  686. this is only recommended for users familiar with OpenBSD. The PHP 4
  687. port is split into two sub-directories: core and extensions. The
  688. extensions directory generates sub-packages for all of the supported
  689. PHP modules. If you find you do not want to create some of these
  690. modules, use the no_* FLAVOR. For example, to skip building the imap
  691. module, set the FLAVOR to no_imap.
  692. __________________________________________________________________
  693. Common Problems
  694. * The default install of Apache runs inside a chroot(2) jail, which
  695. will restrict PHP scripts to accessing files under /var/www. You
  696. will therefore need to create a /var/www/tmp directory for PHP
  697. session files to be stored, or use an alternative session backend.
  698. In addition, database sockets need to be placed inside the jail or
  699. listen on the localhost interface. If you use network functions,
  700. some files from /etc such as /etc/resolv.conf and /etc/services
  701. will need to be moved into /var/www/etc. The OpenBSD PEAR package
  702. automatically installs into the correct chroot directories, so no
  703. special modification is needed there. More information on the
  704. OpenBSD Apache is available in the OpenBSD FAQ.
  705. * The OpenBSD 3.6 package for the gd extension requires XFree86 to be
  706. installed. If you do not wish to use some of the font features that
  707. require X11, install the php4-gd-4.3.8-no_x11.tgz package instead.
  708. __________________________________________________________________
  709. Older Releases
  710. Older releases of OpenBSD used the FLAVORS system to compile up a
  711. statically linked PHP. Since it is hard to generate binary packages
  712. using this method, it is now deprecated. You can still use the old
  713. stable ports trees if you wish, but they are unsupported by the OpenBSD
  714. team. If you have any comments about this, the current maintainer for
  715. the port is Anil Madhavapeddy (avsm at openbsd dot org).
  716. __________________________________________________________________
  717. Solaris specific installation tips
  718. This section contains notes and hints specific to installing PHP on
  719. Solaris systems.
  720. __________________________________________________________________
  721. Required software
  722. Solaris installs often lack C compilers and their related tools. Read
  723. this FAQ for information on why using GNU versions for some of these
  724. tools is necessary. The required software is as follows:
  725. * gcc (recommended, other C compilers may work)
  726. * make
  727. * flex
  728. * bison
  729. * m4
  730. * autoconf
  731. * automake
  732. * perl
  733. * gzip
  734. * tar
  735. * GNU sed
  736. In addition, you will need to install (and possibly compile) any
  737. additional software specific to your configuration, such as Oracle or
  738. MySQL.
  739. __________________________________________________________________
  740. Using Packages
  741. You can simplify the Solaris install process by using pkgadd to install
  742. most of your needed components.
  743. __________________________________________________________________
  744. Debian GNU/Linux installation notes
  745. This section contains notes and hints specific to installing PHP on
  746. Debian GNU/Linux.
  747. __________________________________________________________________
  748. Using APT
  749. While you can just download the PHP source and compile it yourself,
  750. using Debian's packaging system is the simplest and cleanest method of
  751. installing PHP. If you are not familiar with building software on
  752. Linux, this is the way to go.
  753. The first decision you need to make is whether you want to install
  754. Apache 1.3.x or Apache 2.x. The corresponding PHP packages are
  755. respectively named libapache-mod-php* and libapache2-mod-php*. The
  756. steps given below will use Apache 1.3.x. Please note that, as of this
  757. writing, there is no official Debian packages of PHP 5. Then the steps
  758. given below will install PHP 4.
  759. PHP is available in Debian as CGI or CLI flavour too, named
  760. respectively php4-cgi and php4-cli. If you need them, you'll just have
  761. to reproduce the following steps with the good package names. Another
  762. special package you'd want to install is php4-pear. It contains a
  763. minimal PEAR installation and the pear commandline utility.
  764. If you need more recent packages of PHP than the Debian's stable ones
  765. or if some PHP modules lacks the Debian official repository, perhaps
  766. you should take a look at http://www.apt-get.org/. One of the results
  767. found should be Dotdeb. This unofficial repository is maintained by
  768. Guillaume Plessis and contains Debian packages of the most recent
  769. versions of PHP 4 and PHP 5. To use it, just add the to following two
  770. lines to your /etc/apt/sources.lists and run apt-get update :
  771. Example 2-7. The two Dotdeb related lines
  772. deb http://packages.dotdeb.org stable all
  773. deb-src http://packages.dotdeb.org stable all
  774. The last thing to consider is whether your list of packages is up to
  775. date. If you have not updated it recently, you need to run apt-get
  776. update before anything else. This way, you will be using the most
  777. recent stable version of the Apache and PHP packages.
  778. Now that everything is in place, you can use the following example to
  779. install Apache and PHP:
  780. Example 2-8. Debian Install Example with Apache 1.3
  781. # apt-get install libapache-mod-php4
  782. APT will automatically install the PHP 4 module for Apache 1.3, and all
  783. its dependencies and then activate it. If you're not asked to restart
  784. Apache during the install process, you'll have to do it manually :
  785. Example 2-9. Stopping and starting Apache once PHP 4 is installed
  786. # /etc/init.d/apache stop
  787. # /etc/init.d/apache start
  788. __________________________________________________________________
  789. Better control on configuration
  790. In the last section, PHP was installed with only core modules. This may
  791. not be what you want and you will soon discover that you need more
  792. activated modules, like MySQL, cURL, GD, etc.
  793. When you compile PHP from source yourself, you need to activate modules
  794. via the configure command. With APT, you just have to install
  795. additional packages. They're all named 'php4-*' (or 'php5-*' if you
  796. installed PHP 5 from a third party repository).
  797. Example 2-10. Getting the list of PHP additional packages
  798. # dpkg -l 'php4-*'
  799. As you can see from the last output, there's a lot of PHP modules that
  800. you can install (excluding the php4-cgi, php4-cli or php4-pear special
  801. packages). Look at them closely and choose what you need. If you choose
  802. a module and you do not have the proper libraries, APT will
  803. automatically install all the dependencies for you.
  804. If you choose to add the MySQL, cURL and GD support to PHP the command
  805. will look something like this:
  806. Example 2-11. Install PHP with MySQL, cURL and GD
  807. # apt-get install php4-mysql php4-curl php4-gd
  808. APT will automatically add the appropriate lines to your different
  809. php.ini (/etc/php4/apache/php.ini, /etc/php4/cgi/php.ini, etc).
  810. Example 2-12. These lines activate MySQL, cURL and GD into PHP
  811. extension=mysql.so
  812. extension=curl.so
  813. extension=gd.so
  814. You'll only have to stop/start Apache as previously to activate the
  815. modules.
  816. __________________________________________________________________
  817. Common Problems
  818. * If you see the PHP source instead of the result the script should
  819. produce, APT has probably not included /etc/apache/conf.d/php4 in
  820. your Apache 1.3 configuration. Please ensure that the following
  821. line is present in your /etc/apache/httpd.conf file then stop/start
  822. Apache:
  823. Example 2-13. This line activates PHP 4 into Apache
  824. # Include /etc/apache/conf.d/
  825. * If you installed an additional module and if its functions are not
  826. available in your scripts, please ensure that the appropriate line
  827. is present in your php.ini, as seen before. APT may fail during the
  828. installation of the additional module, due to a confusing debconf
  829. configuration.
  830. __________________________________________________________________
  831. Chapter 3. Installation on Mac OS X
  832. This section contains notes and hints specific to installing PHP on Mac
  833. OS X. There are two slightly different versions of Mac OS X, Client and
  834. Server, our manual deals with installing PHP on both systems. Note that
  835. PHP is not available for MacOS 9 and earlier versions.
  836. __________________________________________________________________
  837. Using Packages
  838. There are a few pre-packaged and pre-compiled versions of PHP for Mac
  839. OS X. This can help in setting up a standard configuration, but if you
  840. need to have a different set of features (such as a secure server, or a
  841. different database driver), you may need to build PHP and/or your web
  842. server yourself. If you are unfamiliar with building and compiling your
  843. own software, it's worth checking whether somebody has already built a
  844. packaged version of PHP with the features you need.
  845. The following resources offer easy to install packages and precompiled
  846. binaries for PHP on Mac OS:
  847. * Darwin: http://darwinports.opendarwin.org/
  848. * Entropy: http://www.entropy.ch/software/macosx/php/
  849. * Fink: http://fink.sourceforge.net/
  850. __________________________________________________________________
  851. Using the bundled PHP
  852. PHP has come standard with Macs since OS X version 10.0.0. Enabling PHP
  853. with the default web server requires uncommenting a few lines in the
  854. Apache configuration file httpd.conf whereas the CGI and/or CLI are
  855. enabled by default (easily accessible via the Terminal program).
  856. Enabling PHP using the instructions below is meant for quickly setting
  857. up a local development environment. It's highly recommended to always
  858. upgrade PHP to the newest version. Like most live software, newer
  859. versions are created to fix bugs and add features and PHP being is no
  860. different. See the appropriate MAC OS X installation documentation for
  861. further details. The following instructions are geared towards a
  862. beginner with details provided for getting a default setup to work. All
  863. users are encouraged to compile, or install a new packaged version.
  864. The standard installation type is using mod_php, and enabling the
  865. bundled mod_php on Mac OS X for the Apache web server (the default web
  866. server, that is accessible via System Preferences) involves the
  867. following steps:
  868. 1. Locate and open the Apache configuration file. By default, the
  869. location is as follows: /etc/httpd/httpd.conf
  870. Using Finder or Spotlight to find this file may prove difficult as
  871. by default it's private and owned by the root user.
  872. Note: One way to open this is by using a Unix based text editor in
  873. the Terminal, for example nano, and because the file is owned by
  874. root we'll use the sudo command to open it (as root) so for example
  875. type the following into the Terminal Application (after, it will
  876. prompt for a password): sudo nano /etc/httpd/httpd.conf
  877. Noteworthy nano commands: ^w (search), ^o (save), and ^x (exit)
  878. where ^ represents the Ctrl key.
  879. 2. With a text editor, uncomment the lines (by removing the #) that
  880. look similar to the following (these two lines are often not
  881. together, locate them both in the file):
  882. # LoadModule php4_module libexec/httpd/libphp4.so
  883. # AddModule mod_php4.c
  884. Notice the location/path. When building PHP in the future, the
  885. above files should be replaced or commented out.
  886. 3. Be sure the desired extensions will parse as PHP (examples: .php
  887. .html and .inc)
  888. Due to the following statement already existing in httpd.conf (as
  889. of Mac Panther), once PHP is enabled the .php files will
  890. automatically parse as PHP.
  891. <IfModule mod_php4.c>
  892. # If php is turned on, we respect .php and .phps files.
  893. AddType application/x-httpd-php .php
  894. AddType application/x-httpd-php-source .phps
  895. # Since most users will want index.php to work we
  896. # also automatically enable index.php
  897. <IfModule mod_dir.c>
  898. DirectoryIndex index.html index.php
  899. </IfModule>
  900. </IfModule>
  901. 4. Be sure the DirectoryIndex loads the desired default index file
  902. This is also set in httpd.conf. Typically index.php and index.html
  903. are used. By default index.php is enabled because it's also in the
  904. PHP check shown above. Adjust accordingly.
  905. 5. Set the php.ini location or use the default
  906. A typical default location on Mac OS X is /usr/local/php/php.ini
  907. and a call to phpinfo() will reveal this information. If a php.ini
  908. is not used, PHP will use all default values. See also the related
  909. FAQ on finding php.ini.
  910. 6. Locate or set the DocumentRoot
  911. This is the root directory for all the web files. Files in this
  912. directory are served from the web server so the PHP files will
  913. parse as PHP before outputting them to the browser. A typical
  914. default path is /Library/WebServer/Documents but this can be set to
  915. anything in httpd.conf. Alternatively, the default DocumentRoot for
  916. individual users is /Users/yourusername/Sites
  917. 7. Create a phpinfo() file
  918. The phpinfo() function will display information about PHP. Consider
  919. creating a file in the DocumentRoot with the following PHP code:
  920. <?php phpinfo(); ?>
  921. 8. Restart Apache, and load the PHP file created above
  922. To restart, either execute sudo apachectl graceful in the shell or
  923. stop/start the "Personal Web Server" option in the OS X System
  924. Preferences. By default, loading local files in the browser will
  925. have an URL like so: http://localhost/info.php Or using the
  926. DocumentRoot in the user directory is another option and would end
  927. up looking like: http://localhost/~yourusername/info.php
  928. The CLI (or CGI in older versions) is appropriately named php and
  929. likely exists as /usr/bin/php. Open up the terminal, read the command
  930. line section of the PHP manual, and execute php -v to check the PHP
  931. version of this PHP binary. A call to phpinfo() will also reveal this
  932. information.
  933. __________________________________________________________________
  934. Compiling for OS X Server
  935. Mac OS X Server install.
  936. 1. Get the latest distributions of Apache and PHP.
  937. 2. Untar them, and run the configure program on Apache like so.
  938. ./configure --exec-prefix=/usr \
  939. --localstatedir=/var \
  940. --mandir=/usr/share/man \
  941. --libexecdir=/System/Library/Apache/Modules \
  942. --iconsdir=/System/Library/Apache/Icons \
  943. --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
  944. --enable-shared=max \
  945. --enable-module=most \
  946. --target=apache
  947. 3. If you want the compiler to do some optimization, you may also want
  948. to add this line:
  949. setenv OPTIM=-O2
  950. 4. Next, go to the PHP 4 source directory and configure it.
  951. ./configure --prefix=/usr \
  952. --sysconfdir=/etc \
  953. --localstatedir=/var \
  954. --mandir=/usr/share/man \
  955. --with-xml \
  956. --with-apache=/src/apache_1.3.12
  957. If you have any other additions (MySQL, GD, etc.), be sure to add
  958. them here. For the --with-apache string, put in the path to your
  959. apache source directory, for example /src/apache_1.3.12.
  960. 5. Type make and make install. This will add a directory to your
  961. Apache source directory under src/modules/php4.
  962. 6. Now, reconfigure Apache to build in PHP 4.
  963. ./configure --exec-prefix=/usr \
  964. --localstatedir=/var \
  965. --mandir=/usr/share/man \
  966. --libexecdir=/System/Library/Apache/Modules \
  967. --iconsdir=/System/Library/Apache/Icons \
  968. --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
  969. --enable-shared=max \
  970. --enable-module=most \
  971. --target=apache \
  972. --activate-module=src/modules/php4/libphp4.a
  973. You may get a message telling you that libmodphp4.a is out of date.
  974. If so, go to the src/modules/php4 directory inside your Apache
  975. source directory and run this command: ranlib libmodphp4.a. Then go
  976. back to the root of the Apache source directory and run the above
  977. configure command again. That'll bring the link table up to date.
  978. Run make and make install again.
  979. 7. Copy and rename the php.ini-dist file to your bin directory from
  980. your PHP 4 source directory: cp php.ini-dist /usr/local/bin/php.ini
  981. or (if your don't have a local directory) cp php.ini-dist
  982. /usr/bin/php.ini.
  983. __________________________________________________________________
  984. Compiling for MacOS X Client
  985. The following instructions will help you install a PHP module for the
  986. Apache web server included in MacOS X. This version includes support
  987. for the MySQL and PostgreSQL databases. These instructions are
  988. graciously provided by Marc Liyanage.
  989. Warning
  990. Be careful when you do this, you could screw up your Apache web server!
  991. Do this to install:
  992. 1. Open a terminal window.
  993. 2. Type wget
  994. http://www.diax.ch/users/liyanage/software/macosx/libphp4.so.gz,
  995. wait for the download to finish.
  996. 3. Type gunzip libphp4.so.gz.
  997. 4. Type sudo apxs -i -a -n php4 libphp4.so
  998. 5. Now type sudo open -a TextEdit /etc/httpd/httpd.conf. TextEdit will
  999. open with the web server configuration file. Locate these two lines
  1000. towards the end of the file: (Use the Find command)
  1001. #AddType application/x-httpd-php .php
  1002. #AddType application/x-httpd-php-source .phps
  1003. Remove the two hash marks (#), then save the file and quit
  1004. TextEdit.
  1005. 6. Finally, type sudo apachectl graceful to restart the web server.
  1006. PHP should now be up and running. You can test it by dropping a file
  1007. into your Sites folder which is called test.php. Into that file, write
  1008. this line: <?php phpinfo() ?>.
  1009. Now open up 127.0.0.1/~your_username/test.php in your web browser. You
  1010. should see a status table with information about the PHP module.
  1011. __________________________________________________________________
  1012. Chapter 4. Installation of PECL extensions
  1013. Introduction to PECL Installations
  1014. PECL is a repository of PHP extensions that are made available to you
  1015. via the PEAR packaging system. This section of the manual is intended
  1016. to demonstrate how to obtain and install PECL extensions.
  1017. These instructions assume /your/phpsrcdir/ is the path to the PHP
  1018. source distribution, and that extname is the name of the PECL
  1019. extension. Adjust accordingly. These instructions also assume a
  1020. familiarity with the pear command. The information in the PEAR manual
  1021. for the pear command also applies to the pecl command.
  1022. To be useful, a shared extension must be built, installed, and loaded.
  1023. The methods described below provide you with various instructions on
  1024. how to build and install the extensions, but they do not automatically
  1025. load them. Extensions can be loaded by adding an extension directive.
  1026. To this php.ini file, or through the use of the dl() function.
  1027. When building PHP modules, it's important to have known-good versions
  1028. of the required tools (autoconf, automake, libtool, etc.) See the
  1029. SVN Instructions for details on the required tools, and required
  1030. versions.
  1031. __________________________________________________________________
  1032. Downloading PECL extensions
  1033. There are several options for downloading PECL extensions, such as:
  1034. * http://pecl.php.net
  1035. The PECL web site contains information about the different
  1036. extensions that are offered by the PHP Development Team. The
  1037. information available here includes: ChangeLog, release notes,
  1038. requirements and other similar details.
  1039. * pecl download extname
  1040. PECL extensions that have releases listed on the PECL web site are
  1041. available for download and installation using the pecl command.
  1042. Specific revisions may also be specified.
  1043. * SVN
  1044. All PECL files reside in SVN. A web-based view may be seen at
  1045. http://svn.php.net/pecl/. To download straight from SVN, use:
  1046. $ svn co http://svn.php.net/repository/pecl/<extname>/trunk <extname>
  1047. * Windows downloads
  1048. Windows users may find compiled PECL binaries by downloading the
  1049. Collection of PECL modules from the PHP Downloads page, or by
  1050. retrieving a PECL Snapshot or an extension DLL on PECL4WIN. To
  1051. compile PHP under Windows, read the appropriate chapter.
  1052. __________________________________________________________________
  1053. PECL for Windows users
  1054. As with any other PHP extension DLL, installation is as simple as
  1055. copying the PECL extension DLLs into the extension_dir folder and
  1056. loading them from php.ini. For example, add the following line to your
  1057. php.ini:
  1058. extension=php_extname.dll
  1059. After doing this, restart the web server.
  1060. __________________________________________________________________
  1061. Compiling shared PECL extensions with the pecl command
  1062. PECL makes it easy to create shared PHP extensions. Using the pecl
  1063. command, do the following:
  1064. $ pecl install extname
  1065. This will download the source for extname, compile, and install
  1066. extname.so into your extension_dir. extname.so may then be loaded via
  1067. php.ini
  1068. By default, the pecl command will not install packages that are marked
  1069. with the alpha or beta state. If no stable packages are available, you
  1070. may install a beta package using the following command:
  1071. $ pecl install extname-beta
  1072. You may also install a specific version using this variant:
  1073. $ pecl install extname-0.1
  1074. __________________________________________________________________
  1075. Compiling shared PECL extensions with phpize
  1076. Sometimes, using the pecl installer is not an option. This could be
  1077. because you're behind a firewall, or it could be because the extension
  1078. you want to install is not available as a PECL compatible package, such
  1079. as unreleased extensions from SVN. If you need to build such an
  1080. extension, you can use the lower-level build tools to perform the build
  1081. manually.
  1082. The phpize command is used to prepare the build environment for a PHP
  1083. extension. In the following sample, the sources for an extension are in
  1084. a directory named extname:
  1085. $ cd extname
  1086. $ phpize
  1087. $ ./configure
  1088. $ make
  1089. # make install
  1090. A successful install will have created extname.so and put it into the
  1091. PHP extensions directory. You'll need to and adjust php.ini and add an
  1092. extension=extname.so line before you can use the extension.
  1093. If the system is missing the phpize command, and precompiled packages
  1094. (like RPM's) are used, be sure to also install the appropriate devel
  1095. version of the PHP package as they often include the phpize command
  1096. along with the appropriate header files to build PHP and its
  1097. extensions.
  1098. Execute phpize --help to display additional usage information.
  1099. __________________________________________________________________
  1100. Compiling PECL extensions statically into PHP
  1101. You might find that you need to build a PECL extension statically into
  1102. your PHP binary. To do this, you'll need to place the extension source
  1103. under the php-src/ext/ directory and tell the PHP build system to
  1104. regenerate its configure script.
  1105. $ cd /your/phpsrcdir/ext
  1106. $ pecl download extname
  1107. $ gzip -d < extname.tgz | tar -xvf -
  1108. $ mv extname-x.x.x extname
  1109. This will result in the following directory:
  1110. /your/phpsrcdir/ext/extname
  1111. From here, force PHP to rebuild the configure script, and then build
  1112. PHP as normal:
  1113. $ cd /your/phpsrcdir
  1114. $ rm configure
  1115. $ ./buildconf --force
  1116. $ ./configure --help
  1117. $ ./configure --with-extname --enable-someotherext --with-foobar
  1118. $ make
  1119. $ make install
  1120. Note: To run the 'buildconf' script you need autoconf 2.13 and
  1121. automake 1.4+ (newer versions of autoconf may work, but are not
  1122. supported).
  1123. Whether --enable-extname or --with-extname is used depends on the
  1124. extension. Typically an extension that does not require external
  1125. libraries uses --enable. To be sure, run the following after buildconf:
  1126. $ ./configure --help | grep extname
  1127. __________________________________________________________________
  1128. Chapter 5. Problems?
  1129. Read the FAQ
  1130. Some problems are more common than others. The most common ones are
  1131. listed in the PHP FAQ, part of this manual.
  1132. __________________________________________________________________
  1133. Other problems
  1134. If you are still stuck, someone on the PHP installation mailing list
  1135. may be able to help you. You should check out the archive first, in
  1136. case someone already answered someone else who had the same problem as
  1137. you. The archives are available from the support page on
  1138. http://www.php.net/support.php. To subscribe to the PHP installation
  1139. mailing list, send an empty mail to
  1140. php-install-subscribe@lists.php.net. The mailing list address is
  1141. php-install@lists.php.net.
  1142. If you want to get help on the mailing list, please try to be precise
  1143. and give the necessary details about your environment (which operating
  1144. system, what PHP version, what web server, if you are running PHP as
  1145. CGI or a server module, safe mode, etc...), and preferably enough code
  1146. to make others able to reproduce and test your problem.
  1147. __________________________________________________________________
  1148. Bug reports
  1149. If you think you have found a bug in PHP, please report it. The PHP
  1150. developers probably don't know about it, and unless you report it,
  1151. chances are it won't be fixed. You can report bugs using the
  1152. bug-tracking system at http://bugs.php.net/. Please do not send bug
  1153. reports in mailing list or personal letters. The bug system is also
  1154. suitable to submit feature requests.
  1155. Read the How to report a bug document before submitting any bug
  1156. reports!
  1157. __________________________________________________________________
  1158. Chapter 6. Runtime Configuration
  1159. The configuration file
  1160. The configuration file (called php3.ini in PHP 3, and simply php.ini as
  1161. of PHP 4) is read when PHP starts up. For the server module versions of
  1162. PHP, this happens only once when the web server is started. For the CGI
  1163. and CLI version, it happens on every invocation.
  1164. php.ini is searched in these locations (in order):
  1165. * SAPI module specific location (PHPIniDir directive in Apache 2, -c
  1166. command line option in CGI and CLI, php_ini parameter in NSAPI,
  1167. PHP_INI_PATH environment variable in THTTPD)
  1168. * The PHPRC environment variable. Before PHP 5.2.0 this was checked
  1169. after the registry key mentioned below.
  1170. * As of PHP 5.2.0, the following registry locations are searched in
  1171. order: HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z\IniFilePath,
  1172. HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y\IniFilePath and
  1173. HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x\IniFilePath, where x, y and z
  1174. mean the PHP major, minor and release versions.
  1175. * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry
  1176. location)
  1177. * Current working directory (except CLI)
  1178. * The web server's directory (for SAPI modules), or directory of PHP
  1179. (otherwise in Windows)
  1180. * Windows directory (C:\windows or C:\winnt) (for Windows), or
  1181. --with-config-file-path compile time option
  1182. If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
  1183. e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini. SAPI
  1184. name can be determined by php_sapi_name().
  1185. Note: The Apache web server changes the directory to root at startup
  1186. causing PHP to attempt to read php.ini from the root filesystem if
  1187. it exists.
  1188. The php.ini directives handled by extensions are documented
  1189. respectively on the pages of the extensions themselves. The list of the
  1190. core directives is available in the appendix. Probably not all PHP
  1191. directives are documented in the manual though. For a complete list of
  1192. directives available in your PHP version, please read your well
  1193. commented php.ini file. Alternatively, you may find the the latest
  1194. php.ini from SVN helpful too.
  1195. Example 6-1. php.ini example
  1196. ; any text on a line after an unquoted semicolon (;) is ignored
  1197. [php] ; section markers (text within square brackets) are also ignored
  1198. ; Boolean values can be set to either:
  1199. ; true, on, yes
  1200. ; or false, off, no, none
  1201. register_globals = off
  1202. track_errors = yes
  1203. ; you can enclose strings in double-quotes
  1204. include_path = ".:/usr/local/lib/php"
  1205. ; backslashes are treated the same as any other character
  1206. include_path = ".;c:\php\lib"
  1207. Since PHP 5.1.0, it is possible to refer to existing .ini variables
  1208. from within .ini files. Example: open_basedir = ${open_basedir}
  1209. ":/new/dir".
  1210. __________________________________________________________________
  1211. How to change configuration settings
  1212. Running PHP as an Apache module
  1213. When using PHP as an Apache module, you can also change the
  1214. configuration settings using directives in Apache configuration files
  1215. (e.g. httpd.conf) and .htaccess files. You will need "AllowOverride
  1216. Options" or "AllowOverride All" privileges to do so.
  1217. With PHP 4 and PHP 5, there are several Apache directives that allow
  1218. you to change the PHP configuration from within the Apache
  1219. configuration files. For a listing of which directives are PHP_INI_ALL,
  1220. PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the List of php.ini
  1221. directives appendix.
  1222. Note: With PHP 3, there are Apache directives that correspond to
  1223. each configuration setting in the php3.ini name, except the name is
  1224. prefixed by "php3_".
  1225. php_value name value
  1226. Sets the value of the specified directive. Can be used only with
  1227. PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a
  1228. previously set value use none as the value.
  1229. Note: Don't use php_value to set boolean values. php_flag (see
  1230. below) should be used instead.
  1231. php_flag name on|off
  1232. Used to set a boolean configuration directive. Can be used only
  1233. with PHP_INI_ALL and PHP_INI_PERDIR type directives.
  1234. php_admin_value name value
  1235. Sets the value of the specified directive. This can not be used
  1236. in .htaccess files. Any directive type set with php_admin_value
  1237. can not be overridden by .htaccess or virtualhost directives. To
  1238. clear a previously set value use none as the value.
  1239. php_admin_flag name on|off
  1240. Used to set a boolean configuration directive. This can not be
  1241. used in .htaccess files. Any directive type set with
  1242. php_admin_flag can not be overridden by .htaccess or virtualhost
  1243. directives.
  1244. Example 6-2. Apache configuration example
  1245. <IfModule mod_php5.c>
  1246. php_value include_path ".:/usr/local/lib/php"
  1247. php_admin_flag safe_mode on
  1248. </IfModule>
  1249. <IfModule mod_php4.c>
  1250. php_value include_path ".:/usr/local/lib/php"
  1251. php_admin_flag safe_mode on
  1252. </IfModule>
  1253. <IfModule mod_php3.c>
  1254. php3_include_path ".:/usr/local/lib/php"
  1255. php3_safe_mode on
  1256. </IfModule>
  1257. Caution
  1258. PHP constants do not exist outside of PHP. For example, in httpd.conf
  1259. you can not use PHP constants such as E_ALL or E_NOTICE to set the
  1260. error_reporting directive as they will have no meaning and will
  1261. evaluate to 0. Use the associated bitmask values instead. These
  1262. constants can be used in php.ini
  1263. __________________________________________________________________
  1264. Changing PHP configuration via the Windows registry
  1265. When running PHP on Windows, the configuration values can be modified
  1266. on a per-directory basis using the Windows registry. The configuration
  1267. values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory
  1268. Values, in the sub-keys corresponding to the path names. For example,
  1269. configuration values for the directory c:\inetpub\wwwroot would be
  1270. stored in the key HKLM\SOFTWARE\PHP\Per Directory
  1271. Values\c\inetpub\wwwroot. The settings for the directory would be
  1272. active for any script running from this directory or any subdirectory
  1273. of it. The values under the key should have the name of the PHP
  1274. configuration directive and the string value. PHP constants in the
  1275. values are not parsed. However, only configuration values changeable in
  1276. PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.
  1277. __________________________________________________________________
  1278. Other interfaces to PHP
  1279. Regardless of how you run PHP, you can change certain values at runtime
  1280. of your scripts through ini_set(). See the documentation on the
  1281. ini_set() page for more information.
  1282. If you are interested in a complete list of configuration settings on
  1283. your system with their current values, you can execute the phpinfo()
  1284. function, and review the resulting page. You can also access the values
  1285. of individual configuration directives at runtime using ini_get() or
  1286. get_cfg_var().
  1287. __________________________________________________________________
  1288. Chapter 7. Installation FAQ
  1289. This section holds common questions about the way to install PHP. PHP
  1290. is available for almost any OS (except maybe for MacOS before OSX), and
  1291. almost any web server.
  1292. To install PHP, follow the instructions in Installing PHP.
  1293. 1. Why shouldn't I use Apache2 with a threaded MPM in a production
  1294. environment?
  1295. 2. Unix/Windows: Where should my php.ini file be located?
  1296. 3. Unix: I installed PHP, but every time I load a document, I get the
  1297. message 'Document Contains No Data'! What's going on here?
  1298. 4. Unix: I installed PHP using RPMS, but Apache isn't processing the
  1299. PHP pages! What's going on here?
  1300. 5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the
  1301. database support I need! What's going on here?
  1302. 6. Unix: I patched Apache with the FrontPage extensions patch, and
  1303. suddenly PHP stopped working. Is PHP incompatible with the
  1304. Apache FrontPage extensions?
  1305. 7. Unix/Windows: I have installed PHP, but when I try to access a PHP
  1306. script file via my browser, I get a blank screen.
  1307. 8. Unix/Windows: I have installed PHP, but when try to access a PHP
  1308. script file via my browser, I get a server 500 error.
  1309. 9. Some operating systems: I have installed PHP without errors, but
  1310. when I try to start apache I get undefined symbol errors:
  1311. [mybox:user /src/php4] root# apachectl configtest
  1312. apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  1313. _compress
  1314. _uncompress
  1315. 10. Windows: I have installed PHP, but when I to access a PHP script
  1316. file via my browser, I get the error:
  1317. cgi error:
  1318. The specified CGI application misbehaved by not
  1319. returning a complete set of HTTP headers.
  1320. The headers it did return are:
  1321. 11. Windows: I've followed all the instructions, but still can't get
  1322. PHP and IIS to work together!
  1323. 12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get
  1324. the following error: Security Alert! PHP CGI cannot be accessed
  1325. directly..
  1326. 13. How do I know if my php.ini is being found and read? It seems like
  1327. it isn't as my changes aren't being implemented.
  1328. 14. How do I add my PHP directory to the PATH on Windows?
  1329. 15. How do I make the php.ini file available to PHP on windows?
  1330. 16. Is it possible to use Apache content negotiation (MultiViews
  1331. option) with PHP?
  1332. 17. Is PHP limited to process GET and POST request methods only?
  1333. 1. Why shouldn't I use Apache2 with a threaded MPM in a production
  1334. environment?
  1335. PHP is glue. It is the glue used to build cool web applications by
  1336. sticking dozens of 3rd-party libraries together and making it all
  1337. appear as one coherent entity through an intuitive and easy to learn
  1338. language interface. The flexibility and power of PHP relies on the
  1339. stability and robustness of the underlying platform. It needs a working
  1340. OS, a working web server and working 3rd-party libraries to glue
  1341. together. When any of these stop working PHP needs ways to identify the
  1342. problems and fix them quickly. When you make the underlying framework
  1343. more complex by not having completely separate execution threads,
  1344. completely separate memory segments and a strong sandbox for each
  1345. request to play in, feet of clay are introduced into PHP's system.
  1346. If you feel you have to use a threaded MPM, look at a FastCGI
  1347. configuration where PHP is running in its own memory space.
  1348. And finally, this warning against using a threaded MPM is not as strong
  1349. for Windows systems because most libraries on that platform tend to be
  1350. threadsafe.
  1351. 2. Unix/Windows: Where should my php.ini file be located?
  1352. By default on Unix it should be in /usr/local/lib which is
  1353. <install-path>/lib. Most people will want to change this at
  1354. compile-time with the --with-config-file-path flag. You would, for
  1355. example, set it with something like:
  1356. --with-config-file-path=/etc
  1357. And then you would copy php.ini-dist from the distribution to
  1358. /etc/php.ini and edit it to make any local changes you want.
  1359. --with-config-file-scan-dir=PATH
  1360. On Windows the default path for the php.ini file is the Windows
  1361. directory. If you're using the Apache webserver, php.ini is first
  1362. searched in the Apaches install directory, e.g. c:\program files\apache
  1363. group\apache. This way you can have different php.ini files for
  1364. different versions of Apache on the same machine.
  1365. See also the chapter about the configuration file.
  1366. 3. Unix: I installed PHP, but every time I load a document, I get the
  1367. message 'Document Contains No Data'! What's going on here?
  1368. This probably means that PHP is having some sort of problem and is
  1369. core-dumping. Look in your server error log to see if this is the case,
  1370. and then try to reproduce the problem with a small test case. If you
  1371. know how to use 'gdb', it is very helpful when you can provide a
  1372. backtrace with your bug report to help the developers pinpoint the
  1373. problem. If you are using PHP as an Apache module try something like:
  1374. * Stop your httpd processes
  1375. * gdb httpd
  1376. * Stop your httpd processes
  1377. * > run -X -f /path/to/httpd.conf
  1378. * Then fetch the URL causing the problem with your browser
  1379. * > run -X -f /path/to/httpd.conf
  1380. * If you are getting a core dump, gdb should inform you of this now
  1381. * type: bt
  1382. * You should include your backtrace in your bug report. This should
  1383. be submitted to http://bugs.php.net/
  1384. If your script uses the regular expression functions (ereg() and
  1385. friends), you should make sure that you compiled PHP and Apache with
  1386. the same regular expression package. This should happen automatically
  1387. with PHP and Apache 1.3.x
  1388. 4. Unix: I installed PHP using RPMS, but Apache isn't processing the
  1389. PHP pages! What's going on here?
  1390. Assuming you installed both Apache and PHP from RPM packages, you need
  1391. to uncomment or add some or all of the following lines in your
  1392. httpd.conf file:
  1393. # Extra Modules
  1394. AddModule mod_php.c
  1395. AddModule mod_php3.c
  1396. AddModule mod_perl.c
  1397. # Extra Modules
  1398. LoadModule php_module modules/mod_php.so
  1399. LoadModule php3_module modules/libphp3.so # for PHP 3
  1400. LoadModule php4_module modules/libphp4.so # for PHP 4
  1401. LoadModule perl_module modules/libperl.so
  1402. And add:
  1403. AddType application/x-httpd-php3 .php3 # for PHP 3
  1404. AddType application/x-httpd-php .php # for PHP 4
  1405. ... to the global properties, or to the properties of the VirtualDomain
  1406. you want to have PHP support added to.
  1407. 5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the
  1408. database support I need! What's going on here?
  1409. Due to the way PHP 3 built, it is not easy to build a complete flexible
  1410. PHP RPM. This issue is addressed in PHP 4. For PHP 3, we currently
  1411. suggest you use the mechanism described in the INSTALL.REDHAT file in
  1412. the PHP distribution. If you insist on using an RPM version of PHP 3,
  1413. read on...
  1414. The RPM packagers are setting up the RPMS to install without database
  1415. support to simplify installations and because RPMS use /usr/ instead of
  1416. the standard /usr/local/ directory for files. You need to tell the RPM
  1417. spec file which databases to support and the location of the top-level
  1418. of your database server.
  1419. This example will explain the process of adding support for the popular
  1420. MySQL database server, using the mod installation for Apache.
  1421. Of course all of this information can be adjusted for any database
  1422. server that PHP supports. We will assume you installed MySQL and Apache
  1423. completely with RPMS for this example as well.
  1424. * First remove mod_php3 :
  1425. rpm -e mod_php3
  1426. * Then get the source rpm and INSTALL it, NOT --rebuild
  1427. rpm -Uvh mod_php3-3.0.5-2.src.rpm
  1428. * Then edit the /usr/src/redhat/SPECS/mod_php3.spec file
  1429. In the %build section add the database support you want, and the
  1430. path.
  1431. For MySQL you would add --with-mysql=/usr The %build section will
  1432. look something like this:
  1433. ./configure --prefix=/usr \
  1434. --with-apxs=/usr/sbin/apxs \
  1435. --with-config-file-path=/usr/lib \
  1436. --enable-debug=no \
  1437. --enable-safe-mode \
  1438. --with-exec-dir=/usr/bin \
  1439. --with-mysql=/usr \
  1440. --with-system-regex
  1441. * Once this modification is made then build the binary rpm as
  1442. follows:
  1443. rpm -bb /usr/src/redhat/SPECS/mod_php3.spec
  1444. * Then install the rpm
  1445. rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm
  1446. Make sure you restart Apache, and you now have PHP 3 with MySQL support
  1447. using RPM's. Note that it is probably much easier to just build from
  1448. the distribution tarball of PHP 3 and follow the instructions in
  1449. INSTALL.REDHAT found in that distribution.
  1450. 6. Unix: I patched Apache with the FrontPage extensions patch, and
  1451. suddenly PHP stopped working. Is PHP incompatible with the Apache
  1452. FrontPage extensions?
  1453. No, PHP works fine with the FrontPage extensions. The problem is that
  1454. the FrontPage patch modifies several Apache structures, that PHP relies
  1455. on. Recompiling PHP (using 'make clean ; make') after the FP patch is
  1456. applied would solve the problem.
  1457. 7. Unix/Windows: I have installed PHP, but when I try to access a PHP
  1458. script file via my browser, I get a blank screen.
  1459. Do a 'view source' in the web browser and you will probably find that
  1460. you can see the source code of your PHP script. This means that the web
  1461. server did not send the script to PHP for interpretation. Something is
  1462. wrong with the server configuration - double check the server
  1463. configuration against the PHP installation instructions.
  1464. 8. Unix/Windows: I have installed PHP, but when try to access a PHP
  1465. script file via my browser, I get a server 500 error.
  1466. Something went wrong when the server tried to run PHP. To get to see a
  1467. sensible error message, from the command line, change to the directory
  1468. containing the PHP executable (php.exe on Windows) and run php -i. If
  1469. PHP has any problems running, then a suitable error message will be
  1470. displayed which will give you a clue as to what needs to be done next.
  1471. If you get a screen full of HTML codes (the output of the phpinfo()
  1472. function) then PHP is working, and your problem may be related to your
  1473. server configuration which you should double check.
  1474. 9. Some operating systems: I have installed PHP without errors, but
  1475. when I try to start apache I get undefined symbol errors:
  1476. [mybox:user /src/php4] root# apachectl configtest
  1477. apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  1478. _compress
  1479. _uncompress
  1480. This has actually nothing to do with PHP, but with the MySQL client
  1481. libraries. Some need --with-zlib, others do not. This is also covered
  1482. in the MySQL FAQ.
  1483. 10. Windows: I have installed PHP, but when I to access a PHP script
  1484. file via my browser, I get the error:
  1485. cgi error:
  1486. The specified CGI application misbehaved by not
  1487. returning a complete set of HTTP headers.
  1488. The headers it did return are:
  1489. This error message means that PHP failed to output anything at all. To
  1490. get to see a sensible error message, from the command line, change to
  1491. the directory containing the PHP executable (php.exe on Windows) and
  1492. run php -i. If PHP has any problems running, then a suitable error
  1493. message will be displayed which will give you a clue as to what needs
  1494. to be done next. If you get a screen full of HTML codes (the output of
  1495. the phpinfo() function) then PHP is working.
  1496. Once PHP is working at the command line, try accessing the script via
  1497. the browser again. If it still fails then it could be one of the
  1498. following:
  1499. * File permissions on your PHP script, php.exe, php4ts.dll, php.ini
  1500. or any PHP extensions you are trying to load are such that the
  1501. anonymous internet user ISUR_<machinename> cannot access them.
  1502. * The script file does not exist (or possibly isn't where you think
  1503. it is relative to your web root directory). Note that for IIS you
  1504. can trap this error by ticking the 'check file exists' box when
  1505. setting up the script mappings in the Internet Services Manager. If
  1506. a script file does not exist then the server will return a 404
  1507. error instead. There is also the additional benefit that IIS will
  1508. do any authentication required for you based on the NTLanMan
  1509. permissions on your script file.
  1510. 11. Windows: I've followed all the instructions, but still can't get
  1511. PHP and IIS to work together!
  1512. Make sure any user who needs to run a PHP script has the rights to run
  1513. php.exe! IIS uses an anonymous user which is added at the time IIS is
  1514. installed. This user needs rights to php.exe. Also, any authenticated
  1515. user will also need rights to execute php.exe. And for IIS4 you need to
  1516. tell it that PHP is a script engine. Also, you will want to read this
  1517. faq.
  1518. 12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get
  1519. the following error: Security Alert! PHP CGI cannot be accessed
  1520. directly..
  1521. You must set the cgi.force_redirect directive to 0. It defaults to 1 so
  1522. be sure the directive isn't commented out (with a ;). Like all
  1523. directives, this is set in php.ini
  1524. Because the default is 1, it's critical that you're 100% sure that the
  1525. correct php.ini file is being read. Read this faq for details.
  1526. 13. How do I know if my php.ini is being found and read? It seems like
  1527. it isn't as my changes aren't being implemented.
  1528. To be sure your php.ini is being read by PHP, make a call to phpinfo()
  1529. and near the top will be a listing called Configuration File (php.ini).
  1530. This will tell you where PHP is looking for php.ini and whether or not
  1531. it's being read. If just a directory PATH exists than it's not being
  1532. read and you should put your php.ini in that directory. If php.ini is
  1533. included within the PATH than it is being read.
  1534. If php.ini is being read and you're running PHP as a module, then be
  1535. sure to restart your web server after making changes to php.ini
  1536. 14. How do I add my PHP directory to the PATH on Windows?
  1537. On Windows NT, 2000, XP and 2003:
  1538. * Go to Control Panel and open the System icon (Start -> Settings ->
  1539. Control Panel -> System, or just Start -> Control Panel -> System
  1540. for Windows XP/2003)
  1541. * Go to the Advanced tab
  1542. * Click on the 'Environment Variables' button
  1543. * Look into the 'System Variables' pane
  1544. * Find the Path entry (you may need to scroll to find it)
  1545. * Double click on the Path entry
  1546. * Enter your PHP directory at the end, including ';' before (e.g.
  1547. ;C:\php)
  1548. * Press OK and restart your computer
  1549. On Windows 98/Me you need to edit the autoexec.bat file:
  1550. * Open the Notepad (Start -> Run and enter notepad)
  1551. * Open the C:\autoexec.bat file
  1552. * Locate the line with PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;..... and
  1553. add: ;C:\php to the end of the line
  1554. * Save the file and restart your computer
  1555. Note: Be sure to reboot after following the steps above to ensure
  1556. that the PATH changes are applied.
  1557. The PHP manual used to promote the copying of files into the Windows
  1558. system directory, this is because this directory (C:\Windows, C:\WINNT,
  1559. etc.) is by default in the systems PATH. Copying files into the Windows
  1560. system directory has long since been deprecated and may cause problems.
  1561. 15. How do I make the php.ini file available to PHP on windows?
  1562. There are several ways of doing this. If you are using Apache, read
  1563. their installation specific instructions (Apache 1, Apache 2),
  1564. otherwise you must set the PHPRC environment variable:
  1565. On Windows NT, 2000, XP and 2003:
  1566. * Go to Control Panel and open the System icon (Start -> Settings ->
  1567. Control Panel -> System, or just Start -> Control Panel -> System
  1568. for Windows XP/2003)
  1569. * Go to the Advanced tab
  1570. * Click on the 'Environment Variables' button
  1571. * Look into the 'System variables' pane
  1572. * Click on 'New' and enter 'PHPRC' as the variable name and the
  1573. directory where php.ini is located as the variable value (e.g.
  1574. C:\php)
  1575. * Press OK and restart your computer
  1576. On Windows 98/Me you need to edit the autoexec.bat file:
  1577. * Open the Notepad (Start -> Run and enter notepad)
  1578. * Open the C:\autoexec.bat file
  1579. * Add a new line to the end of the file: set PHPRC=C:\php (replace
  1580. C:\php with the directory where php.ini is located). Please note
  1581. that the path cannot contain spaces. For instance, if you have
  1582. installed PHP in C:\Program Files\PHP, you would enter
  1583. C:\PROGRA~1\PHP instead.
  1584. * Save the file and restart your computer
  1585. 16. Is it possible to use Apache content negotiation (MultiViews
  1586. option) with PHP?
  1587. If links to PHP files include extension, everything works perfect. This
  1588. FAQ is only for the case when links to PHP files don't include
  1589. extension and you want to use content negotiation to choose PHP files
  1590. from URL with no extension. In this case, replace the line AddType
  1591. application/x-httpd-php .php with:
  1592. # PHP 4
  1593. AddHandler php-script php
  1594. AddType text/html php
  1595. # PHP 5
  1596. AddHandler php5-script php
  1597. AddType text/html php
  1598. This solution doesn't work for Apache 1 as PHP module doesn't catch
  1599. php-script.
  1600. 17. Is PHP limited to process GET and POST request methods only?
  1601. No, it is possible to handle any request method, e.g. CONNECT. Proper
  1602. response status can be sent with header(). If only GET and POST methods
  1603. should be handled, it can be achieved with this Apache configuration:
  1604. <LimitExcept GET POST>
  1605. Deny from all
  1606. </LimitExcept>