2011-04-08 143 views
1

我配置/讓/使PHP在哪裏已經安裝在系統上安裝PHP:爲什麼我的php.ini找不到?

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

(一切OK),但是,當我輸入PHP --ini(內部的/ opt/PHP /箱),我得到舊東西:

> 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:

如果[-d 「/選擇/ PHP/BIN」] & & [-d 「/選擇/ PHP/sbin目錄」];然後 PATH = 「$ PATH中:/ opt/PHP /斌:/選擇/ PHP/BIN」

我的PHP配置看起來不錯:

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。)莫名其妙地不工作?

+2

是否在'/選擇/ PHP的輸入'./php --ini'/bin'改變什麼? – Felix 2011-04-08 22:23:58

+1

@Felix可能是對的。 'php'和'。/ php'是兩個不同的東西。 'php'取得$ PATH中的一個(可能是/ usr/bin/php),而'。/ php'取得了cwd中的那個。 – netcoder 2011-04-08 22:28:01

+0

是的...它顯示了另一箇舊的位置...../usr/local/lib ...雖然php的時間是我建立它的時間(我改變並導出了bashrc路徑 – edelwater 2011-04-08 22:29:05

回答

0

我現在有5.3.5。我wget-ed 5.3.6,配置,使,使安裝...

和.ini設置是好的。

+1

這是否意味着它現在正在工作?如果更改ini位置通過配置後,你已經建立了一次,我認爲你必須做一個'make clean && make'爲了它得到更新。 – Matthew 2011-04-09 07:55:09

+0

它不完全工作...但我想我現在有另一個thingie「無法全球化「但是這個問題已經超出了範圍,是的......讓我忘了做乾淨的事情吧。 – edelwater 2011-04-09 08:10:27

1

嘗試使用命令which -a查看哪個php可執行文件位於路徑中。

+0

/usr/bin/php /opt/php/bin/php 刪除第一個對我沒有好處 – edelwater 2011-04-08 22:36:20

+0

和./php-config顯示我正確的前綴,包括等等。 – edelwater 2011-04-08 22:51:38

2

以下是我在類似情況下所做的:

語境: PHP加載作爲Apache模塊(例如DSO)

HOW簡稱:
殼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 

然後我可以選擇php.ini文件我想獲得Apache的啓動加載。

2

PHP request #45114[email protected]寫道:

我加了2種方法來做到這一點。現在,您可以在命令行選項中同時使用-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) 
...