Tag: Apache

Awstats Installation

Awstats is an advanced graphical statistics software that can be used to analyze the webserver logs. Here we can see how we can install awstats on a linux server with Apache.


You can get the latest awstats from here. Login to server as root execute the below commands

# cd  /usr/local/
# wget http://sourceforge.net/projects/awstats/files/AWStats/7.0/awstats-7.0.tar.gz
# tar -zxvf awstats-7.0.tar.gz
# mv /usr/local/awstats-7.0 /usr/local/awstats
# cd /usr/local/awstats/tools/
# perl awstats_configure.pl

The above script will ask few questions, detect/modify your apache configuration and will generate an awstats configuration file for the site you specifies.


Awstats site configuration file path will be :  /etc/awstats/
Name Format of configuration file : awstats.yoursite.com.conf

Open the configuration file with a desired text editor and check, verify and modify the below entries

LogFile —> Log file directive should mention the correct path of the site access log file
SiteDomain —> this directive should mention your domain name

Updating stats

You can update stats with the below command
# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=yoursite.com

Add it as a cron to generate the statistics periodically

# crontab -e

0 0 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=yoursite.com >/dev/null 2>&1


To restrict access and to password protect the statistic information add the below lines in your apache configuration

<Files “awstats.pl”>
AuthUserFile /usr/local/awstats/.htpasswd
AuthGroupFile /path/to/.group
AuthName “Restricted Area”
AuthType Basic
require valid-user

You need to create a user and password and copy it to the file /usr/local/awstats/.htpasswd to limit the access. Any htpasswd online generator can be used for this, You can find an example one here

restart Apache

/etc/init.d/httpd restart


Awstats of the domain can be viewed with the url,


LAMP installation from source


Installing Apache ( 2.2.17 ) , Mysql ( 5.1.54 ) and php ( 5.3.4 ) on a Centos server.


Centos Server


Building from source an optimised/light Apache-Mysql-PHP on top of Centos server


Step 1

Install Mysql

root@serv:~# groupadd mysql

root@serv:~# useradd -r -g mysql mysql

root@serv:~# cd /usr/local

root@serv:~# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.54-linux-i686-glibc23.tar.gz/from/http://mysql.easynet.be/

root@serv:~# gunzip < /usr/local/mysql-5.1.54-linux-i686-glibc23.tar.gz | tar xvf –

root@serv:~# ln -s /usr/local/mysql-5.1.54-linux-i686-glibc23 mysql

root@serv:~# cd mysql

root@serv:~# chown -R mysql .

root@serv:~# chgrp -R mysql .

root@serv:~# scripts/mysql_install_db –user=mysql

root@serv:~# chown -R root .

root@serv:~# chown -R mysql data

root@serv:~# cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf

root@serv:~# bin/mysqld_safe –user=mysql &

root@serv:~# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

root@serv:~# ln -s /usr/local/mysql/bin/* /usr/bin/

Step 2

Install Apache , also install the dependent packages and compilers. You have to install the below packages for the most needed compile options that I have used.

root@serv:~# yum install gcc zlib-devel openssl-devel make

root@serv:~# cd /usr/local/src/

root@serv:~# wget http://www.alliedquotes.com/mirrors/apache//httpd/httpd-2.2.17.tar.bz2

root@serv:~# tar -jxvf httpd-2.2.17.tar.bz2

root@serv:~# cd /usr/local/src/httpd-2.2.17

root@serv:~# ./configure –prefix=/usr/local/apache –host=i686-redhat-linux-gnu –build=i686-redhat-linux-gnu –target=i386-redhat-linux  –enable-deflate –enable-proxy –enable-proxy-http—enable-proxy-connect –enable-so –enable-cgi –enable-info –enable-rewrite –enable-speling –enable-usertrack –enable-deflate –enable-mime-magic –enable-ssl

root@serv:~# make

root@serv:~# make install

Step 3

Install php, as we did before you need to install the dependencies before the php installation

root@serv:~# cd /usr/local/src/

root@serv:~# wget http://in2.php.net/get/php-5.3.4.tar.bz2/from/us.php.net/mirror

root@serv:~# tar -jxvf php-5.3.4.tar.bz2

root@serv:~# cd /usr/local/src/php-5.3.4/

root@serv:~# yum install libxml2-devel pcre-devel bzip2-devel curl-devel libjpeg-devel libpng-devel libXpm-devel libc-client-devel libmcrypt-devel libmcrypt-devel expat-devel

root@serv:~# ./configure –with-apxs2=/usr/local/apache/bin/apxs –enable-bcmath –enable-calendar –enable-ftp –enable-libxml –enable-magic-quotes –enable-pdo=shared –enable-soap –enable-sockets –enable-zip –prefix=/usr –with-bz2 –with-curl=/opt/curlssl/ –with-gd –with-imap=/opt/php_with_imap_client/ –with-imap-ssl=/usr –with-jpeg-dir=/usr –with-kerberos –with-libexpat-dir=/usr –with-libxml-dir –with-libxml-dir –with-mcrypt=/opt/libmcrypt/ –with-mhash=/opt/mhash/ –with-mysql=/usr/local/mysql/ –with-mysql-sock –with-openssl=/usr –with-openssl-dir=/usr –with-pcre-regex –with-pdo-mysql=shared –with-pdo-sqlite=shared –with-png-dir=/usr –with-sqlite=shared –with-xmlrpc –with-xpm-dir=/usr –with-zlib –with-zlib-dir=/usr

root@serv:~# make

root@serv:~# make install
Step 4

Configure php to phrase .php extension as php

root@serv:~# vi /usr/local/apache/conf/httpd.conf

find the line “LoadModule php5_module modules/libphp5.so” add the below line after it.
AddType application/x-httpd-php .php

root@serv:~# /usr/local/apache/bin/apachectl restart

Step 5

That is it, you can now test your installation

echo “<?php phpinfo(); ?> ” > /usr/local/apache/htdocs/phpinfo.php

Access and check your phpinfo page with,