Dump PHP/Apache Environment Information

Provides a tutorial example on how to dump Apache/PHP environment information on CentOS Linux systems.

The execution environment of running PHP scripts on the Apache Web server is different than running them from the command line. You need to dump the Apache/PHP environment information as shown in this tutorial.

1. Publish the following script file, test_phpinfo.php, to the Apache Web server directory, /var/www/html/test:

<?php phpinfo(); ?>

2. View the script file as a Web page, http://localhost/test/test_phpinfo.php in a Web browser. You should see the Apache/PHP environment information displayed in a nice format.

HP Version 7.2.11

System  =>  Linux 4.18.0-147.el8.x86_64 #1 SMP Wed Dec 4 21:51:45 UTC 2019
Build Date  =>  10/09/18 03:09 PM
Server API  =>  FPM/FastCGI
Virtual Directory Support  =>  disabled
Configuration File (php.ini) Path  =>  /etc
Loaded Configuration File  =>  /etc/php.ini
Scan this dir for additional .ini files  =>  /etc/php.d
Additional .ini files parsed  =>  /etc/php.d/20-bz2.ini, ...
..

Directive  =>  Local Value  active    Master Value

cgi-fcgi

php-fpm  => active
cgi.discard_path  =>  0  =>  0
cgi.fix_pathinfo  =>  1  =>  1
cgi.force_redirect  =>  1  =>  1
cgi.nph  =>  0  =>  0
cgi.redirect_status_env  =>  no value  =>  no value
cgi.rfc2616_headers  =>  0  =>  0
fastcgi.error_header  =>  no value  =>  no value
fastcgi.logging  =>  1  =>  1

Core

allow_url_fopen  =>  On  =>  On
allow_url_include  =>  Off  =>  Off
...
error_log  =>  /var/log/php-fpm/www-error.log  =>  ...
extension_dir  =>  /usr/lib64/php/modules  =>  /usr/lib64/php/modules

...

Now I know where to go find the Apache/PHP error log file:

centos$ sudo ls -l /var/log/php-fpm/

-rw-------. 1 root   root      56 Apr  5 03:06 error.log
-rw-------. 1 root   root    1036 Mar 26 23:00 error.log-20200329
-rw-------. 1 root   root      56 Mar 29 03:45 error.log-20200405
-rw-r--r--. 1 apache apache 15063 Apr  7 05:26 www-error.log
-rw-r--r--. 1 apache apache 36055 Mar 29 03:24 www-error.log-20200329
-rw-r--r--. 1 apache apache 99278 Apr  4 07:36 www-error.log-20200405

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Software Package Manager on CentOS - DNF and YUM

 Running Apache Web Server (httpd) on Linux Systems

Running PHP Scripts on Linux Systems

 Install and Manage PHP Packages on CentOS

 "php -i" - Dump PHP Environment Information

 Install and Manage PHP Modules on CentOS

 Files Used in PHP "include" Statements

 Publish PHP Scripts on Apache Web Server

Dump PHP/Apache Environment Information

 Change PHP Configuration Settings

 Apache PHP file_put_contents() Permission Denied

 SELinux Security Context on /var/www/html

 Migrate Old Scripts to New PHP Release

 Running MySQL Database Server on Linux Systems

 Running Python Scripts on Linux Systems

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 LDAP (Lightweight Directory Access Protocol)

 GCC - C/C++ Compiler

 Graphics Environments on Linux

 Conda - Environment and Package Manager

 Tools and Utilities

 Administrative Tasks

 References

 Full Version in PDF/EPUB