Skip to content

Commit

Permalink
Updates to PHP8 and closes #5, adds Xdebug v3 and closes #4
Browse files Browse the repository at this point in the history
Signed-off-by: ojullien <[email protected]>
  • Loading branch information
ojullien committed Feb 28, 2021
1 parent 96c82c9 commit ffffe7b
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 117 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Pull requests are the best way to propose changes to the codebase. There are war

## Bug and fix

If you encounter any **bugs**, please open an [issue](https://github.com/ojullien/php7.x-fpm/issues/new).
If you encounter any **bugs**, please open an [issue](https://github.com/ojullien/php-fpm/issues/new).

**Great Bug Reports** tend to have:

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Olivier Jullien
Copyright (c) 2021 Olivier Jullien

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
47 changes: 22 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
# PHP7.x-FPM configuration and pool templates
# PHP-FPM configuration and pool templates

PHP 7.x FPM personnal configuration and pool templates on Debian linux distribution.
PHP-FPM personnal configuration and pool templates on Debian linux distribution.

*Note: I use this package for my own projects, it contains only the features I need.*

## Table of Contents

- [Requirements](#requirements)
- [Configuration](#configuration)
- [Pools](#pools)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)
[Requirements](#requirements) | [Configuration](#configuration) | [Pools](#pools) | [Documentation](#documentation) | [Contributing](#contributing) | [License](#license)

## Requirements

- Debian linux distribution: ~9.5
- PHP-FPM: ~7.2
- Debian linux distribution: ~10.0
- PHP-FPM: ~8.0

## Configuration

I do not modify any PHP configuration files. I just add new configuration files to override the default PHP configuration.

PHP includes a central configuration file `/etc/php/7.x/fpm/php.ini` and, then, the particular configuration snippets (`/etc/php/7.x/fpm/conf.d/*.ini`) which manage the modules.
PHP includes a central configuration file `/etc/php/8.x/fpm/php.ini` and, then, the particular configuration snippets (`/etc/php/8.x/fpm/conf.d/*.ini`) which manage the modules.

PHP-FPM uses a central configuration file `/etc/php/7.x/fpm/php-fpm.ini` and configures the pools using conf files located in `/etc/php/7.x/fpm/pool.d/`
PHP-FPM uses a central configuration file `/etc/php/8.x/fpm/php-fpm.ini` and configures the pools using conf files located in `/etc/php/8.x/fpm/pool.d/`

Log directory is `/var/log/php/`

### Files

Expand All @@ -33,7 +30,7 @@ PHP-FPM uses a central configuration file `/etc/php/7.x/fpm/php-fpm.ini` and con

### How to setup the PHP personnal configuration

1. Copy the configuration [files](/src/mods-available) into `/etc/php/7.x/mods-available/`
1. Copy the configuration [files](/src/mods-available) into `/etc/php/8.x/mods-available/`
2. Edit the named like zzz-***.ini files and make changes as you need.
3. Enable the configuration you need using `phpenmod zzz-***`
4. Review your settings using `php -i`
Expand All @@ -56,18 +53,18 @@ Each pool runs under is own user/group process (see [adduser](https://manpages.d

### How to setup the pools

*Note: replace x by the minor version of PHP. Ex: php-fpm7.x -t becomes php-fpm7.2 -t*
*Note: replace x by the minor version of PHP. Ex: php-fpm8.x --test becomes php-fpm8.0 --test*

1. Copy all the [files and directories](/src/fpm) into /etc/php/7.x/fpm
2. Move the default pool from `/etc/php/7.x/fpm/pool.d/www.conf` to `/etc/php/7.x/fpm/conf-available/www.conf`
3. Make executable the `phpdisconf.sh` script file using `chmod u+x /etc/php/7.x/fpm/phpdisconf.sh`
4. Make executable the `phpenconf.sh` script file using `chmod u+x /etc/php/7.x/fpm/phpenconf.sh`
5. Edit the FPM configuration file (`/etc/php/7.x/fpm/conf-available/10-php-fpm.conf`) and make changes as you need.
1. Copy all the [files and directories](/src/fpm) into /etc/php/8.x/fpm
2. Move the default pool from `/etc/php/8.x/fpm/pool.d/www.conf` to `/etc/php/8.x/fpm/conf-available/www.conf`
3. Make executable the `phpdisconf.sh` script file using `chmod u+x /etc/php/8.x/fpm/phpdisconf.sh`
4. Make executable the `phpenconf.sh` script file using `chmod u+x /etc/php/8.x/fpm/phpenconf.sh`
5. Edit the FPM configuration file (`/etc/php/8.x/fpm/conf-available/10-php-fpm.conf`) and make changes as you need.
6. Enable yours FPM settings using `./phpenconf.sh 10-php-fpm`
7. Edit the named like `/etc/php/7.x/fpm/conf-available/20-***.conf` files and make changes as you need.
7. Edit the named like `/etc/php/8.x/fpm/conf-available/20-***.conf` files and make changes as you need.
8. Enable the pools using `./phpenconf.sh 20-domain_01.tld 20-domain_02.tld`
9. Test the validity of your php-fpm configuration syntax using `php-fpm7.x -t`
10. Restart the PHP-FPM using `systemctl restart php7.x-fpm.service`
9. Test the validity of your php-fpm configuration syntax using `php-fpm8.0 --test`
10. Restart the PHP-FPM using `systemctl restart php8.x-fpm.service`

## Documentation

Expand All @@ -79,12 +76,12 @@ For instructions on how to use, best practices, templates and other usage inform

Thanks you for taking the time to contribute. Please fork the repository and make changes as you'd like.

As I use these configuration and templates for my own projects, it contains only the features I need. But If you have any ideas, just open an [issue](https://github.com/ojullien/php7.x-fpm/issues) and tell me what you think. Pull requests are also warmly welcome.
As I use these configuration and templates for my own projects, it contains only the features I need. But If you have any ideas, just open an [issue](https://github.com/ojullien/php-fpm/issues) and tell me what you think. Pull requests are also warmly welcome.

If you encounter any **bugs** in the configuration or templates, please open an [issue](https://github.com/ojullien/php7.x-fpm/issues).
If you encounter any **bugs** in the configuration or templates, please open an [issue](https://github.com/ojullien/php-fpm/issues).

Be sure to include a title and clear description,as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.

## License

**php7.x-fpm configuration and templates** are open-source and are licensed under the [MIT License](https://github.com/ojullien/php7.x-fpm/blob/master/LICENSE).
**php-fpm configuration and templates** are open-source and are licensed under the [MIT License](https://github.com/ojullien/php-fpm/blob/master/LICENSE).
2 changes: 1 addition & 1 deletion src/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200129
20210228
10 changes: 5 additions & 5 deletions src/fpm/conf-available/10-php-fpm.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
;; -----------------------------------------------------
;; PHP 7.x-FPM
;; PHP-FPM
;; Global FPM configuration.
;; This file override /etc/php/7.x/fpm/php-fpm.conf
;; It must be loaded after /etc/php/7.x/fpm/php-fpm.conf
;; This file override /etc/php/8.x/fpm/php-fpm.conf
;; It must be loaded after /etc/php/8.x/fpm/php-fpm.conf
;;
;; @context FPM
;; @author Olivier Jullien <https://github.com/ojullien>
;; -----------------------------------------------------

[global]
Expand All @@ -15,9 +14,10 @@
; into a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = /var/log/php7.0/php7-fpm.log
error_log = /var/log/php/php-fpm.log

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = warning

5 changes: 2 additions & 3 deletions src/fpm/conf-available/20-domain_01.tld.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
;; -----------------------------------------------------
;; PHP 7.x-FPM
;; PHP-FPM
;; domain_01.tld pool configuration.
;;
;; @context FPM POOL
;; @author Olivier Jullien <https://github.com/ojullien>
;; -----------------------------------------------------

; Start a new pool named 'domain_01.tld'.
Expand All @@ -30,7 +29,7 @@ group = domain_01.tld
listen = /run/php/$pool.sock

; Include common conf settings
include=/etc/php/7.4/fpm/conf-available/common.conf
include=/etc/php/8.0/fpm/conf-available/common.conf

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
Expand Down
5 changes: 2 additions & 3 deletions src/fpm/conf-available/20-domain_02.tld.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
;; -----------------------------------------------------
;; PHP 7.x-FPM
;; PHP-FPM
;; domain_02.tld pool configuration.
;;
;; @context FPM POOL
;; @author Olivier Jullien <https://github.com/ojullien>
;; -----------------------------------------------------

; Start a new pool named 'domain_02.tld'.
Expand All @@ -30,7 +29,7 @@ group = domain_02.tld
listen = /run/php/$pool.sock

; Include common conf settings
include=/etc/php/7.4/fpm/conf-available/common.conf
include=/etc/php/8.0/fpm/conf-available/common.conf

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
Expand Down
9 changes: 4 additions & 5 deletions src/fpm/conf-available/common.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
;; -----------------------------------------------------
;; PHP 7.x-FPM
;; PHP-FPM
;; Common FPM POOL configuration.
;;
;; @context FPM POOL
;; @author Olivier Jullien <https://github.com/ojullien>
;; -----------------------------------------------------

; the variable $pool can be used in any directive and will be replaced by the
Expand Down Expand Up @@ -201,7 +200,7 @@ pm.max_requests = 500
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: /usr/share/php/7.4/fpm/status.html
; It's available in: /usr/share/php/8.0/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
Expand All @@ -228,7 +227,7 @@ pm.max_requests = 500

; The access log file
; Default: not set
access.log = /var/log/php7.0/$pool.access.log
access.log = /var/log/php/$pool.access.log

; The access log format.
; The following syntax is allowed
Expand Down Expand Up @@ -292,7 +291,7 @@ access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/php7.0/$pool.log.slow
slowlog = /var/log/php/$pool.log.slow

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
Expand Down
33 changes: 25 additions & 8 deletions src/fpm/conf-available/www.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /run/php/php7.4-fpm.sock
listen = /run/php/php8.0-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 511

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; BSD-derived systems allow connections regardless of permissions. The owner
; and group can be specified either by name or by their numeric IDs.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www-data
Expand Down Expand Up @@ -70,7 +71,7 @@ listen.group = www-data
; process.priority = -19

; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
; or group is differrent than the master process user. It allows to create process
; or group is different than the master process user. It allows to create process
; core dump and ptrace the process for the pool user.
; Default Value: no
; process.dumpable = yes
Expand Down Expand Up @@ -139,7 +140,7 @@ pm.max_spare_servers = 3
;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
; recognized as a status page. It shows the following information:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
Expand Down Expand Up @@ -229,14 +230,30 @@ pm.max_spare_servers = 3
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: /usr/share/php/7.4/fpm/status.html
; It's available in: /usr/share/php/8.0/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status

; The address on which to accept FastCGI status request. This creates a new
; invisible pool that can handle requests independently. This is useful
; if the main pool is busy with long running requests because it is still possible
; to get the status before finishing the long running requests.
;
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Default Value: value of the listen option
;pm.status_listen = 127.0.0.1:9001

; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
Expand Down Expand Up @@ -269,13 +286,13 @@ pm.max_spare_servers = 3
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{miliseconds}d
; - %{milliseconds}d
; - %{mili}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some exemples:
; variable. Some examples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
Expand Down Expand Up @@ -374,7 +391,7 @@ pm.max_spare_servers = 3

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; Note: on highloaded environment, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes
Expand Down
4 changes: 2 additions & 2 deletions src/fpm/phpdisconf.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

## -----------------------------------------------------
## Disable a PHP7.x-FPM pool configuration.
## Disable a PHP-FPM pool configuration.
##
## @author Olivier Jullien <https://github.com/ojullien>
## -----------------------------------------------------
Expand Down Expand Up @@ -104,7 +104,7 @@ declare -i iReturn=1
# At least one argument
if (($# < 1)) || [[ -z "$1" ]]; then
echo "Usage: $(basename "$0") <configuration 1> [configuration 2 ...]"
echo -e "\tDisable a PHP7.x-FPM pool configuration file."
echo -e "\tDisable a PHP8.x-FPM pool configuration file."
echo -e "\t<configuration 1>\tPool configuration file."
exit ${iReturn}
fi
Expand Down
4 changes: 2 additions & 2 deletions src/fpm/phpenconf.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

## -----------------------------------------------------
## Enable a PHP7.x-FPM pool configuration.
## Enable a PHP-FPM pool configuration.
##
## @author Olivier Jullien <https://github.com/ojullien>
## -----------------------------------------------------
Expand Down Expand Up @@ -111,7 +111,7 @@ declare -i iReturn=1
# At least one argument
if (($# < 1)) || [[ -z "$1" ]]; then
echo "Usage: $(basename "$0") <configuration 1> [configuration 2 ...]"
echo -e "\tEnable a PHP7.x-FPM pool configuration file."
echo -e "\tEnable a PHP8.x-FPM pool configuration file."
echo -e "\t<configuration 1>\tPool configuration file."
exit ${iReturn}
fi
Expand Down
Loading

0 comments on commit ffffe7b

Please sign in to comment.