Get current PHP installation settings

I wanted to get the settings of the currently installed PHP on my server. I do not want to have PHP settings (.ini), I need /configure options, how PHP is installed. For instance. the values --prefix or --includedir or --sysconfdir my current PHP ...

Edit: I know that phpinfo() will output the settings, but there is no Configure Command field with information on my server! How to get this information?

Edit # 2: No one understands what I want to know, or is my answer really so bad that I get so many downvotes? Typical uses for installing PHP are:

 ./configure --prefix=/usr/share/php5\ --with-libdir=lib64\ --includedir=/usr/include\ --enable-libxml\ --enable-session [...] 

I did not install the current PHP5.2 on the server, so I don’t know how it was configured during the installation, and I need / need to know what the settings were for installing PHP5.3, for example, for the current 5.2 there is a high probability that everything my websites will work without problems.

+4
source share
5 answers

You said that your output from phpinfo() / php -i does not contain the Configure Command. Can you post the output of php -i | head -n 10 php -i | head -n 10 ?

EDIT

Based on your comment that says PHP Version => 5.2.4-2ubuntu5.23 , it looks like you are using Ubuntu. I found a list of those versions of Ubuntu that include the PHP version here , which implies that you are using Hardy Heron. I found the details of a specific source package here , and the download date corresponds to the build date that you see on php -i output. Since you are using a 64-bit version of the package, the full Ubuntu compilation can be found here (warning: LONG). Scrolling through this, you can find configure commands for building apache2 on line 1815, collecting cgi on line 6170 and building cli on line 9164. To save you some scrolling, here is the command for building apache2 (i.e. package 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 
+8
source

You can use phpinfo()

phpinfo - displays PHP configuration information

 <?php phpinfo(); ?> 

You can run php -i from the command line and see if you have different results. Although

php -i calls phpinfo () and prints the results,

results may differ from <?php phpinfo() ?> because the command line may have its own php.ini.

+3
source
 <?php phpinfo(); ?> 

The phpinfo() function phpinfo() provide you with all the parameters you are looking for, formatted as HTML.

+3
source

You are looking for the php-config command. Running it will spit out everything that knows about it and how it happens in PHP. In particular, the following flags will tell you about compiling the php binary.

 --prefix Directory prefix where PHP is installed, eg /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 

A command accepts only one flag at a time, so it’s better to run it without flags.

Output Example:

 $ 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] 

If the bit after each Option in the list is not just an example of output, it is the actual value; this is what you get if you call php-config with this option. For instance.

 $ php-config --prefix /usr 
+2
source

Use this to get settings:

 <?php phpinfo(); ?> 
+1
source

Source: https://habr.com/ru/post/1399231/


All Articles