我安装了 Apache2.4 + Php5.6 + mod_proxy_fcgi + php-fpm 以及其他东西,例如 Mysql 5.5、Phpmyadmin 和 munin,没有问题。注意:我还激活了 userdir 和 rewrite。
现在我想提高安全性,但 SuExec 不起作用,也没有发现任何错误。如果我输入/主页/站点测试/public_html/test.php和:
<?php
echo exec('whoami');
?>
它说:
www-data
我该怎么办?Google 搜索没用。
/var/log/apache2/error.log
[Fri Dec 11 21:32:21.918933 2015] [mpm_prefork:notice] [pid 771] AH00169: caught SIGTERM, shutting down
[Fri Dec 11 21:32:28.064683 2015] [suexec:notice] [pid 12374] AH01232: suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Fri Dec 11 21:32:28.126362 2015] [mpm_prefork:notice] [pid 12375] AH00163: Apache/2.4.10 (Debian) configured -- resuming normal operations
[Fri Dec 11 21:32:28.128026 2015] [core:notice] [pid 12375] AH00094: Command line: '/usr/sbin/apache2'
/etc/apache2/apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /home>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/cache/munin/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
/etc/apache2/sites-enabled/sitetest.net.conf
<VirtualHost *:80>
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
</FilesMatch>
ServerName www.sitetest.net
ServerAlias sitetest.net
ServerAdmin [email protected]
DocumentRoot /home/sitetest/public_html
ErrorLog /home/sitetest/logs/error.log
CustomLog /home/sitetest/logs/access.log combined
SuexecUserGroup sitetest sitetest
</VirtualHost>
在/etc/apache2/suexec/www-数据
/home
public_html
/etc/apache2/mods-enabled/userdir.conf
<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options ExecCGI SymLinksIfOwnerMatch
<Limit GET POST OPTIONS>
Require all granted
</Limit>
<LimitExcept GET POST OPTIONS>
Require all denied
</LimitExcept>
</Directory>
</IfModule>