首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >作为FastCGI运行的php的FastCGI

作为FastCGI运行的php的FastCGI
EN

Stack Overflow用户
提问于 2013-03-20 12:42:25
回答 1查看 2K关注 0票数 2

不久前,我已经将Apache和php安装为一个快速ago模块。

代码语言:javascript
复制
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

现在,我意识到我不能在虚拟主机中使用这个命令:

代码语言:javascript
复制
php_admin_value open_basedir "/var/www/users/test"

在我的例子中,一个典型的虚拟主机文件:

代码语言:javascript
复制
<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指令,重定向来自以下方面的所有请求,我将不胜感激:

代码语言:javascript
复制
http://www.test.com/a/new/post

对此,内部:

代码语言:javascript
复制
http://www.test.com/index.php?a/new/post

以下内容不起作用-应提供一些参数:

代码语言:javascript
复制
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>部分中的这个指令达到了我所需的目的:

代码语言:javascript
复制
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?$1 [NC,L,QSA]

但是,呈现php图像的行为很奇怪(未显示)。

代码语言:javascript
复制
<?php
phpinfo();
?>

此图像在回显文件中的链接为

代码语言:javascript
复制
<img border="0" src="/info.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42" alt="PHP Logo" />

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2013-03-22 15:37:14

与问题(2)相关的看起来这些指令确实是神奇的(请参阅内部和后面的注释)

代码语言:javascript
复制
<VirtualHost *:80>
 ServerName test
 ServerAlias test
 ServerAdmin webmaster@test.com
 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字段后看到了这些差异

代码语言:javascript
复制
root@localhost# 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/user/test/public_html/”),就可以正常工作。因此,编写了一个测试映像:

代码语言:javascript
复制
echo '<img src="/wallpaper-10.jpg" alt="Christmas">';

它位于"/var/www/users/test/public_html/wallpaper-10.jpg".

还在等待关于问题(1).

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15523860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档