Linux · 2010-05-15

DirectAdmin把php从CLI调整为suPhp(php-cgi)

公司的机器上突然apache的cpu一直跑高,但是php是跑在php-cli模式下,需要调整为suphp(php-cgi)
默认cli是让php跑在apache上,调整php跑在用户上代替原本的apache,不调整的话看不到具体是哪个用户出问题

以下为directadmin重新编译的方法

cd /usr/local/directadmin
mv custombuild custombuild.old
wget http://files.directadmin.com/services/custombuild/1.1/cu
stombuild.tar.gz
tar xvzf custombuild.tar.gz
cd custombuild
./build suphp
./build all d #这个过程比较久
./build rewrite_confs

*************************************
*                                   *
*   All parts have been installed   *
*                                   *
*************************************

Type: /sbin/service httpd restart


更改配置文件 /usr/local/directadmin/custombuild/options.conf
把
php5_cli=yes
php5_cgi=no
改成
php5_cli=no
php5_cgi=yes

更改配置文件 /usr/local/suphp/etc/suphp.conf
把日志的level改为info
;Loglevel
;loglevel=warn
loglevel=error


然后重启apache
测试phpinfo页面下
Server API 	CGI/FastCGI 
就是成功了。

这样在top里就能找出哪个虚拟主机用户跑高apache的cpu或内存了!

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                          
30855 xxx    17   0 25236  10m 4464 S 52.5  0.3   0:00.31 /usr/local/php5/bin/php-cgi

suPhp日志 /var/log/suphp.log

Note: 如果发生Internal Server Error (http500) 大多数为文件宿主不正确
则继续运行
./build roundcube
./build squirrelmail
./build phpmyadmin

DirectAdmin_如何安装suPhp