How to setup AWStats for apache log analyzer (CentOS 6.8)

1) Installation
 #yum install epel-release
 #yum install httpd
 #chkconfig httpd on
 #service httpd start
 #yum install awstats

2) Configuration

 a) Changes in log format in httpd.conf
 check the below entry for log format. if it does not exist then add it.    
 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

 b) changes in virtualhosts 

 change your log configuration like below
 CustomLog logs/ combined
 c) configuring awstats.conf for apache 
 #vim /etc/httpd/conf.d/awstats.conf

  add below entries in <Directory "/usr/share/awstats/wwwroot">
  </Directory> container

  AuthUserFile "/path-to-file/.htpasswd"
  AuthName "Restriceted Access"
  AuthType Basic
  Require user "htuser"

 Then create password file by below command
 #htpasswd -c /path-to-file/.htpasswd htuser
 #chmod 404 /path-to-file/.htpasswd htuser

d) creating configuation file for awstat

 #cp /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/
 then edit the file /etc/awstats/

# vim /etc/awstats/ and change the below entries according to domain

( for multiple domains its better to create seperate files for each domain)

e) setting permissions 

now change permissions for the awstat folder

#find  /usr/share/awstats -type d -exec chmod 701 '{}' \;
#find /usr/share/awstats  -type f  -exec chmod 404 '{}' \;

#chmod +x  /usr/share/awstats/wwwroot/cgi-bin/
#chmod 400 /etc/awstats/*.conf

Once you make all the changes make sure to restart apache to get configuration changes into effect

#/etc/init.d/httpd stop
#/etc/init.d/httpd start

or #/etc/init.d/httpd restart

make necessary changes according to your domain in below url  to check the statistics

Image to pdf

 #tiff-to-pdf is 6 to 7 times faster script than this script
 start_time=`date +%s`
 ########## Section 1 ##########
 # This command can convert any image to PDF document, version 1.3 ( very slow as compared to tiff2pdf ) but slightly faster than section 2

mogrify -format pdf *

######### Section 2 ##########
 # this command can convert any image to PDF document, version 1.3

#ls  | while read filename; do
 #file=`echo $filename |sed 's/\(.*\)\..*/\1/'`
 #convert $filename $file.pdf

finish_time=`date +%s`

echo "Time duration: `expr $finish_time - $start_time` secs."

Check up/down hosts in your network

To check how many systems are up and how many systems are down in network.use below script

I used nohup to avoid ping output on screen

for i in {1..254} ; do ip=192.168.0.$i && nohup ping -c1 $ip 2> /dev/null && echo "$ip online" || echo "$ip offline" ; done

tiff to pdf

# this file converts tif image to pdf file in present directory and all subdirectoris.
start_time=$(date +%s)

find . -type f -iname "*.tif*" | while read tif; do
 pdf=`echo $tif |sed 's/\(.*\)\..*/\1/'`
 if [[ ! -f "$pdf.pdf" ]];
 tiff2pdf -o "$pdf.pdf" "$tif"
   tstamp=`date +%N`
   if [[ ! -f "$pdf.pdf" ]];
   tiff2pdf -o "$pdf.pdf" "$tif"
   tstamp=`date +%S`
   tiff2pdf -o "$pdf.pdf" "$tif"
finish_time=$(date +%s)
echo done
echo "Time duration: $((finish_time - start_time)) secs."

create tar archive from the list of files

If you want to create tar file from the list (The list may contain files from different folders).

then use below command

#tar -zcvf  mytar.tar.gz -T list

This command will read list line by line and keep adding the file mentioned in list to the tar file 

How to Setup Wpad Auto Proxy to your network

The Web Proxy Auto-Discovery Protocol (WPAD) is a method used by clients to locate a URL of a configuration file using DHCP and/or DNS discovery methods. Once detection and download of the configuration file is complete it can be executed to determine the proxy for a specified URL. The WPAD protocol only outlines the mechanism for discovering the location of this file.

Create a file wpad.dat with following contain :-

function FindProxyForURL(url, host) {
return "PROXY; DIRECT";


For the another requirement like two proxy servers or one proxy  with one vpn servers like configuration please refer my this post.

How to install flash player plugin in mozilla firefox

Step 1
go to
select .tar.gz for other linux
and then click on download to download it

Step 2
open the terminal and go to the Downloads folder
extract the source by command
#tar -zxvf install_flash_player_some-version_linux_i386.tar.gz
a file will be extracted from source
copy that file to the mozilla plugins folder by following command
#sudo cp /usr/lib/mozilla/plugins



ssmtp program to send emails

This is the program who sends email. it takes 8,192B of disk space after installation
its quit simple to use.

for that we have to edit /etc/ssmtp/ssmtp.conf like below
#$hostname=sysadmins —-> this line doesn’t affect after commenting


The normal command to send email via command line is
Subject: Sent from a terminal!

script to send message using text file
function welcome_mail
echo enter user name
read username
echo enter full name

cat > /tmp/welcome-reciepent << welcome1
To: $USER@your_domain
From: System Administrator
Subject: Welcome! Please read the instructions

Welcome , Please go through the instructions given below

cat /file_path/instructions >> /tmp/welcome-reciepent

echo “Sending Welcome-mail”
ssmtp $ < /tmp/welcome-reciepent
echo “OK”

and the /file_path/instruction is a simple file in which instructions are written.
like this.

this is instruction1
this is instruction2
this is instruction3
this is instruction4
(Please don’t revert back. This is a system generated email)

merits: 1) simple to use and can be used to mail newly joined user.
2) the mail can be sent by using any mail account as the sender will not be shown (it will show the name we choose.)
3) user cant reply back as there is no emailid in sender

demerits : 1) we can not attach the file.(searching the solution)
2) we will have to install the software for it

OpenVpn client on ubuntu

step 1: (installation)
(it might be possible that some packages are not needed but i installed these packages )

#sudo apt-get install libglib2.0-dev libgtk2.0-dev libglade2-dev libgnome-keyring-dev gedit gksu subversion build-essential autogen #automake autoconf intltool
#sudo apt-get install openvpn
#sudo apt-get install network-manager-openvpn
#sudo apt-get install gopenvpn (this may not be needed)

step 2: (Downloading Certificates and Key Files)

Download all the certificate files from pfsense->vpn->openvpn->
clientexport to /etc/openvpn
make all these file readable and executable for all by
#sudo chmod +rx * in /etc/openvpn

at this stage you can start the vpn but in text mode
the command is
#openvpn --config /etc/openvpn/pfsense-udp-1194-config.ovpn

Step 3 : (creating openvpn connection in graphical mode)

#/etc/init.d/network-manager start
click on network manager icon (it will appear on beside the sound icon on the taskbar on the top
right side)

vpn connections -> configure vpn -> import -> pfsense-udp-1194.ovpn
(browse this file.)
now this will create a vpn connection.
you have to modify this connection up to some extenct

step 4 : (modification/configuration):

go to vpn tab

gateway : it will take automatically don't make change

Type : password with Certificate (TLS) (default dont change)
username :
password :
User Certificate (browse this file)
CA Certificate (browse this file)
Private Key

click on advace button
go to TLS Authentication tab
check mark on use additional TLS authentication

Key File
Key Direction 1

Save The configuration

now again click on the network manager icon on right top
select vpn connections -> pfsense-udp-1194-config

(Basically the .ovpn file is important as its the main configuration file. In my case my openvpn server is on pfsense so I downloaded file from there. Your case may be different so only getting the .ovpn file will be the different procedure for you if you are not using pfsense.)