Now Hiring: Are you a driven and motivated 1st Line IT Support Engineer?

Blog

DirectAdmin 使用Mod_fcgid替换cli/SuPHP

其它内容

DirectAdmin 使用Mod_fcgid替换cli/SuPHP

DirectAdmin 使用Mod_fcgid替换cli/SuPHP

fcgid是标准的fastcgi模式 性能和cli模式要好,
这种要看情况,以及硬件环境和配置优化等参数

cd /usr/local/src
wget http://www.apache.org/dist/httpd/mod_fcgid/mod_fcgid-2.3.5.tar.gz
tar xvfz mod_fcgid-2.3.5.tar.gz
cd mod_fcgid-2.3.5
APXS=/usr/sbin/apxs ./configure.apxs && make && make install
chmod 755 -R /var/lib/httpd
mkdir /fcgi

修改DA的编译配置

cd /usr/local/directadmin/custombuild/
vi options.conf
改为 php5_cgi=yes   php5_cli=no
然后开始重新编译 php

./build php n在更改apache配置文件并且加载mod_fcgid模块

vi /etc/httpd/conf/extra/httpd-info.conf
添加以下字段

LoadModule fcgid_module /usr/lib/apache/mod_fcgid.so
 
SharememPath /var/run/fcgid_shm
SocketPath /var/lib/httpd/fcgid/sock
 
<IfModule mod_fcgid.c>
  FcgidIdleTimeout 3600
  FcgidProcessLifeTime 7200
  FcgidMaxProcesses 128
  FcgidMaxProcessesPerClass 4
  FcgidConnectTimeout 60
  FcgidIOTimeout 90
  FcgidInitialEnv RAILS_ENV production
#  FcgidInitialEnv PHP_FCGI_CHILDREN 4
#  MaxRequestsPerProcess 500
</IfModule>
 
<Directory "/home">
        AllowOverride All
        Options SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
        <IfModule sapi_apache2.c>
        php_admin_flag engine off
        </IfModule>
        <IfModule mod_php5.c>
        php_admin_flag engine off
        </IfModule>
</Directory>下面我们在配置Directadmin的配置文件自定义模板功能
进入  “/usr/local/directadmin/data/templates”.  建立 custom 文件夹. 修改 virtual_host2*.conf
( 4个文件 : virtual_host2.conf / virtual_host2_secure.conf / virtual_host2_secure_sub.conf / virtual_host2_sub.conf )
我们直接copy源过来修改即可

cd /usr/local/directadmin/data/templates
mkdir custom
cp virtual_host2*.conf custom
cd custom


现在更改 virtual_host2*
把这些都注释掉 使用新的

|*if CLI="1"|
#               php_admin_flag engine |PHP|
#               <IfModule !mod_php6.c>
#                       php_admin_flag safe_mode |SAFE_MODE|
#               </IfModule>
#               php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f |USER|@|DOMAIN|'
|*endif|
|*if OPEN_BASEDIR="ON"|
#               php_admin_value open_basedir |OPEN_BASEDIR_PATH|
|*endif|
|*if SUPHP="1"|
#                suPHP_Engine |PHP|
#               suPHP_UserGroup |USER| |GROUP|
|*endif|改为新的是

<IfModule mod_fcgid.c>
    <Files ~ (\.fcgi)>
        SetHandler fcgid-script
        Options +FollowSymLinks +ExecCGI
    </Files>
</IfModule>
<IfModule mod_fcgid.c>
<Files ~ (\.php)>
    SetHandler fcgid-script
    FCGIWrapper "/fcgi/|USER|/public_html/fcgid.sh" .php
    Options +ExecCGI
    allow from all
</Files>
</IfModule>这里需要定义个fcgid的脚本作为用户的初始


cd
/usr/local/directadmin/scripts/custom/

vi fcgid.sh
内容为

#!/bin/sh
export PHP_FCGI_MAX_REQUESTS=0在建立directadmin的post文件
这个文件是执行DA收到的的请求
domain_create_post.sh 命名为这个 并且更改权限为755

#!/bin/sh
mkdir -p /fcgi/${username}/public_html
cp /usr/local/directadmin/scripts/custom/fcgid.sh /fcgi/${username}/public_html/fcgid.sh && chmod 0700 /fcgi/${username}/public_html/fcgid.sh
cp /usr/local/directadmin/scripts/custom/php.ini /fcgi/${username}/public_html/php.ini
perl -pi -w -e "s/PHPCFG_BASEDIR/\/home\/${username}\//g;" /fcgi/${username}/public_html/php.ini
chown -R ${username}:${username} /fcgi/${username}
echo "date  ${domain} created  " >> /var/log/directadmin/domain_create.log
exec /usr/local/php5/bin/php-cgi最后复制一个php.ini 到 自定义文件夹
/usr/local/directadmin/scripts/custom/
并且更改 open_basedir 为

open_basedir = PHPCFG_BASEDIR:/tmp:/var/tmp最后更改执行权限更改

chmod a+x /usr/local/directadmin/scripts/custom/*.sh测试环境以及软件版本 :
1. CentOS 5.4 / 5.5 – 64 bits
2. DirectAdmin 1.362 – With Custombuild 1.2
3. Apache 2.2.17 – Worker MPM
4. PHP 5.2.15 – 5.2.17
5. mod_fcgid 2.3.4 / 2.3.5

备注
1. 不支持mod_fcgid 2.3.6版本  [修复方式见注1]
2. 不支持directadmin自动更新php软件版本.

注1
2.3.6的已修复
官方公告为 https://issues.apache.org/bugzilla/show_bug.cgi?id=49902#c3

解压源码包后 文本编辑 fcgid_spawn_ctl.c 更改第178行的:
&& current_node->vhost_id == sconf->vhost_id
改为
&& current_node->vhost_id == command->vhost_id

后重新编译即可

Comments (2)

  1. 我想要跟你交个朋友,留个QQ吧?

    2012年3月9日 at 上午 9:32
    |Reply
  2. 可以申请友情链接吗?博主~~

    2012年3月9日 at 下午 6:30
    |Reply

回复 奇妖电影网 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare