如何在CGI模式下运行时重写PHP配置 [英] How to override PHP configuration when running in CGI mode
问题描述
有一些教程在那里,告诉我如何当它在CGI模式下运行PHP覆盖配置。但我仍然感到困惑,因为他们很多假设服务器运行在Linux上。虽然我需要做的同时在Windows上。
我的主机确实使用Linux,但我的本地开发计算机使用的是Windows XP且Xampp 1.7.3。所以,我需要做的,在我的本地计算机上的第一,那么我想改变托管服务器的配置。
在我的托管服务器的PHP已经在运行的CGI,而在我的本地计算机上运行还是作为Apache模块。
在这一点上,我了解流程是:
-
更改PHP在CGI模式下工作。我在的httpd-xampp.conf注释这两行这样做:
#的LoadFileC:/xampp/php/php5ts.dll
#的LoadModule php5_module模块/ php5apache2_2.dll
块引用> -
我的PHP现在正在运行的CGI。我查了一下这个用phpinfo()函数。它告诉我,服务器API现在CGI / FastCGI的。现在,我想重写PHP配置。
-
创建的DocumentRoot的cgi-bin目录中。我的DocumentRoot是在D:\\ WWW \\(我使用的是虚拟主机的Apache)。所以,现在是D:\\ WWW \\ cgi-bin目录。
-
更改默认的的cgi-bin目录设置
的ScriptAlias / cgi-bin目录/D:/网络/ cgi-bin目录/
<目录D:\\ WWW \\ cgi-bin目录>
多视图选项索引SymLinksIfOwnerMatch包括ExecCGI
所有的AllowOverride
从所有允许
< /目录>
块引用> -
复制的php.ini文件D:\\ WWW \\ cgi-bin目录和修改的upload_max_filesize从128M设置为10M
。 -
创建'php.cgi'文件D:\\ WWW \\ cgi-bin目录,并把这些code里面的文件:
#!/ bin / sh的
的/ usr /本地/的cPanel / CGI-SYS / PHP5 -c / home / user中/的public_html / cgi-bin目录/
块引用>
:/ XAMPP / cgi-bin目录/ C到D:\\ WWW \\ cgi-bin目录:从
就是这样。我被困在这一点上。所有的教程告诉我,创造'php.cgi文件,并把壳code里面的文件。
怎么做Windows上的第6步?我知道下一个步骤是创建在.htaccess文件处理程序来加载php.cgi。
和也,因为我还需要改变我的托管服务器(Linux)的PHP的配置,是右上第6步?一些教程告诉插入这些行而不是上面:
#!/ bin / sh的
出口PHPRC = /网站/ INI / 1
EXEC /cgi-bin/php5.cgi
我很抱歉,如果我的问题不明确。我是一名新成员,这是我在这个网站的第一个问题。
感谢您。
如果您的服务器已经在运行PHP的CGI,你并不需要运行多个PHP配置,步骤5和6是没有必要的。只要改变默认的php.ini
There are some tutorials out there telling me how to override PHP configuration when it is running in CGI mode. But I'm still confused because lots of them assume that the server is running on Linux. While I need to do that also on Windows.
My hosting is indeed using Linux but my local development computer is using Windows XP with Xampp 1.7.3. So I need to do that in my local computer first, then I want to change the configuration on hosting server.
The PHP in my hosting server is already run as CGI while in my local computer still run as Apache module.
At this point, the processes that I understand are:
Change PHP to work in CGI mode. I did this by commenting these two line in "httpd-xampp.conf":
# LoadFile "C:/xampp/php/php5ts.dll"
# LoadModule php5_module modules/php5apache2_2.dll
My PHP is now running as CGI. I checked this with phpinfo(). It tells me that the Server API is now CGI/FastCGI. Now I want to override php configuration.
Create "cgi-bin" directory in DocumentRoot. My DocumentRoot is in "D:\www\" (I'm using apache with virtual host). So it is now "D:\www\cgi-bin".
Change the default "cgi-bin" directory settings from "C:/xampp/cgi-bin/" to "D:\www\cgi-bin":
ScriptAlias /cgi-bin/ "D:/www/cgi-bin/"
<Directory "D:\www\cgi-bin"> Options MultiViews Indexes SymLinksIfOwnerMatch Includes ExecCGI AllowOverride All Allow from All </Directory>
Copy 'php.ini' file to "D:\www\cgi-bin" and modify upload_max_filesize setting from 128M to 10M.
Create 'php.cgi' file in "D:\www\cgi-bin" and put these code inside the file:
#!/bin/sh
/usr/local/cpanel/cgi-sys/php5 -c /home/user/public_html/cgi-bin/
That's it. I'm stuck at this point. All of tutorials tell me to create 'php.cgi' file and put shell code inside the file.
How to do the 6th step on Windows? I know the next step is to create handler in .htaccess file to load that 'php.cgi'.
And also, because I will also need to change PHP configuration on my hosting server (Linux), is the 6th step above right? Some tutorial tells to insert these lines instead of above:
#!/bin/sh
export PHPRC=/site/ini/1
exec /cgi-bin/php5.cgi
I'm sorry if my question is not clear. I'm a new member and this is my first question in this site.
Thank you.
If your server is already running PHP as cgi, and you do not need to run multiple PHP configurations, steps 5 and 6 are not necessary. Just change the default php.ini
这篇关于如何在CGI模式下运行时重写PHP配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!