我试图configurationDebian 6.0.4与PHP5的大规模共享主机。 apache2-mpm-worker libapache2-mod-fcgid apache2-suexec软件包apache2-mpm-worker libapache2-mod-fcgid apache2-suexec 。
我成功地加载了mod_vhost_alias和suexec来pipe理我的域名,然后我把这个configuration放在/etc/apache2/sites-enabled/001-vhostalias :
NameVirtualHost *:80 ServerName web-test.mynet.lan DocumentRoot /var/www/ SuexecUserGroup www-data www-data UseCanonicalName Off VirtualDocumentRoot /var/www/www.%2+/public_html/ VirtualScriptAlias /var/www.%2+/cgi-bin/ DirectoryIndex index.html index.htm index.shtml index.php ScriptAlias /__php5-cgi/ "/usr/local/lib/custom-cgi/php5-cgi/" Action php5-script /__php5-cgi/php5-cgi AddHandler php5-script .php
有了上面的这个,在线上,一个名为www.test-a.com的域名需要:
adduser test-a.com (强制使用坏名字) mkdir -p /var/www/www.test-a.com/public_html并放置数据 chmod和chown , 一切工作正常 … 没有suEXEC我做了一些简单的PHPtesting,它工作正常uid / gid www-data 。 但现在我需要启用suEXEC隔离域…
问题是:如何告诉suEXEC自动获得正确的uid / gid?
我正在使用默认的suEXECconfiguration:
root@web-test:/var/www# /usr/lib/apache2/suexec -V -D AP_DOC_ROOT="/var/www" -D AP_GID_MIN=100 -D AP_HTTPD_USER="www-data" -D AP_LOG_EXEC="/var/log/apache2/suexec.log" -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin" -D AP_UID_MIN=100 -D AP_USERDIR_SUFFIX="public_html"
但它崩溃了:
root@web-test:/var/www# tail /var/log/apache2/suexec.log [2012-05-05 18:31:48]: cannot run as forbidden uid (33/php5-cgi) [2012-05-05 18:34:24]: uid: (33/www-data) gid: (33/www-data) cmd: php5-cgi
注意:我以前使用过apache2-mpm-itk但是在400-500个VirtualHost定义之后,特别是在apache2ctl restart|graceful"时崩溃了。
谢谢
我会build议使用mpm-itk
Package: apache2-mpm-itk Description: multiuser MPM for Apache 2.2 The ITK Multi-Processing Module (MPM) works in about the same way as the classical "prefork" module (that is, without threads), except that it allows you to constrain each individual vhost to a particular system user. This allows you to run several different web sites on a single server without worrying that they will be able to read each others' files. This is a third-party MPM that is not included in the normal Apache httpd. Please note that this MPM is somewhat less tested than the MPMs that come with Apache itself.
有了额外的补丁,你可以dynamic地分配uid / gid。 我使用这样的解决scheme大约2年没有任何问题。
<VirtualHost *:80> ServerName www.example.net ServerAlias *.example.net UseCanonicalName Off VirtualDocumentRoot /vhosts/example.net/%1 DirectoryIndex index.php index.html AssignUserFromPath "^/vhosts/example.net/([^/]+)" mvh_$1 mvh_$1 <Directory /vhosts/example.net> Options -Indexes +Includes AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
SuexecUserGroup指令似乎不支持variables,所以没有简单的方法来做你想要的。 这个邮件列表文章也说这是不可能的,应该使用CGIwrap来代替。 我能想到的唯一的另一种方法是滥用suEXEC的mod_userdir集成,并以某种方式将请求重写到用户目录,但这不太可能奏效。