diff --git a/install/unix/apache2.xml b/install/unix/apache2.xml index 23024391b65e..af5b33c2862f 100644 --- a/install/unix/apache2.xml +++ b/install/unix/apache2.xml @@ -1,47 +1,69 @@ - Apache 2.x on Unix systems + Apache httpd 2.x on Unix systems - This section contains notes and hints specific to Apache 2.x installs - of PHP on Unix systems. + This section contains notes and hints specific to Apache HTTP Server + 2.x installs of PHP on Linux and Unix-like systems. - - &warn.apache2.compat; - + + + Use PHP-FPM Instead + + Do not use mod_php for new + installations. The instructions on this page are retained + for historical reference and for the rare cases where embedding PHP + directly in the Apache httpd process is specifically required. + + + For all modern deployments, use + PHP-FPM (FastCGI Process Manager) + with Apache httpd's mod_proxy_fcgi module. PHP-FPM + provides better resource management, process isolation, independent + restart of PHP without restarting Apache httpd, and compatibility with + Apache httpd's event MPM (the default since Apache httpd 2.4). + Major Linux distributions ship this as the default configuration. + + + The mod_php approach embeds PHP directly into every + Apache httpd worker process. Unless PHP is compiled with thread safety + (--enable-zts), mod_php requires + the prefork MPM, which significantly limits + concurrency. If you proceed with mod_php, you + should fully understand the performance and security implications. + + + The Apache Documentation - is the most authoritative source of information on the Apache 2.x server. - More information about installation options for Apache may be found + is the most authoritative source of information on the Apache httpd 2.x server. + More information about installation options for Apache httpd may be found there. - The most recent version of Apache HTTP Server may be obtained from + The most recent version of Apache httpd may be obtained from Apache download site, and a fitting PHP version from the above mentioned places. - This quick guide covers only the basics to get started with Apache 2.x + This quick guide covers only the basics to get started with Apache httpd 2.x and PHP. For more information read the Apache Documentation. The version numbers have been omitted here, to ensure the instructions are not incorrect. In the examples below, 'NN' should be - replaced with the specific version of Apache being used. + replaced with the specific version of Apache httpd being used. - There are currently two versions of Apache 2.x - there's 2.4 and 2.2. - While there are various reasons for choosing each, 2.4 is the current - latest version, and the one that is recommended, if that option is - available to you. However, the instructions here will work for either - 2.4 or 2.2. Note that Apache httpd 2.2 is officially End Of Life, - and no new development or patches are being issued for it. + These instructions apply to Apache httpd 2.4, which is the only supported + release branch of Apache httpd. Earlier versions (2.2 and below) are + end of life and should not be used. - Obtain the Apache HTTP server from the location listed above, + Obtain Apache httpd from the location listed above, and unpack it: @@ -67,18 +89,23 @@ tar -xzf php-NN.tar.gz - + - Build and install Apache. Consult the Apache install documentation for - more details on building Apache. + Build and install Apache httpd. Consult the Apache httpd install documentation for + more details on building Apache httpd. Note that mod_php + requires the prefork MPM unless PHP was compiled + with thread safety (--enable-zts). If you intend + to use PHP-FPM instead (recommended), you can use the default + event MPM and skip to the + PHP-FPM installation instructions. @@ -88,10 +115,10 @@ make install - Now you have Apache 2.x.NN available under /usr/local/apache2, - configured with loadable module support and the standard MPM prefork. + Now you have Apache httpd 2.x.NN available under /usr/local/apache2, + configured with loadable module support and the prefork MPM. To test the installation use your normal procedure for starting - the Apache server, e.g.: + the Apache httpd server, e.g.: @@ -101,7 +128,7 @@ make install - and stop the server to go on with the configuration for PHP: + and stop the server to continue with the configuration for PHP: @@ -118,13 +145,13 @@ make install Now, configure and build PHP. This is where you customize PHP with various options, like which extensions will be enabled. Run ./configure --help for a list of available options. In our example - we'll do a simple configure with Apache 2 and MySQL support. + we'll do a simple configure with Apache httpd and MySQL support. - If you built Apache from source, as described above, the below example will - match your path for apxs, but if you installed Apache some other way, you'll - need to adjust the path to apxs accordingly. Note that some distros may rename + If you built Apache httpd from source, as described above, the below example will + match your path for apxs, but if you installed Apache httpd some other way, you'll + need to adjust the path to apxs accordingly. Note that some distributions may rename apxs to apxs2. @@ -144,9 +171,9 @@ make install you'll need to re-run the configure, make, and make install steps. You only need to restart apache for the new module to take effect. - A recompile of Apache is not needed. + A recompile of Apache httpd is not needed. - + Note that unless told otherwise, make install will also install PEAR, @@ -159,7 +186,7 @@ make install Setup your php.ini. - + php.ini in another location, use --with-config-file-path=/some/path in step 5. - + If you instead choose php.ini-production, be certain to read the list of changes within, as they affect how PHP behaves. @@ -189,25 +216,9 @@ cp php.ini-development /usr/local/lib/php.ini - - For PHP 8: - - - - - - - - For PHP 7: - - - - @@ -215,8 +226,8 @@ LoadModule php7_module modules/libphp7.so - Tell Apache to parse certain extensions as PHP. For example, let's have - Apache parse .php files as PHP. Instead of only using the Apache AddType + Tell Apache httpd to parse certain extensions as PHP. For example, let's have + Apache httpd parse .php files as PHP. Instead of only using the AddType directive, we want to avoid potentially dangerous uploads and created files such as exploit.php.jpg from being executed as PHP. Using this example, you could have any extension(s) parse as PHP by simply adding @@ -243,7 +254,7 @@ LoadModule php7_module modules/libphp7.so + SetHandler application/x-httpd-php ]]> @@ -268,7 +279,6 @@ LoadModule php7_module modules/libphp7.so To allow use of a PHP file as the default handler if no other handler is found, for example when using a routing engine, the FallbackResource directive may be used. - This is available in Apache 2.4.4 and later. @@ -317,9 +327,9 @@ RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source] - Use your normal procedure for starting the Apache server, e.g.: + Use your normal procedure for starting Apache httpd, e.g.: - + - Following the steps above you will have a running Apache2 web server with - support for PHP as a SAPI module. Of course, there are - many more configuration options available for Apache and PHP. For more + Following the steps above you will have a running Apache httpd web server with + support for PHP as a SAPI module. There are + many more configuration options available for Apache httpd and PHP. For more information type ./configure --help in the corresponding source tree. - - Apache may be built multithreaded by selecting the - worker MPM, rather than the standard - prefork MPM, when Apache is built. This is done by - adding the following option to the argument passed to ./configure, in - step 3 above: - - - - - - - - - - This should not be undertaken without being aware of the consequences of - this decision, and having at least a fair understanding of - the implications. The Apache documentation - regarding MPM-Modules - discusses MPMs in a great deal more detail. - - + MPM Compatibility - The Apache MultiViews - FAQ discusses using multiviews with PHP. + Unless PHP was compiled with Zend Thread Safety + (--enable-zts), mod_php requires + the prefork MPM. Most distribution packages of + mod_php are not built with ZTS, so + prefork is typically required. If you need a + threaded MPM (recommended for better performance under load), use + PHP-FPM with + mod_proxy_fcgi instead. - To build a multithreaded version of Apache, the target system must support threads. - In this case, PHP should also be built with - Zend Thread Safety (ZTS). Under this configuration, not all extensions will be available. - The recommended setup is to build Apache with the default - prefork MPM-Module. + The Apache MultiViews + FAQ discusses using multiviews with PHP. @@ -410,3 +400,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> +