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.

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