我前段时间安装了 Apache 和 php 作为 fastcgi 模块
root@company# apt-get install apache2 apache2-suexec libapache2-mod-fcgid php5-cgi
root@company# dpkg-query -l '*apache2*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============================-==============================-============================================================================
ii apache2 2.2.20-1ubuntu1.2 Apache HTTP Server metapackage
ii apache2-mpm-worker 2.2.20-1ubuntu1.2 Apache HTTP Server - high speed threaded model
ii apache2-suexec 2.2.20-1ubuntu1.2 Standard suexec program for Apache 2 mod_suexec
ii apache2-utils 2.2.20-1ubuntu1.2 utility programs for webservers
ii apache2.2-bin 2.2.20-1ubuntu1.2 Apache HTTP Server common binary files
ii apache2.2-common 2.2.20-1ubuntu1.2 Apache HTTP Server common files
ii libapache2-mod-fcgid 1:2.3.6-1+squeeze1build0.11.10 an alternative module compat with mod_fastcgi
root@company# dpkg-query -l '*php*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=================================-=================================-==================================================================================
un php-pear <none> (no description available)
ii php5-cgi 5.3.6-13ubuntu3.7 server-side, HTML-embedded scripting language (CGI binary)
ii php5-common 5.3.6-13ubuntu3.7 Common files for packages built from the php5 source
un php5-json <none> (no description available)
un php5-mhash <none> (no description available)
un php5-suhosin <none> (no description available)
un phpapi-20090626 <none> (no description available)
root@company# dpkg-query -l '*fcgi*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=================================-=================================-==================================================================================
ii libapache2-mod-fcgid 1:2.3.6-1+squeeze1build0.11.10.1 an alternative module compat with mod_fastcgi
现在,我知道我不能在我的虚拟主机中使用这个命令:
php_admin_value open_basedir "/var/www/users/test"
在我的例子中,一个典型的虚拟主机文件:
<VirtualHost *:80>
ServerName test
ServerAlias test
ServerAdmin webmaster@test.com
DocumentRoot /var/www/users/test/public_html/
<IfModule mod_fcgid.c>
SuexecUserGroup test test
<Directory /var/www/users/test/public_html/>
Options +ExecCGI
Options -Indexes
AllowOverride None
AddHandler fcgid-script .php
FCGIWrapper /var/www/system/test/php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
</IfModule>
# ErrorLog /var/log/apache2/error.log
# CustomLog /var/log/apache2/access.log combined
ServerSignature Off
</VirtualHost>
1)关于如何启用open_basedir
并允许我的用户更改php.ini
我在他们家中定义的任何想法(例如/var/www/users/test
)。用户即使尝试编辑也不应该更改我的值php.ini
。
这可能吗?或者,我应该忘记php.ini
所有用户的用户访问权限并一次性更改他的php.ini
?(我可以通过简单地重新定位它来做到这一点 - 如您所知,在这样的设置中有一个 fcgid 包装脚本)
2)如果有人也可以给我一些 Apache2 指令来重定向所有请求,我将不胜感激:
http://www.test.com/a/new/post
在内部对此:
http://www.test.com/index.php?a/new/post
以下不起作用 - 应该给出一些参数:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
(不,出于速度的原因,我不想允许 .htaccess 文件)
谢谢!
对问题 (2) 的评论:我注意到该<Directory>
部分中的这个指令实现了我所需要的:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?$1 [NC,L,QSA]
但是在(未显示)呈现php图像时表现得很奇怪
<?php
phpinfo();
?>
回显文件中此图像的链接是
<img border="0" src="/info.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42" alt="PHP Logo" />
有任何想法吗?