Last active
August 24, 2016 02:39
-
-
Save NewFuture/27b6adeaf558e2456785a55ebc12849a to your computer and use it in GitHub Desktop.
get php env in bash (command line)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP_PATH=${PHP_PATH:=php} | |
#get php version | |
#获取 php 版本 | |
PHP_VERSION=$("$PHP_PATH" -v|grep --only-matching --perl-regexp "\d\.\d+\.\d+"|head -1); | |
php -v|grep -oP "(?<=^PHP\W)\d\.\d\.\d+" | |
#get php.ini path | |
#获取 php.in 位置 | |
PHP_INI=$("$PHP_PATH" --ini|grep --only-matching --perl-regexp "/.*php.ini$"|head -1) | |
#php.ini for all | |
PHP_INI=$("$PHP_PATH" --ini|grep --only-matching --perl-regexp "/.*php.ini$"|head -1|sed -r -e 's/cli/*/') | |
#get PHP extension configure dir like php.d/ or conf.d/ | |
#获取 PHP 扩展配置路径 如 php.d/ or conf.d/ | |
PHP_INI_PATH=$("$PHP_PATH" --ini|grep -m1 --only-matching --perl-regexp "/.*\.d$"|head -1) | |
PHP_INI_PATH=$("$PHP_PATH" --ini|grep -m1 --only-matching --perl-regexp "/.*\.d$"|sed -r -e 's/cli/*/') | |
#check php module is loaded | |
#判断 php modul 是否存在 | |
MODULE_NAME=yaf | |
PHP_MODULE=$("$PHP_PATH" -m|grep -c -w $MODULE_NAME) | |
#get extention lib dir | |
#获取PHP扩展目录 | |
PHP_LIB_PATH=$("$PHP_PATH" -i | grep -o -m1 "^extension_dir.*=>.*=>" | grep -m1 -o -P "(['\"](/+[^/\\\\:*?'\"<>=|\^]*)+/?['\"])|((/+[^/\\\\:*?'\"<>=|\s\^]*)+/?)" | tail -1) | |
"php" -i|grep -oPm1 "(?<=^extension_dir\W=>\W)(.*)(?=\W=>)" | |
"php" -i|grep -oPm1 "(?<=^extension_dir\W=>\W)(['\"]?(/+[^/\\\\:*?'\"<>=|\^]*)+/?['\"]?)(?=\W=>)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment