Apache and Awstats

Source: Internet
Author: User

First, experimental Steps and Results

First Stage

Build Apache website Service

Hstname

OS

Ip

Software

Www.benet.com

CentOS-6.5

192.168.1.200

Httpd-2.2.17.tar.gz

Awstats-7.0.zip

Client

Windows 7

192.168.1.234

Ie

Shut down firewall: Service iptables stop

Configure Apache Services

[Email protected]/]# tar zxvf httpd-2.2.17.tar.gz-c/usr/src/

[Email protected]/]# Unzip Awstats-7.0.zip

[Email protected]/]#/configure--prefix=/usr/local/httpd--enable-so--enable-rewrite--enable-charset-lite-- enable-cgi && make && make install

--prefix: Specifying the installation directory

--ENABLE-SO: Enable dynamic load module support

--enable-rewrite: Enable site rewriting features

--enable-charset-lite: Startup Character Set support

--ENABLE-CGI: Enable CGI scripting support

[[email protected] httpd-2.2.17]# ln-s/usr/local/httpd/bin/*/usr/local/bin///Optimize execution path

[Email protected] ~]# CP/USR/LOCAL/HTTPD/BIN/APACHECTL/ETC/INIT.D/HTTPD

[Email protected] ~]# VIM/ETC/INIT.D/HTTPD

#chkconfig: 35 85 15

#description: Apache HTTP Server

[Email protected] ~]# chkconfig--add httpd

[Email protected] ~]# chkconfig--level httpd on

[Email protected] ~]# vim/usr/local/httpd/conf/httpd.conf

ServerName www.benet.com:80//Add website domain name

[[email protected] ~]# httpd–t//Check for configuration file errors

Syntax OK

[[email protected] ~]#/etc/init.d/httpd start

[Email protected] ~]# NETSTAT-ANPT |grep 80

TCP 0 0::: +:::* LISTEN 54881/httpd

[Email protected] ~]# ELinks http://192.168.1.200

It works!

Create a virtual Web host based on a different domain name

Create a document directory for a Web site for two sites

[Email protected] ~]# mkdir/usr/local/httpd/htdocs/benetcom

[Email protected] ~]# mkdir/usr/local/httpd/htdocs/accpcom

[[email protected] ~]# echo '

[[email protected] ~]# echo '

modifying configuration Files httpd.conf and httpd-vhosts.conf

[Email protected] ~]# cd/usr/local/httpd/conf/extra/

[Email protected] extra]# vim httpd-vhosts.conf

Namevirtualhost 192.168.1.200:80

<virtualhost 192.168.1.200:80>

DocumentRoot "/usr/local/httpd/htdocs/benetcom/"

ServerName www.benet.com

Errorlog "Logs/www.benet.com-error_log"

Customlog "Logs/www.benet.com-access_log" common

</VirtualHost>

<virtualhost 192.168.1.200:80>

DocumentRoot "/usr/local/httpd/htdocs/accpcom/"

ServerName www.accp.com

Errorlog "Logs/www.accp.com-error_log"

Customlog "Logs/www.accp.com-access_log" common

</VirtualHost>

[Email protected] extra]# CD.

[Email protected] conf]# vim httpd.conf

Include conf/extra/httpd-vhosts.conf//Remove the "#" in front of this line

[Email protected] ~]# vim/etc/hosts

192.168.1.200 www.benet.com www.accp.com

[Email protected] ~]#/etc/init.d/httpd restart

[Email protected] ~]# ELinks http://www.benet.com

Www.benet.com

[Email protected] ~]# ELinks http://www.accp.com

Www.accp.com

Phase II

Deploying and installing the Awstats Log Analysis system

[Email protected]/]# Unzip Awstats-7.0.zip

[Email protected]/]# MV Awstats-7.0/usr/local/awstats

[Email protected]/]# cd/usr/local/awstats/tools/

[Email protected] tools]#./awstats_configure.pl

-----AWStats Awstats_configure 1.0 (Build 1.9) (c) Laurent destailleur-----

This tool would help you to configure AWStats to analyze statistics for

    • One Web server. You can try the it to let it be possible

In AWStats Setup, however following the step by step manual setup

Documentation (docs/index.html) is often a better idea. Above All if:

-You aren't an administrator user,

-You want to analyze downloaded log files without Web server,

-You want to analyze mail or FTP log files instead of Web log files,

-You need to analyze load balanced servers log files,

-You want to ' understand ' all possible ways to use AWStats ...

Read the AWStats documentation (docs/index.html).

-----> Running OS detected:linux, BSD or Unix

-----> Check for Web Server install

Enter full config file path of your WEB server.

