设为首页 收藏本站
查看: 405|回复: 0

[经验分享] Windows下FastCGI安装PHP(Apache mod_fcgid)

[复制链接]

尚未签到

发表于 2015-8-1 08:28:07 | 显示全部楼层 |阅读模式
  在升级本地php至5.3.3版本时,发现NTS版本包里没有php5apache2_2.dll库,以为PHP落掉了这个重要的库,google后得知,是针对PHP的FastCGI安装方式。需要给Apache安装FastCGI的mod,并配置,引用一篇安装配置的原文。
  

  I’ve run PHP on Windows in every way imaginable. I’ve run it through IIS and Apache. I’ve run it as SAPI, CGI, FastCGI. Heck, I’ve run it from the command line to automate tasks (during my pre-Python days). But I hadn’t tried mod_fcgid until recently. Setting it up isn’t terribly straight forward and most of the online tutorials I found were for various flavor of Linux, so I thought I’d go over how to do it here.
  Everybody that has worked with PHP for a while knows that using it inline with your web server will, at random points, eat your web server. This has been true across PHP versions forever. There are always legends of people that have just the right release with just the right libraries and just the right modules loaded that it just works and if you’re one of those people (a) I hate you and (b) for pete’s sake DON’T TOUCH ANYTHING. From my personal experience, trying to pinpoint and fix the problem will turn your life into a furious ball of nothing.

  So most people end up with a CGI or FastCGI solution.
  mod_fcgid is a FastCGI solution, that being basically CGI with the ability to persist a process or processes and manage them from the server. That gives you the performance benefits of ISAPI (or pretty close) with the process isolation of CGI. mod_fcgid is binary compatible with FastCGI, but offers improved control over process spawning. It also runs well on multi-threaded Apache and lets you fairly easily run different PHP versions and configurations on the same Apache instance. Plus, running PHP under Apache with mod_fastcgi has proven problematic in practice.
  Assuming you already have Apache 2.x up and running, we’re going to grab a couple of things. First, you’ll want to grab the Non Thread Safe release of PHP. This will massively increase performance of PHP, as the PHP process doesn’t have twiddle its thumbs waiting on thread synchronization.  The next thing you’ll need to grab is mod_fcgid, which you’ll dump into your Apache modules folder. We’ll assume you dumped the PHP folder at C:\php, so change your paths appropriately.
  Next, you’ll need to load the mod_fcgid module in your Apache httpd.conf file.
  


  • LoadModule fcgid_module modules/mod_fcgid.so  
  Now for the hard bit – configuring mod_fcgid. There are all kinds of mod_fcgid settings you can read about on the doc site, but these should cover most of your needs.



    AddHandler fcgid-script .fcgi .php  
  # Where to look for the php.ini file?  
  FcgidInitialEnv PHPRC        "c:/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 "c:/php/php-cgi.exe" .php  
  # Define the MIME-Type for ".php" files  
  AddType application/x-httpd-php .php  
   AddHandler fcgid-script .fcgi .php # Where to look for the php.ini file? FcgidInitialEnv PHPRC        "c:/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 "c:/php/php-cgi.exe" .php # Define the MIME-Type for ".php" files AddType application/x-httpd-php .php   Note the two hard paths to PHP – change those as needed. Last, we’ll  need to tell Apache to include ExecCGI in its options for a particular  directory. Supposing your document root is C:\www, you’d have something  like this:

  
  Options Indexes FollowSymLinks ExecCGI  
  Order allow,deny  
  Allow from all  
  AllowOverride All  
   Options Indexes FollowSymLinks ExecCGI Order allow,deny Allow from all AllowOverride All   Now php files in your document root and subsequent directories will  be served by mod_fcgid. Restart Apache, make a test php file (), and give it a whirl. You should see a php-cgi.exe  process started that mod_fcgid is managing.
  It’s tricky to set up the first time, but mod_fcgid is the best way to run PHP on Apache I’ve found.
  原文地址:
  http://fuzzytolerance.info/code/apache-mod_fcgid-and-php-on-windows/
  

  
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-92856-1-1.html 上篇帖子: 64位Apache 下篇帖子: php程序apache 301重定向设置(.htaccess)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表