Last active
October 22, 2019 21:54
-
-
Save eksiscloud/9614b88dbf9828b81a6943a606a2659f to your computer and use it in GitHub Desktop.
Monit: Apache2, MySQL and PHP-FPM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apache2 | |
check process apache2 with pidfile /var/run/apache2/apache2.pid | |
group www-data | |
start program = "/bin/systemctl start apache2" with timeout 30 seconds | |
stop program = "/bin/systemctl stop apache2" | |
if failed host localhost port 80 with protocol http | |
and request "/server-status" for 2 times within 2 cycles then restart | |
depend apache_bin | |
depend apache_rc | |
check file apache_bin with path /usr/sbin/apache2 | |
group www-data | |
include /etc/monit/templates/rootbin | |
check file apache_rc with path /etc/init.d/apache2 | |
group www-data | |
include /etc/monit/templates/rootbin | |
# MySQL | |
check process mysql with pidfile /var/run/mysqld/mysqld.pid | |
group mysql | |
start program = "/bin/systemctl start mysql" | |
stop program = "/bin/systemctl stop mysql" | |
if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 2 times within 3 cycles then restart | |
if failed unixsocket /var/run/mysqld/mysqld.sock protocol mysql for 2 times within 3 cycles then restart | |
if 2 restarts with 2 cycles then timeout | |
depend mysql_bin | |
depend mysql_rc | |
check file mysql_bin with path /usr/sbin/mysqld | |
group mysql | |
include /etc/monit/templates/rootbin | |
check file mysql_rc with path /etc/init.d/mysql | |
group mysql | |
include /etc/monit/templates/rootbin | |
# PHP-FPM | |
check process php7.2-fpm with pidfile /var/run/php/php7.2-fpm.pid | |
start program = "/bin/systemctl start php7.2-fpm" with timeout 30 seconds | |
stop program = "/bin/systemctl stop php7.2-fpm" | |
if failed host example.tld port 80 protocol http | |
and request "/index.php" | |
then restart | |
if 2 restarts within 2 cycles then timeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
server-status is not an ordinary file. It is part of Apache2. You have to enable mod_status: a2enmod status