As I mentioned in previous post I did a few upgrades to EasyApache4 on couple of WHM/cPanel servers recently. While providing with an impressive list of advantages this upgrade could render some of the hosted sites offline because of missing PHP modules and incompatible PHP versions. In order to minimize the downtime all hosted sites has to be verified for availability. There could be easily hundreds of web sites hosted on single WHM/cPanel server and checking all of them manually will take a lot of time. In Linux almost anything could be automated.
I’ve used following shell script line to check for the locally hosted web sites that return HTTP status code 500 – ‘server error’.
1 2 3 |
/usr/local/apache/bin/httpd -S 2>&1 | grep www | \ awk '{print "echo -n ="$2"= ; curl -L -s -o /dev/null -w \"%{http_code}\" -I -X GET http://"$2"; echo; "}' | \ sh - | grep 500 |
It produces following output
1 2 3 4 |
=www.broken-site1.com=500 =www.broken-site2.com=500 =www.broken-site3.com=500 =www.broken-site4.com=500 |
I’ve ran this script on the WHM/cPanel server that hosts more then 150 sites and it took just a few seconds to run the test and determine broken sites. This script could be modified to take the input from any other source with the single site name per line.
0 Comments.