你如何创build单独的configuration文件mod_php在Apache和命令行PHP?

我正在看ubuntu设置为Apache(mod_php)和php cli的php。 他们在/etc/php5/apache2/php.ini中有一个configurationini,其中包含apache + php的设置和另一个configurationini的/etc/php5/cli/php.ini(用于php cli)。 如何复制这些设置? 我在rhel环境下编译php

当你编译php时,你需要编译两次。 所以你可以做的是首先检查你的PHP信息的mod_php和比你的cli。 他们可能编译不同。 <?php print phpinfo();?>会给你mod_php的configuration命令。 一个简单的php -i为你的cli版本会给你你的cli config命令。 这是确认你现在正在使用的最好的方法,实际上是你将要编译的。

所以对于mod_php,你可以使用: ./configure <more-configs-here> --prefix=/some/prefix/dir --with-apxs2=/path/to/your/apache --disable-cli --disable-cgi --with-config-file-path=/etc/php5/apache2

for php cli: ./configure <more-configs-here> --prefix=/some/prefix/dir --with-config-file-path=/etc/php5/cli

在configuration你的cli时,不要configurationapxs2。

当然, make && make install或任何你需要做的最后。

这些值在编译时被硬编码。 在Debian / Ubuntu软件包中,这些path似乎是通过作为打包过程的一部分而应用的patches/006-debian_quirks.patch修补patches/006-debian_quirks.patch进行修改的。 特别是这个补丁的片段。

 --- php5.orig/sapi/cli/php.1.in +++ php5/sapi/cli/php.1.in @@ -374,13 +374,14 @@ Shows configuration for extension Show configuration file names .SH FILES .TP 15 -.B php\-cli.ini +.B /etc/php5/cli/php.ini The configuration file for the CLI version of PHP. .TP -.B php.ini -The standard configuration file will only be used when -.B php\-cli.ini -cannot be found. +.B /etc/php5/cgi/php.ini +The configuration file for the CGI version of PHP. +.TP +.B /etc/php5/apache2/php.ini +The configuration file for the version of PHP that apache2 uses. .SH EXAMPLES .TP 5 \fIphp \-r 'echo "Hello World\\n";'\fP 

在Debian / Ubuntu系统上,执行一个apt-get source php5 ,以获取源代码包,其中将包含所有的构build脚本和所使用的修补程序。 请务必查看脚本,可能会有更多与此相关的configuration,我没有看到一个快速的grep。

@Zoredache的答案是正确的。

缺less的信息是“如何应用这些path?

假设您在Debian 7中获得PHP的源码包

  apt-get source php5 #then cd php5-5.4.41 

所有进一步的步骤都假设你在这个目录下。

在这个目录下,你可以find“debian”子目录 ,其中包含一个“debian / patches”目录,其中包含debian应用于原始源的补丁。

  ls debian/patches # gives files ending with .patch # we need debian/patches/0004-006-debian_quirks.patch # found via grep -Ri 'php5/cli/php.ini' * 

我们将使用名为“quilt”的工具创build一个适合此层次结构的修补程序:

 apt-get install quilt 

被子补丁系统pipe理一系列补丁到原始源。 然后我们应用包中包含的所有修补程序。

  export QUILT_PATCHES=debian/patches quilt push -a 

如果你想应用它只是为了php.ini的位置,例如PHP 5.3的源码,你可以尝试删除debian / patches /除了0004-006-debian_quirks.patch之外的所有文件,然后在PHP中移动它5.3文件夹。