Install Apache, MySQL, and PHP first, sequentially.
1.apache, MySQL installation is relatively simple, skip
2. PHP installation, I installed the php5.3.6 built-in php-fpm, so there is no need to separate under the patch.
./CONFIGURE–PREFIX=/USR/LOCAL/PHP5/
--with-mysql=/usr/local/mysql/
--enable-fpm
--with-apxs2=/usr/local/apache/bin/apxs
Attention:
--enable-fastcgi
--enable-force-cgi-redirect
These 2 new versions of PHP are already built-in, so if you add these 2 parameters, make will indicate that the 2 parameters cannot be found. So there's no need to add these 2 parameters.
--with-apxs2
This parameter see some article said need fastcgi mode, can not configure this, in fact, is not exactly so, the purpose of this parameter is simply to compile the PHP interpretation module into so file added to Apache modules, and automatically added to the Conf file. If we do not want to use the module mode, in the httpd.conf:
LoadModule Php5_module modules/libphp5.so
This line can be commented out.
Installation of 3.mod_fastcgi
#wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
# TAR-ZXVF Mod_fastcgi-2.4.6.tar.gz
# CD mod_fastcgi-2.4.6
# CP Makefile.ap2 Makefile
# vim Makefile To change the path in Makefile to the installation path of your Apache
# Make install successful
After successful installation, the mod_fastcgi.so is automatically copied to the/usr/local/apache/modules directory
The next step is how to configure these 4 modes:
1. Module mode
This mode is the simplest, increasing in http.conf
LoadModule Php5_module modules/libphp5.so
Can. And then in
<ifmodule mime_module>
AddType application/x-httpd-php. php
AddType Applicaiton/x-httpd-php-source. Phps
2.CGI mode
This mode needs to be commented out
LoadModule Php5_module modules/libphp5.so this line. If you do not annotate this line go straight to handler mode. This is the module mode.
Then add the action in httpd.conf:
Action application/x-httpd-php/cgi-bin/php-cgi
If php-cgi is not found in the/cgi-bin/directory. You can do it yourself from the bin inside of PHP.
Then restart Apache, and then open the test page to discover that the server API becomes: cgi/fastcgi. Description successfully switched to CGI mode.
3.FastCgi mode, built-in Process manager with Apche
First, add the FastCGI module to the httpd.conf configuration file:
LoadModule Fastcgi_module modules/mod_fastcgi.so
This pattern annotation does not comment loadmodule php5_module modules/libphp5.so This line seems to be of little relevance, as long as the following modules are configured
<ifmodule fastcgi_module>
Fastcgiserver/usr/local/apache/cgi-bin/php-cgi-processes 20
AddType application/x-httpd-php. php
AddHandler php-fastcgi. php
Action php-fastcgi/cgi-bin/php-cgi
</IfModule>
will automatically go to fastcgi mode.
Then restart Apache, this time with PS Aux|grep PHP will find a lot of php-cgi process is running. Description Configuration takes effect
4.FastCgi mode, with PHP-FPM process Manager
First, add the FastCGI module to the httpd.conf configuration file:
LoadModule Fastcgi_module modules/mod_fastcgi.so
Then modify the configuration file into:
<ifmodule fastcgi_module>
Fastcgiexternalserver/usr/local/apache/cgi-bin/php-cgi-host 127.0.0.1:9000
AddType application/x-httpd-php. php
AddHandler php-fastcgi. php
Action php-fastcgi/cgi-bin/php-cgi
</IfModule>
Note that the 127.0.0.1:9000 is the PHP-FPM open port, so we also need to turn the php-fpm on.
The location of my computer is.
>>>/usr/local/php5/sbin/php-fpm
Open and then PS aux|grep php
Will find a lot of php-fpm processes:
Root 7002 0.4 1.5 13060 1912? Ss 15:20 0:00 php-fpm:master process (/usr/local/php5/etc/php-fpm.conf)
Nobody 7003 0.0 1.3 13052 1656? S 15:20 0:00 Php-fpm:pool www
Nobody 7004 0.0 1.3 13052 1660? S 15:20 0:00 Php-fpm:pool www
Nobody 7005 0.0 1.3 13052 1660? S 15:20 0:00 Php-fpm:pool www
Nobody 7006 0.0 1.3 13052 1660? S 15:20 0:00 Php-fpm:pool www
Nobody 7007 0.0 1.3 13052 1660? S 15:20 0:00 Php-fpm:pool www
Nobody 7008 0.0 1.3 13052 1660? S 15:20 0:00 Php-fpm:pool www
Nobody 7009 0.0 1.3 13052 1660? S 15:20 0:00 Php-fpm:pool www
Nobody 7010 0.0 1.3 13052 1660? S 15:20 0:00 Php-fpm:pool www
Nobody 7011 0.0 1.3 13052 1660? S 15:20 0:00 Php-fpm:pool www
Nobody 7012 0.0 1.3 13052 1668? S 15:20 0:00 Php-fpm:pool www
Nobody 7013 0.0 1.3 13052 1672? S 15:20 0:00 Php-fpm:pool www
Nobody 7014 0.0 1.3 13052 1672? S 15:20 0:00 Php-fpm:pool www
Nobody 7015 0.0 1.3 13052 1672? S 15:20 0:00 Php-fpm:pool www
Nobody 7016 0.0 1.3 13052 1672? S 15:20 0:00 Php-fpm:pool www
Nobody 7017 0.0 1.3 13052 1672? S 15:20 0:00 Php-fpm:pool www
Nobody 7018 0.0 1.3 13052 1672? S 15:20 0:00 Php-fpm:pool www
Nobody 7019 0.0 1.3 13052 1672? S 15:20 0:00 Php-fpm:pool www
Nobody 7020 0.0 1.3 13052 1676? S 15:20 0:00 Php-fpm:pool www
Nobody 7021 0.0 1.3 13052 1672? S 15:20 0:00 Php-fpm:pool www
Nobody 7022 0.0 1.3 13052 1676? S 15:20 0:00 Php-fpm:pool www
Re-test access no problem, the merit of making it.
Apache Configuration PHP Support module mode, CGI mode and fastcgi mode experiment