获取当前的PHP安装设置

Por*_*oru 8 php install

我想在我的服务器上获取当前安装的PHP的设置.我不想拥有PHP(.ini)本身的设置,我需要/configurePHP当前安装的参数.例如我当前PHP 的值--prefix或者--includedir或者--sysconfdir是...

编辑:我知道phpinfo()将输出设置但在我的服务器上不是Configure Command包含信息的字段!我如何获得这些信息?

编辑#2:没有人理解我想知道什么,或者我的答案真的很糟糕,我得到了这么多的投票?安装PHP的常见用法是:

./configure --prefix=/usr/share/php5\
 --with-libdir=lib64\
 --includedir=/usr/include\
 --enable-libxml\
 --enable-session
[...]
Run Code Online (Sandbox Code Playgroud)

我没有在服务器上安装当前的PHP5.2,所以我不知道它在安装过程中是如何配置的,我需要/想知道安装PHP5.3的设置是什么,就像当前的5.2有很高的机会让我的所有网站都没有任何问题.

nic*_*rim 9

您已经说过phpinfo()/ 你的输出php -i没有配置命令部分.你可以发布输出php -i | head -n 10吗?

编辑:

根据您所说的评论PHP Version => 5.2.4-2ubuntu5.23,您似乎正在运行Ubuntu.我发现这个名单,其中的Ubuntu版本包括PHP的版本在这里,这意味着你正在运行的哈苍鹭.我在这里找到了特定源包的详细信息,上传日期对应于您在输出中看到的构建日期php -i.由于您运行的是64位版本的软件包,因此可以在此处找到完整的Ubuntu构建日志(警告:LONG).滚动浏览,您可以configure在第1815行找到apache2构建的命令,第6170行的cgi构建和第916行的cli构建.为了节省一些滚动,这里是apache2构建的命令(即包libapache2-mod-php5):

    CFLAGS="-O2 -Wall -fsigned-char -fno-strict-aliasing   -gstabs" PROG_SENDMAIL="/usr/sbin/sendmail" ../configure \
    --prefix=/usr --with-apxs2=/usr/bin/apxs2 \
    --with-config-file-path=/etc/php5/apache2 \
    --with-config-file-scan-dir=/etc/php5/apache2/conf.d \
    --build=x86_64-linux-gnu --host=x86_64-linux-gnu --mandir=/usr/share/man --enable-memory-limit --disable-debug --with-regex=php --disable-rpath --disable-static --with-pic --with-layout=GNU --with-pear=/usr/share/php --enable-calendar --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-track-vars --enable-trans-sid --enable-bcmath --with-bz2 --enable-ctype --with-db4 --without-gdbm --with-iconv --enable-exif --enable-filepro --enable-ftp --with-gettext --enable-mbstring --with-pcre-regex=/usr --enable-shmop --enable-sockets --enable-wddx --with-libxml-dir=/usr --with-zlib --with-kerberos=/usr --with-openssl=/usr --enable-dbx --enable-soap --enable-zip --with-mime-magic=/usr/share/file/magic.mime --with-exec-dir=/usr/lib/php5/libexec --with-system-tzdata \
    --without-mm \
    --with-curl=shared,/usr \
    --with-zlib-dir=/usr \
    --with-gd=shared,/usr --enable-gd-native-ttf \
    --with-gmp=shared,/usr \
    --with-jpeg-dir=shared,/usr \
    --with-xpm-dir=shared,/usr/X11R6 \
    --with-png-dir=shared,/usr \
    --with-freetype-dir=shared,/usr \
    --with-ttf=shared,/usr \
    --with-t1lib=shared,/usr \
    --with-ldap=shared,/usr \
    --with-ldap-sasl=/usr \
    --with-mhash=shared,/usr \
    --with-mysql=shared,/usr \
    --with-mysqli=shared,/usr/bin/mysql_config \
    --with-pspell=shared,/usr \
    --with-unixODBC=shared,/usr \
    --with-recode=shared,/usr \
    --with-xsl=shared,/usr \
    --with-snmp=shared,/usr \
    --with-sqlite=shared,/usr \
    --with-mssql=shared,/usr \
    --with-tidy=shared,/usr \
    --with-xmlrpc=shared \
    --with-pgsql=shared,/usr PGSQL_INCLUDE=`pg_config --includedir` \
    --enable-pdo=shared \
    --without-pdo-dblib \
    --with-pdo-mysql=shared,/usr \
    --with-pdo-odbc=shared,unixODBC,/usr \
    --with-pdo-pgsql=shared,/usr/bin/pg_config \
    --with-pdo-sqlite=shared,/usr \
    --with-pdo-dblib=shared,/usr
Run Code Online (Sandbox Code Playgroud)

  • 您正在寻找"php-config"命令. (3认同)

Mar*_*ner 8

您正在寻找php-config命令。运行此命令将吐出PHP有关安装和创建的所有信息。具体来说,以下标志将告诉您有关php二进制文件的编译。

--prefix  Directory prefix where PHP is installed, e.g. /usr/local

--ldflags LD Flags which PHP was compiled with

--libs    Extra libraries which PHP was compiled with

--configure-options   Configure options to recreate configuration of current 
          PHP installation
Run Code Online (Sandbox Code Playgroud)

该命令一次只接受一个标志,因此最好不带标志运行它。

输出示例:

$ php-config
Usage: /usr/bin/php-config [OPTION]
Options:
  --prefix            [/usr]
  --includes          [-I/usr/include/php ...snip ]
  --ldflags           []
  --libs              [-lcrypt   -lresolv -lcrypt ...snip ]
  --extension-dir     [/usr/lib64/php/modules]
  --include-dir       [/usr/include/php]
  --man-dir           [/usr/share/man]
  --php-binary        [/usr/bin/php]
  --php-sapis         [cli cgi]
  --configure-options [--build=x86_64-redhat-linux-gnu --host= ...snip]
  --version           [5.3.29]
  --vernum            [50329]
Run Code Online (Sandbox Code Playgroud)

Option列表中每一个后面的位不只是示例输出,它是实际值;如果您php-config使用该选项打电话,这就是您得到的。例如

$ php-config --prefix
/usr
Run Code Online (Sandbox Code Playgroud)