Php

如何獲取 php.ini 的路徑?

  • July 27, 2011

我的 /etc/php5 路徑中目前有 3 個php.iniS 文件。樹:

./php5_
./php5_/cli
./php5_/cli/conf.d
./php5_/cli/php.ini
./php5_/apache2
./php5_/apache2/conf.d
./php5_/apache2/php.ini
./php5_/conf.d
./php5_/conf.d/suhosin.ini
./php5_/conf.d/mysql.ini
./php5_/conf.d/mysqli.ini
./php5_/conf.d/gd.ini
./php5_/conf.d/pdo.ini
./php5_/conf.d/mcrypt.ini
./php5_/conf.d/curl.ini
./php5_/conf.d/pdo_mysql.ini
./cli
./cli/conf.d
./cli/php.ini
./apache2
./apache2/conf.d
./apache2/php.ini
./conf.d
./conf.d/memcache.ini
./conf.d/suhosin.ini
./conf.d/mysql.ini
./conf.d/mysqli.ini
./conf.d/gd.ini
./conf.d/pdo.ini
./conf.d/mcrypt.ini
./conf.d/memcached.ini
./conf.d/curl.ini
./conf.d/pdo_mysql.ini

但我還是覺得有什麼不對。我試圖在所有 php.ini 文件中出現一些語法錯誤,嘗試重新啟動 apache 並成功重新啟動。怎麼了?如何獲得 REAL php.ini 的路徑,我應該對其進行編輯才能看到更改?

對於 web,創建一個簡單的 php 頁面,該頁面具有以下內容

   <?php
   phpinfo();
   ?>

它將顯示所有已解析的 ini 文件

從您的命令行,只需執行 php –ini:

[sandro@mercury ~]$ php --ini
Configuration File (php.ini) Path: /usr/local/etc
Loaded Configuration File:         /usr/local/etc/php.ini
Scan for additional .ini files in: /usr/local/etc/php
Additional .ini files parsed:      /usr/local/etc/php/extensions.ini

引用自:https://serverfault.com/questions/294581