Apache is automatically restarted when a fault occurs, and Apache is restarted after a fault occurs.
Recently, I don't know why my blog is always inexplicably suspended,
Restart Apache, and I am too lazy to study the problem.
I just need to manually restart Apache through SSH every time, which is a little troublesome.
In addition, if a blog fails at night, it cannot be accessed at night.
Later, I finally couldn't bear it. I wrote a script to do this. The Code is as follows:
#!/bin/shif ( wget --timeout=5 -q --spider http://leonax.net/ )thenecho "ok"else/etc/init.d/httpd restartecho "httpd restarted"fi
The principle is simple, that is, to access the blog (Row 3 ),
If there is any problem, restart Apache (Row 7 ).
Here, the wget parameter-spider indicates that the content is only accessed and not downloaded.
If you like, you can also add an email code in else,
Send Apache error log directly to the email for analysis, but I am too lazy to do it.
Save the code as check_apache.sh and add it to crontab:
*/5 * * * * /var/www/check_apache.sh
*/5 indicates that check_apache.sh is run every five minutes.
Note that you must use sudo when opening crontab, because the sudo permission is required to restart Apache.
Reprinted from: http://leonax.net/c/product/software/apache/
How can I fix the restart problem after apache stops responding?
First, describe what linux system you are using. Different linux commands are different.
I personally use the ubuntu system. The command to restart apache is sudo/etc/init. d/apache2 restart.
You can also start two steps: sudo/etc/init. d/apache2 stop and then
Sudo/etc/init. d/apache2 start
Supplementary answer:
Try the following method to see if it is OK:
1. Method for disabling SELINUX:
# Vi/etc/selinux/config
Change the value of SELINUX to disabled, that is, SELINUX = disabled.
2. Do not disable SELINUX:
# Setenforce 0
# Chcon-c-v-R-u system_u-r object_r-t textrel_shlib_t/usr/local/apache/modules/libphp5.so
# Service httpd restart
# Setenforce 1
If the website cannot be opened, restart apache to enable it again. What is the problem? Is it a server problem or apache configuration problem?
No problem. If the restart function is normal.