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