2013-03-20 80 views
0

我已經安裝了前一段時間的Apache和PHP作爲FastCGI模塊open_basedir的用於運行PHP的FastCGI爲

[email protected]# apt-get install apache2 apache2-suexec libapache2-mod-fcgid php5-cgi 

[email protected]# 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 

[email protected]# 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) 

[email protected]# 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" 

在我的情況下,一般的虛擬主機文件:

​​

1)任何想法如何啓用open_basedir一個nd也允許我的用戶更改我在家中定義的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 

下不工作,應給一些參數ETERS:

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" /> 

有什麼想法?

+0

你確定你應該有其他人,因爲用戶在Web服務器上,如果你不知道如何管理/正確配置嗎......? – CBroe 2013-03-20 13:21:17

+0

那麼你有什麼建議?管理是繼承還是國籍? – centurian 2013-03-20 14:09:17

回答

0

與問題相關(2):看來這些指令真正使魔(看到裏面的意見和後)

<VirtualHost *:80> 
ServerName test 
ServerAlias test 
ServerAdmin [email protected] 
DocumentRoot /var/www/users/test/public_html/ 

#the next line should be removed in production 
RewriteLog /var/www/users/test/public_html/rewrite.log 
RewriteLogLevel 9 

<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 

RewriteEngine On 
#next line introduces some behavior, see comment (1) 
#RewriteBase/

#redirect non-existent files or, redirect existent 
#files with the execute bit set, see comment (2) 
RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} -x 

#under the above dir ("/var/www/users/test/public_html/") 
#there is a "php/tests/testApache.php" that catches all requests 
#for non-existent files or for executables, 
#L=last, NC=case-insensitive, NE=no hexcode escaping of the request uri 
#QSA=append query string from the original request uri to the resulted string 
RewriteRule ^/?(.*)$ php/tests/testApache.php?$1 [NC,NE,L,QSA] 

</Directory> 
</IfModule> 

#the next 2 lines should be removed in production 
ErrorLog /var/www/users/test/public_html/error.log 
CustomLog /var/www/users/test/public_html/access.log combined 

ServerSignature Off 

</VirtualHost> 

評論(1):通過調查我們的 「rewrite.log」文件中,我們看到這些差異時刪除,SID,RID領域

[email protected]# diff 1.txt 2.txt 
8,10c8 
< 127.0.0.1 - - [22/Mar/2013: +0200] [test/sid#][rid#/initial] (2) [perdir /var/www/users/test/public_html/] trying to replace prefix 
/var/www/users/test/public_html/ with/
< 127.0.0.1 - - [22/Mar/2013: +0200] [test/sid#][rid#/initial] (5) strip matching prefix: /var/www/users/test/public_html/php/tests/te 
stApache.php -> php/tests/testApache.php 
< 127.0.0.1 - - [22/Mar/2013: +0200] [test/sid#][rid#/initial] (4) add subst prefix: php/tests/testApache.php -> /php/tests/testApache 
.php 
--- 
> 127.0.0.1 - - [22/Mar/2013: +0200] [test/sid#][rid#/initial] (2) [perdir /var/www/users/test/public_html/] strip document_root prefi 
x: /var/www/users/test/public_html/php/tests/testApache.php -> /php/tests/testApache.php 

左部(1.txt的)後,自帶的虛擬主機RewriteBase /

評論(2):通過重定向不存在的文件我們所有的圖像,.css,.js,.htm *文件都按預期工作,只要資源路徑與文檔根目錄相比較虛擬主機是「/ var/www/users/test/public_html /」)。 因此,測試圖像寫的是:

echo '<img src="/wallpaper-10.jpg" alt="Christmas">'; 

,它位於 「/var/www/users/test/public_html/wallpaper-10.jpg」。

仍然在等待問題作出一些迴應(1) ...