Apache2 使用suexec和mod_fcgid的apache大规模虚拟主机

Apache2 使用suexec和mod_fcgid的apache大规模虚拟主机,apache2,virtual-hosts,mod-fcgid,suexec,Apache2,Virtual Hosts,Mod Fcgid,Suexec,我遵循了这一点,现在2个用户(例如john和alice)的相关目录(/var/www/john和/var/ww/alice)的一切都按预期运行 现在,我想进入下一个层次:我需要重新启动Apache,而不是在/etc/apache2/sites available/上定义不同的vhost。 比如说,我的DNS服务器有以下记录:other.site.example.com,我希望它的主目录位于/var/www/other.site/web 问题在于suexec和mod_fcgid的所有这些配置设置。

我遵循了这一点,现在2个用户(例如john和alice)的相关目录(
/var/www/john
/var/ww/alice
)的一切都按预期运行

现在,我想进入下一个层次:我需要重新启动Apache,而不是在
/etc/apache2/sites available/
上定义不同的vhost。 比如说,我的DNS服务器有以下记录:
other.site.example.com
,我希望它的主目录位于
/var/www/other.site/web

问题在于suexec和mod_fcgid的所有这些配置设置。 我结束了我的
httpd.conf
(或者我应该创建一个类似
/etc/apache2/sites available/mass_virtual
?)的文件):

NameVirtualHost*:80
#默认虚拟主机
服务器名www.example.com
ServerAlias example.com
服务器管理员webmaster@example.com
DocumentRoot/var/www/root/web/
SuexecUserGroup网站管理员网站管理员
选项+执行CGI
选项-索引
允许超越所有
AddHandler fcgid script.php
FCGIWrapper/var/www/php-fcgi-scripts/root/php-fcgi-starter.php
命令允许,拒绝
通融
#ErrorLog/var/log/apache2/error.log
#CustomLog/var/log/apache2/access.log组合
服务器签名关闭
#三级子域虚拟主机
UseCononicalName关闭
ServerAlias*.example.com
#有问题的电子邮件!
服务器管理员webmaster@example.com
#这是您的/var/www/other.site/web还是/var/www/www.other.site/web
#请求www.other.site.example.com?
VirtualDocumentRoot/var/www/%-3+/web
#有问题的组和用户!
SuexecUserGroup web1 web1
选项+执行CGI
选项-索引
允许超越所有
AddHandler fcgid script.php
FCGIWrapper/var/www/php fcgi scripts/*/php fcgi starter.php
命令允许,拒绝
通融
#ErrorLog/var/log/apache2/error.log
#CustomLog/var/log/apache2/access.log组合
服务器签名关闭
  • 正如您从评论中看到的,我有一个有问题的
    ServerAdminwebmaster@example.com
    、一个
    SuexecUserGroup web1 web1
    和一个
    VirtualDocumentRoot/var/www/%-3+/web
    配置

  • 此外,为了确保安全性,我认为如果
    mod_fcgid
    无法加载,那么服务器和

  • 我想我应该拒绝所有人,并打开一个 改为php库目录


  • 谢谢。

    好的,因为我没有回复,我将尝试我建议的解决方案的一半(?):使用mod_userdir强制执行suexec

  • 让我们创建以下/etc/apache2/httpd.conf

    ##########################################
    ### mod_fcgid configuration directives ###
    ##########################################
    #values should be tuned depending on server memory
    FcgidMaxProcesses 1000
    FcgidMaxProcessesPerClass 100
    FcgidMinProcessesPerClass 3
    #see 'export PHP_FCGI_MAX_REQUESTS=5000' at '/var/www/php-fcgi-scripts/<user>/php-fcgi-starter'
    FcgidMaxRequestsPerProcess 5000
    FcgidIOTimeout 40
    FcgidProcessLifeTime 3600
    FcgidMaxRequestInMem 65536
    FcgidMaxRequestLen 131072
    FcgidOutputBufferSize 65536
    
    问题:如果我取消注释第一行,我会在服务器重新启动时收到警告,表示没有虚拟主机

  • 让我们创建我的用户bob

  • 让我们在
    /var/www/bob/public\u html

    FcgidWrapper /var/www/php-fcgi-scripts/bob/php-fcgi-starter .php
    
  • 让我们点击我的浏览器进入
    www.example.com/info.php
    example.com/info.php

    web-admin
    
    ...trying to open info.php!!!
    
    …如预期,但是

  • 让我们转到
    www.example.com/~bob/info.php

    web-admin
    
    ...trying to open info.php!!!
    
    让我们看看错误

    <root># cat /var/log/apache2/error.log
    [notice] caught SIGTERM, shutting down
    [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
    [notice] Apache/2.2.20 (Ubuntu) mod_fcgid/2.3.6 configured -- resuming normal operations
    
    #cat/var/log/apache2/error.log
    [通知]本学期即将结束
    [注意]已启用suEXEC机制(包装器:/usr/lib/apache2/suEXEC)
    [注意]Apache/2.2.20(Ubuntu)mod_fcgid/2.3.6已配置--恢复正常操作
    
    正如您所看到的,没有错误,但是
    mod_fcgid
    未启用以运行.php文件,apache尝试将其作为普通文件发送!!! 有什么办法解决这个问题吗?


  • 正如我所说,我的意图是请求将www.other.site.example.com定向到用户/var/www/other.site/web,但正如我在“Using suEXEC”上所读到的,我们可以在VirtualHost定义中不使用SuexecUserGroup指令的情况下,在mod_userdir的帮助下调用suEXEC!那么,如果在mod_rewrite的帮助下,对www.other.site.example.com的请求被透明地转换为www.example.com/~other.site,然后使用mod_userdir启用suexec??,该怎么办???有什么想法或指令可以实现这一点吗?这肯定是APACHE中的一个BUG请参见:但我需要指令来修补它!!你有过这样的经历吗?Im现在正处于相同的情况,试图限制用户(也使用vhost别名)