Komut satırı ile kullanılan php.ini dosyasını bulmak için nasıl?

11 Cevap php

Ben easyphp ortamda PDO_MYSQL etkinleştirmeniz gerekir, bu yüzden php.ini dosyasına gitti ve aşağıdaki satırı uncommented:

extension=php_pdo_mysql.dll

Unfortunately I still have the same problem. I'm using the CLI so I suppose I need to locate the php.ini file used by the CLI. How can I find it?

11 Cevap

Sen () kullanarak tam bir phpinfo alabilirsiniz:

php -i 

Ve orada, kullanılan php.ini dosyası vardır:

$ php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

Peki, grepping muhtemelen Windows üzerinde çalışmak için gitmiyor, böylece Windows platformları, bu gibi find komutunu kullanabilirsiniz:

php -i | find /i "Configuration File"

Sadece koşmak php --ini

You can use get_cfg_var('cfg_file_path') for that:

To check whether the system is using a configuration file, try retrieving the value of the cfg_file_path configuration setting. If this is available, a configuration file is being used.
Unlike phpinfo() it will tell if it didn't find/use a php.ini at all.

var_dump( get_cfg_var('cfg_file_path') );

Ve sadece php.ini set konum . You're using the command line version, so using the -c parametre, örneğin, yerini specifiy yapabilirsiniz

php -c /home/me/php.ini -f /home/me/test.php

php - ini

Size kullandığı yolu ve olası ini dosya (lar) hakkında tüm detaylar detayları verecektir

Genel dosyaları yapılandırma gelince göründüğü gibi somtimes şeyler her zaman değil. Yani burada ben dosyaları bir işlem tarafından açılmış ne keşfetmek için benim her zamanki yöntemler uyguluyorum.

I strace gerçekten Arkamdan bana neler gösterecek denilen çok güçlü ve yararlı bir komut satırı programı kullanın!

$ strace -o strace.log php --version
$ grep php.ini strace.log

Strace çekirdek (sistemi) program yapar çağırır ve ile-o belirtilen dosyaya çıktı döker kazılar

Bu grep bu günlükte php.ini oluşumlarını aramak için kullanımı kolay. O ne olup bittiğini görmek için aşağıdaki tipik tepkisi bakarak oldukça açıktır.

open("/usr/bin/php.ini", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/etc/php.ini", O_RDONLY)          = 3
lstat("/etc/php.ini", {st_mode=S_IFREG|0644, st_size=69105, ...}) = 0

Tüm yapılandırma dosyaları yüklü istiyorsanız, bu size söyleyecektir edilir:

php -i | grep "\.ini"

Birden fazla ini dosyasındaki bazı sistemler, yük şeyler. Benim ubuntu sistemde, bu gibi görünüyor:

$  php -i | grep "\.ini"
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini,
/etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/mcrypt.ini,
/etc/php5/cli/conf.d/memcache.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini

Run php --ini, terminale, sen ini dosyaları hakkında tüm ayrıntıları alırsınız

[root@tamilan src]# php --ini
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/bcmath.ini,
/etc/php.d/curl.ini,
/etc/php.d/dba.ini,
/etc/php.d/dom.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/gd.ini,
/etc/php.d/imap.ini,
/etc/php.d/json.ini,
/etc/php.d/mbstring.ini,
/etc/php.d/memcache.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/phar.ini,
/etc/php.d/posix.ini,
/etc/php.d/sqlite3.ini,
/etc/php.d/ssh2.ini,
/etc/php.d/sysvmsg.ini,
/etc/php.d/sysvsem.ini,
/etc/php.d/sysvshm.ini,
/etc/php.d/wddx.ini,
/etc/php.d/xmlreader.ini,
/etc/php.d/xmlwriter.ini,
/etc/php.d/xsl.ini,
/etc/php.d/zip.ini

Daha, kullanım yardım komutu için php --help tüm olası seçenekleri gösteririz.

Eğer başka bir uygulama için geçmek için gerekiyorsa, gibi bir şey yapabilirsiniz:

php --ini | grep Loaded | cut -d" " -f12

Sadece yolunu döndürür. php -c $(php --ini | grep Loaded | cut -d" " -f12) (fpm için yararlı) config dosyasında geçecek

Ben EasyPHP kullandığı zaman, php.ini dosyası C:\Windows\ veya C:\Windows\System32 ya hatırlıyorum ne

Php.ini dosyasında uzantı dizini, örneğin ayarlayın:

extension_dir = "C:/php/ext/"

Eğer PHP bir klasördeki tüm dll ve uzantıları ile bir dahili klasör olduğunu göreceksiniz.

Komut satırı ile kullanılan hiçbir php.ini yoktur. Sen ...EasyPHP-<<version>>\php\php.ini php dizininde birini düzenlemek için daha ...EasyPHP-<<version>>\apache\php.ini adlı dosyayı kopyalamak zorunda

Referans: