开启fcgid模式你的服务器的性能可以提升好几倍,无论从并发量还是请求总量,我测试了自己本机的访问量10000000个,并发10000个,直接宕机,但是开启了fcgid模式就不会宕机了,只是变慢了而已,所有fcgid模式还是非常有用的,正式服务器建议一定开启fcgid模式,

这是自己的亲身体验的效果的。

1:下载apache 的扩展文件 mod_fcgid.so 文件(https://www.apachehaus.com/cgi-bin/download.plx

2:解压其中的mod_fcgid.so 到apache的modules目录下

3:修改apache的配置文件  如下:

#加载mod_fcgid.so模块

LoadModule fcgid_module modules/mod_fcgid.so

#fcgid.的配置

<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi .PHP
# Where to look for the php.ini file?
FcgidInitialEnv PHPRC        "D:/php"
# Set PHP_FCGI_MAX_REQUESTS to greater than or equal to FcgidMaxRequestsPerProcess
# to prevent php-cgi process from exiting before all requests completed
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS      1000
# Maximum requests a process should handle before it is terminated
FcgidMaxRequestsPerProcess       1000
# Maximum number of PHP processes
FcgidMaxProcesses             15
# Number of seconds of idle time before a php-cgi process is terminated
FcgidIOTimeout             120
FcgidIdleTimeout                120
#Path to php-cgi
FcgidWrapper "D:/php/php-cgi.exe" .php
# Define the MIME-Type for ".php" files
AddType application/x-httpd-php .php
</IfModule>

4:在apache的配置文件中找到其发布目录配置,添加如下红色部分标注的部分,否则会提示你无权限访问项目目录

<Directory "D:/wamp/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes  FollowSymLinks Includes ExecCGI
    
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

  # Controls who can get stuff from this server.
  Order allow,deny
  Allow from all

</Directory>

5:在vhost里面加入

<VirtualHost *:80>
    ServerAdmin admin@kkjy.com
    DocumentRoot "/www/xxx"
    ServerName xxx.com
    ServerAlias xxx.com
    ErrorLog "logs/xxx.com-error.log"
    CustomLog "logs/xxx.com-access.log" common
    <Directory "/www/xxx">
      AddHandler fcgid-script .php
      Options Indexes FollowSymLinks ExecCGI
      AllowOverride all
      FcgidWrapper "D:/php/php-cgi.exe" .php
      Require all granted
    </Directory>
</VirtualHost>

6:重新启动apache,查看你的phpinfo()中的环境变量中是否加入了fcgid