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

该博客介绍了如何配置Apache的FastCGI模块以优化PHP处理,包括设置MaxRequestsPerProcess、MaxRequestLen、ProcessLifeTime等参数,以及通过Cronjob定时清理PHP进程以减少内存占用。此外,还提到了调整Apache的线程池配置以提升性能。
摘要由CSDN通过智能技术生成

# Fastcgi configuration for PHP5

LoadModule fcgid_module modules/mod_fcgid.so

MaxRequestsPerProcess 15

MaxRequestLen 15728640

ProcessLifeTime 120

IdleTimeout 30

DefaultMinClassProcessCount 0

DefaultMaxClassProcessCount 3

IPCConnectTimeout 60

IPCCommTimeout 30

AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php5

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php4

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php3

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php2

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!)

ThreadStackSize 4000000

ServerLimit 2

StartServers 1

MaxClients 128

MinSpareThreads 1

MaxSpareThreads 1

ThreadsPerChild 8

MaxRequestsPerChild 700

TimeOut 45

MaxRequestsPerProcess 500

MaxProcessCount 15

DefaultMaxClassProcessCount 15

DefaultMinClassProcessCount 0

IPCConnectTimeout 60

IPCCommTimeout 3

PHP_Fix_Pathinfo_Enable 1

IdleTimeout 30

IdleScanInterval 10

BusyTimeout 120

BusyScanInterval 90

ErrorScanInterval 60

ZombieScanInterval 3

ProcessLifeTime 120复制代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值