好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

DirectAdmin 使用Mod_fcgid替换cli/SuPHP

DirectAdmin 使用 Mod_fcgid替换cli/SuPHP fcgid是标准的fastcgi模式 性能和cli模式要好, 这种要看情况,以及硬件环境和配置优化等参数 cd /usr/local/src wget http://HdhCmsTestapache.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 FcgidIdleTimeout 3600 FcgidProcessLifeTime 7200 FcgidMaxProcesses 128 FcgidMaxProcessesPerClass 4 FcgidConnectTimeout 60 FcgidIOTimeout 90 FcgidInitialEnv RAILS_ENV production # FcgidInitialEnv PHP_FCGI_CHILDREN 4 # MaxRequestsPerProcess 500 AllowOverride All Options SymLinksIfOwnerMatch Order allow,deny Allow from all php_admin_flag engine off php_admin_flag engine off 下面我们在配置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| # # php_admin_flag safe_mode |SAFE_MODE| # # 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|改为新的是 SetHandler fcgid-script Options +FollowSymLinks +ExecCGI  

SetHandler fcgid-script FCGIWrapper "/fcgi/|USER|/public_html/fcgid.sh" .php Options +ExecCGI allow from all 这里需要定义个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 后重新编译即可  

查看更多关于DirectAdmin 使用Mod_fcgid替换cli/SuPHP的详细内容...

  阅读:42次