Apache-2.2

我們可以在 php.ini 中有 2 個“extension_dir”嗎?

  • September 13, 2012

當我安裝 pdo-pgsql 時,擴展程序已安裝/usr/lib/php/extensions/no-debug-non-zts-20090626/,因此不會自動載入。在php.ini中,我extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"已經定義了。

片段php.ini

; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"
zend_extension = "/usr/local/IonCube/ioncube_loader_lin_5.3.so"
zend_extension = "/usr/local/Zend/lib/Guard-5.5.0/php-5.3.x/ZendGuardLoader.so"
extension = "eaccelerator.so"
extension = "pdo.so"
extension = "pdo_pgsql.so"
extension = "pdo_sqlite.so"
extension = "sqlite.so"
extension = "pdo_mysql.so"

修改為工作

; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20090626"
zend_extension = "/usr/local/IonCube/ioncube_loader_lin_5.3.so"
zend_extension = "/usr/local/Zend/lib/Guard-5.5.0/php-5.3.x/ZendGuardLoader.so"
extension = "eaccelerator.so"
extension = "pdo.so"
extension = "pdo_pgsql.so"
extension = "pdo_sqlite.so"
extension = "sqlite.so"
extension = "pdo_mysql.so"
  1. 為什麼 PECL 將 pdo-pgsql 安裝到第二個擴展目錄而不是第一個?
  2. 是否建議使用 2extension_dir如上面的第二個程式碼片段所示?
  1. 因為它是安裝時的預設位置 via pecl install,而如果您從原始碼編譯 PHP,則擴展路徑應為/usr/local/lib/php/extensions/no-debug-non-zts-20090626.
  2. 據我所知,PHP 不支持 multiple extension_dir,它只選擇最後一個。只需鍵入php -i | grep eaccelerator以查看會發生什麼。

解決方法是將擴展複製到正確的路徑。

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