PHP

The PHP programming language (PHP standing for PHP: Hypertext Preprocessor) is an interpretted language designed for dynamic web pages.

The interpretter is called with php(1).

The current version is 8, but older (unsupported) versions see continued use. The language has evolved rapidly and porting between versions can be a difficult task.


Example

<?php echo 'Hello, World!';

Embedded Example

php(1) can be embedded into web pages, if the web server supports it.

<!DOCTYPE html>
<html>
  <head>
    <title>PHP "Hello, World!" program</title>
    </head>
    <body>
    <?php
       echo '<p>Hello, World!</p>';
    ?>
  </body>
</html>


Installation

Most Linux and BSD distributions offer a php package, as well as versioned packages (like php7).


Configuration

See here for details.

Logging PHP

To log a php(1) process, configure /etc/php/php.ini with:

display_errors = off
log_errors = on
error_log = "/var/log/php.log"

Some notable settings and their default values:

Logging PHP-FPM

To log a pgp-fpm(8) pool, configure /etc/php/php.fpm.d/$pool.conf with:

[www]
access.format = "[%t] %m %{REQUEST_SCHEME}e://%{HTTP_HOST}e%{REQUEST_URI}e %f%Q%q (status=%s)"
access.log = /usr/local/var/log/$pool.log

Note that log_level is set in php-fpm.conf.

log_level = debug

To log php(1) processes differently for each php-fpm(8) pool, try:

[www]
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /var/log/php-$pool.log


Applications and Servers


See also

PHP Manual, the language reference manual

php(1)


CategoryRicottone

PHP (last edited 2023-04-08 17:02:03 by DominicRicottone)