为什么我的php.ini找不到?

时间:2011-04-08 22:20:29

标签: php

我在已安装php的系统上配置/ make / make install php:

 ./configure --prefix=/opt/php
 --with-config-file-path=/opt/php/etc --with-config-file-scan-dir=/opt/php/etc/php.d
 --enable-fpm --with-fpm-user=ec2-user --with-fpm-group=ec2-user --disable-debug 
 --enable-exif --with-curl --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-
 pdo-mysql=mysqlnd --with-zlib --enable-zip --enable-bcmath --enable-calendar 
 --enable-ftp --with-mhash --with-openssl --with-mcrypt --enable-mbstring --enable-
 mbregex --with-gd --with-jpeg-dir --with-png-dir

(一切都好)然而,当我输入php --ini(在/ opt / php / bin中)时,我得到了旧的东西:

> Configuration File (php.ini) Path:
> /etc Loaded Configuration File:       
> /etc/php.ini Scan for additional .ini
> files in: /etc/php.d Additional .ini
> files parsed:      /etc/php.d/apc.ini,
> /etc/php.d/curl.ini,
> /etc/php.d/fileinfo.ini,
> /etc/php.d/json.ini,
> /etc/php.d/mbstring.ini,
> /etc/php.d/phar.ini,

为什么/我该如何解决这个问题?

我的bashrc:

  

if [-d“/ opt / php / bin”]&& [-d   “/ opt / php / sbin”];然后   PATH = “$路径:/选择/ PHP / bin中:/选择/ PHP / BIN”

我的php-config看起来不错:

Usage: ./php-config [OPTION]
Options:
  --prefix            [/opt/php]
  --includes          [-I/opt/php/include/php -I/opt/php/include/php/main -I/opt/php/include/php/TSRM -I/opt/php/include/php/Zend -I/opt/php/include/php/ext -I/opt/php/include/php/ext/date/lib]
  --ldflags           []
  --libs              [-lcrypt   -lz -lcrypt -lrt -lmcrypt -lltdl -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl  -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt ]
  --extension-dir     [/opt/php/lib/php/extensions/no-debug-non-zts-20090626]
  --include-dir       [/opt/php/include/php]
  --php-binary        [/opt/php/bin/php]
  --php-sapis         [cli fpm]
  --configure-options [--prefix=/opt/php --with-config-file-path=/opt/php/etc --with-config-file-scan-dir=/opt/php/etc/php.d --enable-fpm --with-fpm-user=ec2-user --with-fpm-group=ec2-user --disable-debug --enable-exif --with-curl --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-zip --enable-bcmath --enable-calendar --enable-ftp --with-mhash --with-openssl --with-mcrypt --enable-mbstring --enable-mbregex --with-gd --with-jpeg-dir --with-png-dir]
  --version           [5.3.5]
  --vernum            [50305]

但是... myphp.ini没有,看起来我的--with-config-file-path = PATH(设置查找php.ini的路径,默认为PREFIX / lib。)不知何故不是工作

4 个答案:

答案 0 :(得分:2)

以下是我在类似情况下所做的事情:

<强>上下文 PHP作为Apache模块加载(例如DSO)

总之:
shell ENV

PHP_INI_SCAN_DIR=/pathtophpini
export PHP_INI_SCAN_DIR

的http.conf

# ...
# DSO Modules: PHP as an Apache module
SetEnv PHPRC /usr/pathtophpini
SetEnv PHP_INI_SCAN_DIR /usr/pathtophpini

LoadModule php5_module /pathtophpmod/libphp5.so
PHPINIDir /pathtophpini
# ...

壳牌

/etc/init.d/apache2 restart   

然后我可以选择我想在Apache start加载的php.ini文件。

答案 1 :(得分:2)

PHP request #45114中,jani @ php.com写道:

  

我添加了两种方法来做到这一点。现在你可以在命令行选项中使用-n和-c(-n禁用每个ini加载,-c启用从指定路径加载指定文件)或将PHP_INI_SCAN_DIR环境变量设置为空(禁用扫描)或指向其他一些目录。

示例:

php -n -c /conf -r'phpinfo();'

输出:

...
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /conf/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
...

答案 2 :(得分:1)

尝试命令which -a以查看路径中的哪个php可执行文件。

答案 3 :(得分:0)

我现在有5.3.5。我wget-ed 5.3.6,configure,make,make install ...

并且.ini设置没问题。