Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to restart Apache server under Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to restart the Apache server under Linux". In the daily operation, I believe that many people have doubts about how to restart the Apache server under Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to restart the Apache server under Linux". Next, please follow the editor to study!

Description: my host is the centos system, the instructions for each step of the operation are written in the notes, easy to read.

Vi apachemonitor.shemonitor.shalloxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx } doit () {if! Curlit; then# if the apache service of localhost does not return 200 headers normally, an exception occurs. Execute the following command: sleep 20top-n 1-b > > / var/log/apachemonitor.log# write the contents of the top command to the file for reference / usr/bin/killall-9 apache2 & & / usr/bin/killall-9 php5-cgi & & / usr/bin/killall-9 httpd&& / usr/bin/killall-9 http & & / usr/bin/killall-9 apache&& / usr/bin/killall-9 php-cgi > / dev/null# compatibility Killed all kinds of apache processes. You can modify sleep 2/etc/init.d/apache2 start > / dev/null/etc/init.d/httpd start > / dev/null# according to the characteristics of your apache service. For the sake of compatibility, you have executed two apache restart commands, which can be modified as needed. Echo $(date) "apache restart" > > / var/log/apachemonitor.log# write log sleep 3 write log wait 30 seconds after the restart is complete, and then try if again! If curlit; then# is still not accessible, then: echo $(date) "failed! Now reboot computer! "> > / var/log/apachemonitor.log# writes apache to the log that still fails and reboot# restarts the machine. In fact, restarting the entire server is a very last resort. I do not recommend it. Everyone modifies it according to their own needs, such as text messages, e-mail and so on. Fisleep 180fi} sleep 30 runs the script 5 minutes after it starts formal work (to prevent miscalculation due to the fact that apache has not yet started after restarting the server) while true Do# main loop body doit > / dev/nullsleep 10done then execute: chmod + x apachemonitor.sh add boot startup item: vi / etc/rc.d/rc.local my rc.local script content is: #! / bin/sh## this script will be executed * after* all the other init scripts.# you can put your own initialization stuff in here if you don't# want to do the full sys v style init stuff.touch / var/lock/subsys/local/root/lampmonitor.sh so far The study on "how to restart the Apache server under Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report