欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

cpanel中的php运行方式使用fast-cgi模式的配置方法

程序员文章站 2022-05-22 23:03:42
...
  1. # Fastcgi configuration for PHP5
  2. LoadModule fcgid_module modules/mod_fcgid.so
  3. MaxRequestsPerProcess 15
  4. MaxRequestLen 15728640
  5. ProcessLifeTime 120
  6. IdleTimeout 30
  7. DefaultMinClassProcessCount 0
  8. DefaultMaxClassProcessCount 3
  9. IPCConnectTimeout 60
  10. IPCCommTimeout 30
  11. AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml
  12. FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php5
  13. FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php4
  14. FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php
  15. FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php3
  16. FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php2
  17. FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .phtml
复制代码

# End of autogenerated PHP configuration.

保存好之后,重启apache。

4.由于大量php进程长期占用内存,可以每小时执行一次清空php进程。 crontab -e 把光标弄到最下 0 * * * * ps aux | grep php | egrep -v grep | awk ‘{print $2}’ | xargs kill -9 Ctrl+O保存,Enter,Ctrl+X退出

对于第3步,也另有老外总结出其它方法: 登录 WHM->Apache Configuration->Include Editor->Pre Virtual host Include

特别关注地是: - DefaultMinClassProcessCount 0 (necessary to make Idle timeout work) - ThreadStackSize (default is too high, wastes memory, the setting below is good for most and will save enough memory to allow another php thread!)

  1. ThreadStackSize 4000000
  2. ServerLimit 2
  3. StartServers 1
  4. MaxClients 128
  5. MinSpareThreads 1
  6. MaxSpareThreads 1
  7. ThreadsPerChild 8
  8. MaxRequestsPerChild 700
  9. TimeOut 45
  10. MaxRequestsPerProcess 500
  11. MaxProcessCount 15
  12. DefaultMaxClassProcessCount 15
  13. DefaultMinClassProcessCount 0
  14. IPCConnectTimeout 60
  15. IPCCommTimeout 3
  16. PHP_Fix_Pathinfo_Enable 1
  17. IdleTimeout 30
  18. IdleScanInterval 10
  19. BusyTimeout 120
  20. BusyScanInterval 90
  21. ErrorScanInterval 60
  22. ZombieScanInterval 3
  23. ProcessLifeTime 120
复制代码