源码编译安装php怎么获取这2个值呢?

hphper 发布于 2016/01/12 23:03
阅读 231
收藏 0

一个是php的扩展目录,就是 extension_dir,配置文件也没写啊,都是注释掉的,默认是哪个怎么知道呢

难道要用cli方式 通过 ini_get("extension_dir");获取吗?

还有一个是怎么获取ini的其它目录就是

图中标红的目录

如果是编译安装,比如我php安装在/usr/local/下

怎么知道要弄一份php.ini放在 /usr/local/php/lib/ 下呢,我从网上搜是要这么放,但这些信息最初怎么获取的呢?求解,谢谢



加载中
0
eechen
eechen
./configure --help 可见:
假设你没有配置下面两项:
--with-config-file-path=PATH
Set the path in which to look for php.ini [PREFIX/lib]
--with-config-file-scan-dir=PATH
Set the path where to scan for configuration files
假设我配置了--prefix=/png/php/5.4.45,
则phpinfo()中的默认值为:
Configuration File (php.ini) Path 为 /png/php/5.4.45/lib
Scan this dir for additional .ini files 为 (none)

Linux上查看PHP默认读取的配置文件
执行下列命令可见:
strace -f -o strace.log \
/png/php/5.4.45/bin/php -v && \
cat strace.log|egrep 'open|read'|grep 'ini'
3080  open("/png/php/5.4.45/bin/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
3080  open("/png/php/5.4.45/lib/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
3080  open("/png/php/5.4.45/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
3080  open("/png/php/5.4.45/lib/php.ini", O_RDONLY) = 3
可见PHP会优先读取php程序所在目录下的php-cli.ini,访问到则不再读取其他ini文件.

PHP-FPM情况如下:
strace -f -o strace.log \
/png/php/5.4.45/sbin/php-fpm -v && \
cat strace.log|egrep 'open|read'|grep 'ini'
3537  open("/png/php/5.4.45/lib/php-fpm-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
3537  open("/png/php/5.4.45/lib/php.ini", O_RDONLY) = 3

PHP-CGI情况如下:
strace -f -o strace.log \
/png/php/5.4.45/bin/php-cgi -v && \
cat strace.log|egrep 'open|read'|grep 'ini'
3568  open("./php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
3568  open("/png/php/5.4.45/bin/php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
3568  open("/png/php/5.4.45/lib/php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
3568  open("./php.ini", O_RDONLY)       = -1 ENOENT (No such file or directory)
3568  open("/png/php/5.4.45/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
3568  open("/png/php/5.4.45/lib/php.ini", O_RDONLY) = 3
hphper
hphper
多谢
0
hylent
hylent

./configure --help | less

慢慢看

hphper
hphper
谢谢!
返回顶部
顶部