Utoljára aktív 1740032355

Taken from https://gist.github.com/shakahl/9dab7d1e49c5d8d6a57a4633a702d23c

php

anthony's Avatar anthony gist felülvizsgálása 1740032355. Revízióhoz ugrás

1 file changed, 134 insertions

real-time-php-fpm-status.md(fájl létrehozva)

@@ -0,0 +1,134 @@
1 + # Real-time PHP-FPM Status
2 + This gist will explain you how to enable an undocumented feature of `PHP-FPM` which will give a real-time performance stats.
3 +
4 + Everybody knows the famous `phpinfo()` and the page it generates, right? Then the real-time `PHP-FPM` status page design is very similar.
5 +
6 + ![image](https://user-images.githubusercontent.com/9881407/61850126-fc292280-aea2-11e9-8f19-2cd5d109190e.png)
7 +
8 + > Some informations from the top are not displayed to avoid security issues.
9 +
10 + ## Enable PHP-FPM Status
11 + This is pretty simple to do, just run the command below.
12 +
13 + ```bash
14 + sudo sed -i 's/;pm.status_path/pm.status_path/' /etc/php/7.0/fpm/pool.d/www.conf
15 + ```
16 +
17 + Then restart the service:
18 +
19 + ```bash
20 + sudo systemctl restart php7.0-fpm
21 + ```
22 +
23 + > This has been tested on `PHP` versions `7.0`, `7.1`, `7.2` and `7.3`.
24 +
25 + ## Edit PHP / Apache Configuration
26 + In order to make the `status` page reachable, you will need to modify the `PHP` configuration related to `Apache2`.
27 +
28 + ```bash
29 + # Do this for all installed PHP versions...
30 + sudo nano /etc/apache2/conf-available/php7.0-fpm.conf
31 + ```
32 +
33 + And add these lines:
34 +
35 + ```apache
36 + # Enable 'status' and 'ping' page
37 + <LocationMatch "/(ping|status)">
38 + SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
39 + </LocationMatch>
40 +
41 + # Enable *real-time* 'status' page
42 + <IfModule alias_module>
43 + Alias /realtime-status "/usr/share/php/7.0/fpm/status.html"
44 + </IfModule>
45 + ```
46 +
47 + > This file `/usr/share/php/7.0/fpm/status.html` is totally **undocumented**, I was not able to find any related information on the web.
48 +
49 + Then restart `Apache2` to apply changes:
50 +
51 + ```bash
52 + sudo systemctl restart apache2
53 + ```
54 +
55 + > Make sure the `PHP` socket file and **real-time** `HTML` status has the correct version!
56 +
57 + ## Fix the broken `PHP` logo (_optional_)
58 + The `PHP` logo is broken unfortunately but I've found a way to fix it, this is just a little dirty... :sweat_smile:
59 +
60 + ```bash
61 + sudo sed -i 's|https://static.php.net/www.php.net/images/php.gif|data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHkAAABACAYAAAA+j9gsAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAD4BJREFUeNrsnXtwXFUdx8/dBGihmE21QCrQDY6oZZykon/gY5qizjgM2KQMfzFAOioOA5KEh+j4R9oZH7zT6MAMKrNphZFSQreKHRgZmspLHSCJ2Co6tBtJk7Zps7tJs5t95F5/33PvWU4293F29ybdlPzaM3df2XPv+Zzf4/zOuWc1tkjl+T0HQ3SQC6SBSlD6WKN4rusGm9F1ps/o5mPriOf8dd0YoNfi0nt4ntB1PT4zYwzQkf3kR9/sW4xtpS0CmE0SyPUFUJXFMIxZcM0jAZ4xrKMudQT7963HBF0n6EaUjkP0vI9K9OEHWqJLkNW1s8mC2WgVTwGAqWTafJzTWTKZmQuZ/k1MpAi2+eys6mpWfVaAPzcILu8EVKoCAaYFtPxrAXo8qyNwzZc7gSgzgN9Hx0Ecn3j8xr4lyHOhNrlpaJIgptM5DjCdzrJ0Jmce6bWFkOpqs0MErA4gXIBuAmY53gFmOPCcdaTXCbq+n16PPLXjewMfGcgEttECeouTpk5MplhyKsPBTiXNYyULtwIW7Cx1vlwuJyDLR9L0mQiVPb27fhA54yBbGttMpc1OWwF1cmKaH2FSF7vAjGezOZZJZ9j0dIZlMhnuRiToMO0c+N4X7oksasgEt9XS2KZCHzoem2Ixq5zpAuDTqTR14FMslZyepeEI4Ogj26n0vLj33uiigExgMWRpt+CGCsEePZqoePM738BPTaJzT7CpU0nu1yXpAXCC3VeRkCW4bfJYFZo6dmJyQTW2tvZc1nb719iyZWc5fmZ6Osu6H3uVzit52oBn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n9/B0xkD2U6+e+sOaHqImTfLrycUOIZM1hJwC3oemPXbi/y5PnsrJ136bUa8pxu69BklmANWwDRkgR1wmwVaglyi3Nz6JLQ+ZG5NxQsgNdAhmIfJN7wxgoWg9fxzPQ+c/g9YAIXgeUKCyipJO4uR/wswAOIwB/5IgxvbAAAAAElFTkSuQmCC|' /usr/share/php/7.0/fpm/status.html
62 + ```
63 +
64 + > Again, do this for all installed `PHP` versions. (_no need to restart the web server_)
65 +
66 + ## Available `status` formats
67 + The default and very well documented `status` page offer **three** different formats:
68 +
69 + * `XML`
70 + * `JSON`
71 + * `HTML`
72 +
73 + But all of them are not refresh in **real-time**.
74 +
75 + All formats, also give **two** different output levels:
76 +
77 + * `normal`
78 + * `full`
79 +
80 + ### 1. XML Format
81 + Access `URL` is: http://localhost/status?xml
82 +
83 + ![image](https://user-images.githubusercontent.com/9881407/61850292-79ed2e00-aea3-11e9-8f0b-d5fc247d02d6.png)
84 +
85 + For the `full` output level: http://localhost/status?xml&full
86 +
87 + ![image](https://user-images.githubusercontent.com/9881407/61850331-97ba9300-aea3-11e9-83fb-966488900f08.png)
88 +
89 + ### 2. JSON Format
90 + Access `URL` is: http://localhost/status?json
91 +
92 + ![image](https://user-images.githubusercontent.com/9881407/61850250-5cb85f80-aea3-11e9-9821-64aa43038907.png)
93 +
94 + For the `full` output level: http://localhost/status?json&full
95 +
96 + ![image](https://user-images.githubusercontent.com/9881407/61850390-c46eaa80-aea3-11e9-8085-e5b227e44c5a.png)
97 +
98 + ### 3. HTML Format
99 + Access `URL` is: http://localhost/status?html
100 +
101 + ![image](https://user-images.githubusercontent.com/9881407/61850220-414d5480-aea3-11e9-9942-fab887b9426d.png)
102 +
103 + For the `full` output level: http://localhost/status?html&full
104 +
105 + ![image](https://user-images.githubusercontent.com/9881407/61850452-e700c380-aea3-11e9-9e76-d787f8299f9a.png)
106 +
107 + > The alias `status` is defined here: `/etc/php/7.0/fpm/pool.d/www.conf`.
108 +
109 + ## Real-time `status` page
110 + This is the **undocumented** one.
111 +
112 + Access `URL` is: http://localhost/realtime-status
113 +
114 + ![image](https://user-images.githubusercontent.com/9881407/61850126-fc292280-aea2-11e9-8f19-2cd5d109190e.png)
115 +
116 + _It will use the `JSON` output format internally to display the real-time values._
117 +
118 + > The alias `realtime-status` is defined here: `/etc/apache2/conf-available/php7.0-fpm.conf`.
119 +
120 + ## Access via `HTTPS` protocol
121 + At the moment you have created an `SSL` / `TLS` certificate for your testing or production domain, the `standard` and the `real-time` mode should work with both `HTTP` and `HTTPS` protocols.
122 +
123 + # References
124 + Some references where I was able to find useful informations.
125 +
126 + * https://howto.biapy.com/en/debian-gnu-linux/servers/apache-2/setup-a-status-page-on-a-apache-2-server
127 + * https://www.tecmint.com/enable-monitor-php-fpm-status-in-nginx/
128 + * https://stackoverflow.com/questions/37367851/set-up-and-access-the-php-fpm-status-page-in-bitnami-lamp-stack
129 +
130 + # Contribute
131 + Feel free to comment if you have any suggestions or corrections to make.
132 +
133 + # Contact
134 + You can reach me on Twitter using: [@Jiab77](https://twitter.com/Jiab77).
Újabb Régebbi