Press "Enter" to skip to content

查看php版本/配置文件路径/编译参数

查看php版本:
[root@test etc]# php -v
PHP 7.2.5 (cli) (built: Jun 1 2018 11:10:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

查看php配置文件路径:
通常php.ini的位置在:
/etc目录下或/usr/local/lib目录下.
如果你还是找不到php.ini或者找到了php.ini修改后不生效(其实是没找对),请使用如下办法:
1.新建php文件,写入如下代码
<?php
echo phpinfo();
?>
然后在浏览器访问该页面,搜索php.ini.利用了phpinfo函数中的环境变量结果.
2.执行(需要修改php为你自己的路径)/usr/local/php/bin/php --ini
会显示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/curl.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/json.ini,
/etc/php.d/phar.ini,
/etc/php.d/zip.ini
可以在编译的时候使用--with-config-file-path参数来修改php.ini的存放位置,例如,你可以使用--with-config-file-path=/etc把php.ini存放到/etc下面.
3.[root@test ~]# php -i |grep -i configuration
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Configuration

查看php编译参数:
[root@test etc]# php -i |grep configure
Configure Command => './configure' '--prefix=/www/server/php/72' '--with-config-file-path=/www/server/php/72/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--enable-mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl=/usr/local/curl' '--enable-mbregex' '--enable-mbstring' '--enable-intl' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl=/usr/local/openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-opcache'

Be First to Comment

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注