Question
How to configure the PHP-FPM plugin of 360 Monitoring on a Plesk server?
Answer
Note: All domains with the PHP-FPM plugin enabled must have a valid SSL certificate, run on Nginx and be accessible.
The corresponding User Story (EXTPLESK-3359) was created to consider the future possibility of the automatic implementation of the plugin.
-
Go to Domains > example.com > PHP Settings
-
Add the following lines to the Additional directives field:
CONFIG_TEXT: [php-fpm-pool-settings]
pm.status_path = /status_phpfpm -
Click OK
-
Go to Domains > example.com > Apache & nginx Settings
-
Add the following lines to the Additional directives for nginx:
CONFIG_TEXT: location ~ ^/status_phpfpm$ {
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass "unix:///var/www/vhosts/system/example.com/php-fpm.sock";
include /etc/nginx/fastcgi.conf;
} -
Click OK
-
Connect to the server via SSH
-
Add the following section to the file
/etc/agent360.ini
:CONFIG_TEXT: [phpfpm]
enabled = yes
status_page_url = https://example.com/status_phpfpm?json -
Restart the service:
# systemctl restart agent360
Note: It is needed to repeat the steps for every domain that is needed to be monitored. For multiple domains, the section in /etc/agent360.ini
should look like this one:
CONFIG_TEXT: [phpfpm]
enabled = yes
status_page_url = https://example.com/status_phpfpm?json, https://domain.tld/status_phpfpm?json, ...
Warning: Changes in the templates might result in incorrect work of all domains. The operations below should be handled by a Linux administrator.
-
Connect to the server via SSH
-
Copy the default template to create a custom one:
# cp -a /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
-
Edit file
/usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
by adding the following lines:CONFIG_TEXT: location ~ ^/status_phpfpm$ {
allow <?php echo $OPT['ipAddress']->escapedAddress; ?>;
deny all;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass "unix://<?php echo $VAR->server->webserver->vhostsDir ?>/system/<?php echo $VAR->domain->targetName; ?>/php-fpm.sock";
include /etc/nginx/fastcgi.conf;
}Note: The lines should be added as the last
location
section inside the block:CONFIG_TEXT: <?php if ($VAR->domain->active && $VAR->domain->physicalHosting->php && $VAR->domain->physicalHosting->proxySettings['nginxServePhp']): ?>
...
<?php endif ?> -
Update the PHP Settings by adding the necessary Additional directive:
# echo -e "[php-fpm-pool-settings]\npm.status_path = /status_phpfpm" > tmpfile && for domain in $(MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin -Nse "SELECT name FROM psa.domains WHERE htype = 'vrt_hst'"); do plesk bin site --update-php-settings $domain -additional-settings tmpfile; done && rm -f tmpfile
-
Adjust the 360 Monitoring agent settings:
# echo -en "[phpfpm]\nenabled = yes\nstatus_page_url =" > tmpconffile && for domain in $(MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin -Nse "SELECT name FROM psa.domains WHERE htype = 'vrt_hst'"); do echo -n " https://$domain/status_phpfpm?json," >> tmpconffile; done && sed -i '$ s/.$//' tmpconffile && cat tmpconffile >> /etc/agent360.ini && rm -f tmpconffile
-
Apply the web configuration:
# plesk repair web -y
-
Restart the agent:
# systemctl restart agent360
-
Connect to the server via SSH
-
Download the script:
# wget https://plesk.zendesk.com/hc/article_attachments/4418181127570/360_phpfpm_plugin_conf.py
-
Make it executable:
# chmod +x 360_phpfpm_plugin_conf.py
-
Execute the script:
# ./360_phpfpm_plugin_conf.py
If the following error appears:
CONFIG_TEXT: /usr/bin/env: 'python': No such file or directory
Execute the script in this way:
# python3 360_phpfpm_plugin_conf.py
-
Apply the web configuration:
# plesk repair web -y
Comments
2 comments
Hello,
I followed the guide (the version "for all domains - automatically"). Apparently all went fine, but I still see the the "install" button next to the label for the php-fpm plugin and in the toolbar it's not listed among the active ones (httpd, mysql, nginx).
What could be missing? I also tried to "service agent360 restart", but nothing changed. Thank you
Tried on a new server (Plesk Obsidian, like the previous one) and got the same result (I still see the "install" button). When using agent360 --test phpfpm, it says:
phpfpm:
Execution error: HTTP Error 404: Not Found
The configuration in /etc/agent360.ini seems fine:
[phpfpm]
enabled = true
status_page_url = https://mysite1.com/status_phpfpm?json, https://mysite2.com/status_phpfpm?json ...
Please sign in to leave a comment.