Download Browseable Copy Of A Website Using Wget

Wget is a great tool in linux to download files from the internet. Wget can also be used to download a browseable copy of a website into your hard disk.

To download a complete website, use the command provided below

[code]wget  –recursive  –no-clobber   –page-requisites  –html-extension  –convert-links  –restrict-file-names=windows –no-parent -e robots=off[/code]

Wget will download all files and convert the links so that it Western union online can be browsed offline. Try it!

Mount an ISO image under Linux

You can mount an ISO images via the loop device under Linux. You need to use mount command as follows

mount -o loop /home/file.iso /media/disk


file.iso is the ISO file located in /home
/media/disk is the mount point. You will see a disc icon on the desktop if you mount under /media.

If you would like to mount the ISO file automatically every time when you boot your computer, add the below line in /etc/fstab

/home/file.iso /media/disk iso9660 loop,defaults 0 0

How to detect Public IP on VPS

If you have to find the public IP addresses that are assigned to a Virtual Private Server, just use the command below


On VPS, you would get the following

lo ===> 127.0.01
venet0 ==> 127.0.01
venet0:0 ==> Public IP
venet0:1 ==> Public IP

If you have more than one public IP, you would see venet0:1, venet0:2, venet0:3 etc

Installing Monit & Restart Apache Automatically

Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. You can use Monit to monitor daemon processes or similar programs running on localhost. Monit is particular useful for monitoring daemon processes, such as those started at system boot time from /etc/init.d/.

Common monit usage:
a) Monit can start a process if it does not run.
b) Restart a process if it does not respond.
c) Stop a process if it uses to much resources etc.

Installation on CentOS

yum install openssl*
tar -zxf monit-5.3.2.tar.gz
cd monit-5.3.2
make && make install
cp monitrc /etc/
cd ..
rm -rf monit-5.3.2*
echo "include /etc/monit.d/*" >> /etc/monitrc
chmod 700 /etc/monitrc
mkdir /etc/monit.d/
nano /etc/monit.d/apache

And copy/paste the following and save the file

Note: If you are on cPanel, use the codeblock posted next to the below post

check process httpd with pidfile /var/run/
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host port 80 protocol http
and request "/test.html"
then restart
if 5 restarts within 5 cycles then timeout

check process httpd with pidfile /usr/local/apache/logs/
group nobody
start program = "/scripts/restartsrv httpd"
stop program = "/scripts/restartsrv httpd"
if failed host port 80 protocol http
and request "/test.html"
then restart
if 5 restarts within 5 cycles then timeout

I believe, it is better if you use “/scripts/restartsrv httpd” instead of “/etc/init.d/httpd start” if you are on cPanel/WHM server.

Note: Next step may change according to your system configuration. The location of apache on cPanel server is
/usr/local/apache and htdocs will be /usr/local/apache/htdocs

So you should use this command provided below

echo "Test file" > /usr/local/apache/htdocs/test.html

If you are not using cPanel, then the apache location may be /etc/httpd and htdocs may be /var/www/html. In that case, change the code accordingly

echo "Test file" > /var/www/html/test.html

Add monit to rc.local so that it starts automatically when your server starts.
echo "/usr/local/bin/monit -d 60 -v -c /etc/monitrc -p /var/run/ -l /var/log/monit.log" >> /etc/rc.local

Finally, execute monit now.

/usr/local/bin/monit -d 60 -v -c /etc/monitrc -p /var/run/ -l /var/log/monit.log

You will see a message “Starting monit daemon” at the end if everything goes perfect.

That should start monit as deamon and check the ports on every 60 seconds.

Extending monit

You can monitor other services using monit such as mysql, exim etc. To do so, create a new file at /etc/monit.d/ and save it with the appropriate commands to check and restart code.

For example, if you want to monitor mysql, you can use the below commands

touch /etc/monit.d/mysql
echo "check process mysqld with pidfile /var/lib/mysql/`hostname`.pid" > /etc/monit.d/mysql
echo "start program = \"/etc/init.d/mysql start\"" >> /etc/monit.d/mysql
echo "stop program = \"/etc/init.d/mysql stop\"" >> /etc/monit.d/mysql
echo "if failed host port 3306 then restart" >> /etc/monit.d/mysql
echo "if 5 restarts within 5 cycles then timeout" >> /etc/monit.d/mysql

Those commands will add the following lines to /etc/monit.d/mysql

check process mysqld with pidfile /var/lib/mysql/
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host port 3306 then restart
if 5 restarts within 5 cycles then timeout

Be sure to re-execute monit after adding this.

Hope this helps