我已经安装了PHP,Apache和fastcgi_handler:
emerge dev-lang/php www-apache/mod_fastcgi_handler
我设法通过更新/etc/apache2/modules.d/70_mod_php5.conf中的相关行
至:
# AddHandler application/x-httpd-php .php .php5 .phtml # AddHandler application/x-httpd-php-source .phps AddHandler fcgi:/var/run/php-fpm.socket .php .php5
和/etc/conf.d/apache2来
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D SUEXEC -D LANGUAGE -D PHP5 -D FASTCGI_HANDLER"
在我的文档根目录中,我有以下文件来validation安装:
<?php echo '<pre>'; var_dump(exec('whoami')); var_dump(php_sapi_name());
然后我有以下的虚拟主机:
<IfDefine DEFAULT_VHOST> <VirtualHost localhost:80> ServerName local.testdomain.com ServerAlias local.testdomain.com SuExecUserGroup foobar foobar DocumentRoot "/home/foobar/workspace/local.testdomain.com" <Directory "/home/foobar/workspace/local.testdomain.com"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> </IfDefine>
其结果是:501错误
[Wed Jul 10 01:52:10 2013] [error] [client ::1] (13)Permission denied: access to / denied (filesystem path '/home/foobar/workspace/') because search permissions are missing on a component of the path
将文档根目录移动到用户目录之外,test.php似乎正确执行,但是我得到了这个结果:
string(6) "nobody" string(8) "fpm-fcgi"
我期待它是:
string(6) "foobar" string(8) "fpm-fcgi"
我的假设是,如果我能让SuExec正常工作,它可以毫无问题地遍历用户的目录。
在我的推论,这证实PHP-FPM工作正常,但是这个指令:“ SuExecUserGroup foobar foobar ”没有。 SuExec肯定是工作,因为我在日志中获得以下行:
[Wed Jul 10 02:09:47 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
我希望有人能指出我错过了什么,以及我怎么可能修复它。
提前致谢。
我正在使用Gentoo btw。
使用PHP-FPM,如果要更改PHP进程的uid,则不再需要SuExec。
您可以使用php-fpmconfiguration文件的指令“user”和“group”来执行相同的操作。