Configure PHP Support module mode, CGI mode, and fastcgi mode in Apache

Source: Internet
Author: User

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

Configure PHP Support module mode, CGI mode, and fastcgi mode in Apache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.