Example:/etc/httpd/httpd.conf

Example:/usr/local/apache2/conf/httpd.conf

Example:c:\program Files\apache group\apache\conf\httpd.conf

Config file path (' None ' to skip Web server Setup):

>/usr/local/httpd/conf/httpd.conf//httpd master configuration file path

-----> Check and complete Web server config file '/usr/local/httpd/conf/httpd.conf '

Warning:you Apache config file contains directives to write ' common ' log files

This means is some features can ' t work (OS, browsers and keywords detection).

Do you want me to setup Apache to write ' combined ' log files [y/n]? Y//Set log file type

Add ' alias/awstatsclasses '/usr/local/awstats/wwwroot/classes/"'

Add ' alias/awstatscss '/usr/local/awstats/wwwroot/css/"'

Add ' alias/awstatsicons '/usr/local/awstats/wwwroot/icon/"'

Add ' scriptalias/awstats/'/usr/local/awstats/wwwroot/cgi-bin/"'

Add ' <Directory> ' directive

AWStats directives added to Apache config file.

-----> Update Model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf '

File awstats.model.conf updated.

-----> need to create a new config file?

Do you want me to build a new AWStats Config/profile

File (required if first install) [y/n]? Y//Set Site configuration file

-----> Define Config file name to create

What's the name of the your Web site or profile?

Example:www.mysite.com

Example:demo

Your Web site, virtual server or profile name:

> www.benet.com//The site name of the statistic

Next default configuration press ENTER

Modifying the awstats.www.benet.com.conf configuration file

[Email protected] ~]# mkdir/var/lib/awstats

[Email protected] ~]# vim/etc/awstats/awstats.www.benet.com.conf

Logfile= "/usr/local/httpd/logs/access_log"

Dirdata= "/var/lib/awstats"

Create a storage directory for the database and update the database

[[email protected] ~]#/usr/local/awstats/tools/awstats_updateall.pl now//execute update script

Running ' "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl"-update-config=www.benet.com-configdir= "/etc/awstats" ' To update config www.benet.com

Create/update database for config '/etc/awstats/awstats.www.benet.com.conf ' by Awstats version 7.0 (build 1.971)

From the data in log file "/usr/local/httpd/logs/access_log" ...

Phase 1:first bypass old records, searching new record ...

Searching new records from beginning of log file ...

Jumped lines in file:0

Parsed lines in File:2

Found 0 dropped Records,

Found 0 comments,

Found 0 Blank Records,

Found 2 Corrupted Records,

Found 0 old Records,

Found 0 New qualified records.

Create Recurring Scheduled Tasks

[Email protected] ~]# CRONTAB-E

*/5 * * * */usr/local/awstats/tools/awstats_updateall.pl now

Create a site Jump page

[[email protected]/] Vim aws.html

<meta Http-equiv=refresh content= "0;

Url=http://www.benet.com/awstats/awstats.pl?config=www.benet.com ">

<body><body>

[[Email protected]/]# MV aws.html/usr/local/httpd/htdocs///Move the jump page to the Web site root directory

[Email protected] ~]#/etc/init.d/httpd restart

Restart Apache Visit Awstats Home

Phase III

Control for access to the Awsstats

Client Address Restrictions

[Email protected]/]# vim/usr/local/httpd/conf/httpd.conf

<directory "/usr/local/awstats/wwwroot" >

Options None

AllowOverride None

Order Deny,allow

Deny from 192.168.1.234//Deny host access to 192.168.1.234 IP

</Directory>

[Email protected]/]#/etc/init.d/httpd restart

At this point the 192.168.1.234 client will not be able to access www.benet.com/aws.html

User Identity authentication Restrictions

First use the HTPASSWD tool to create a user authentication data file

[Email protected]/]# htpasswd-c/usr/local/httpd/conf/.awspwd Xuhao

New Password:

Re-type New Password:

Adding Password for user Xuhao

[Email protected]/]# cat/usr/local/httpd/conf/.awspwd

xuhao:ee3ehfdzn4a5c

Modify the httpd.conf configuration file to add user authorization

[Email protected]/]# vim/usr/local/httpd/conf/httpd.conf

<directory "/usr/local/awstats/wwwroot" >

Options None

AllowOverride None

Order Allow,deny

Allow from all

AuthName "AWStats Directory"//define protected realm names

AuthType Basic//Set the type of authentication

AUTHUSERFILE/USR/LOCAL/HTTPD/CONF/.AWSPWD//Set the path for saving user account and password files

Require Valid-user//legal user to access

</Directory>

[Email protected]/]#/etc/init.d/httpd restart

Login Client Access Test

Apache and Awstats

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.