Red Hat/CentOS Apache 2 FastCGI PHP Configuration(2)

?AddHandler php5-fastcgi .php : To configure Apache to handle php files (within the scope of the directive) with the specified extension(s) as FastCGI applications.
?Action php5-fastcgi /cgi-bin/php.fcgi : This directive adds an action, which will activate cgi-script when action-type is triggered by the request. The cgi-script is the URL-path to a resource that has been configured as a CGI script using ScriptAlias. In our case, requests for files with a .php file extension of are handled instead by the specified cgi script /cgi-bin/php.fcgi.
Save and close the file. Restart httpd:

# service httpd restart
mod_fastcgi virtual hosting configuration
?Domain name: nixcraft.com
?DocumentRoot: /websites/home/nixcraft.com/http
?cgi-bin directory: /websites/home/nixcraft.com/cgi-bin
?php.fcgi path: /websites/home/nixcraft.com/cgi-bin/php.fcgi
?Logs file directory: /websites/home/nixcraft.com/logs
Based upon above settings your virtualhosting configuration for nixcraft.com domain should look like as follows:

<VirtualHost *:80>
        ServerAdmin webmaster@nixcraft.com
        DocumentRoot "/websites/home/nixcraft.com/http"
        ServerName nixcraft.com
        ServerAlias
        ErrorLog "/websites/home/nixcraft.com/logs/error.log"
        CustomLog "/websites/home/nixcraft.com/logs/access.log" common
        ScriptAlias /cgi-bin/ "/websites/home/nixcraft.com/cgi-bin/"
 
 <Directory "/websites/home/nixcraft.com/http">
  Options -Indexes FollowSymLinks +ExecCGI
  AllowOverride AuthConfig FileInfo
  AddHandler php5-fastcgi .php
  Action php5-fastcgi /cgi-bin/php.fcgi
  Order allow,deny
  Allow from all
 </Directory>
 
 <Directory "/websites/home/nixcraft.com/cgi-bin">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
 </Directory>
</VirtualHost>Create a /websites/home/nixcraft.com/cgi-bin/php.fcgi as follows:

#!/bin/bash
PHP_CGI=/usr/bin/php-cgi
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec$PHP_CGISet permission and restart httpd:

# chmod +x /websites/home/nixcraft.com/cgi-bin/php.fcgi# service httpd restart

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wywpgj.html