1.從官網下載最新的的awstats,解壓縮
# unzip awstats-6.95.zip
# mv awstats-6.95 /usr/local/awstats
2. 安裝配置awstats,以我服務器上的網站phpadmin.dean.com爲例,根據情況請自行更改網址
[root@server56 LAMP]# cd /usr/local/awstats/
[root@server56 awstats]# mkdir -m 755 data
[root@server56 awstats]# perl tools/awstats_configure.pl
-----> Check for web server installFound Web server Apache config file '/etc/httpd/httpd.conf' <=============讀取你的httpd配置文件
-----> Check and complete web server config file '/etc/httpd/httpd.conf'
All AWStats directives are already present.
-----> 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 <===============第一次需要創建一個新的config fiel
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> phpadmian.dean.com <====================這裏輸入你要記錄的網址,當然是自己httpd服務器上的
-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> <================配置文件存放路徑,一般默認/etc/awstats即可,直接回車
-----> Create config file '/etc/awstats/awstats.phpadmin.dean.com.conf'
Config file /etc/awstats/awstats.phpadmin.dean.com.conf created.
-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=phpadmin.dean.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue... <====================按回車創建。。。
A SIMPLE config file has been created: /etc/awstats/awstats.phpadmin.dean.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'phpadmin.dean.com' with command:
> perl awstats.pl -update -config=phpadmin.dean.com
You can also read your statistics for 'phpadmin.dean.com' with URL:
> http://localhost/awstats/awstats.pl?config=phpadmin.dean.com
Press ENTER to finish... <=============創建成功,按回車退出
3.修改配置文件/etc/awstats/awstats.drupal.dean.com.conf ,找到logFile那一行,將其修給爲自己網站的訪問日誌路徑,並且增加一樣DataDir指向上面創建的data目錄
vim /etc/awstats/awstats.drupal.dean.com.conf
LogFile="/usr/local/apache/logs/druap.dean.com-access_log"
DataDir="DataDir="/usr/local/awstats/data"4.生成統計日誌網頁。
1)首先需要創建/var/lib/awstats目錄,否則在生成日誌網頁的時候報錯
mkdir /var/lib/awstats
2)確保你的網站訪問日誌格式爲combined ,否則會報錯This means each line in your web server log file need to have "combined log format" like this:
3)確保awstats.pl有執行權限,否則無法生成日誌網頁
chmod +x /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
4)生成日誌網頁cd /usr/local/awstats/wwwroot/cgi-bin
perl awstats.pl updata -config=phpadmin.dean.com
5. 查看日誌網頁在瀏覽器裏輸入:http://phpadmin.dean.com/awstats/awstats.pl?config=phpadmin.dean.com
效果如下
6.可以將以上命令放到crontab中執行,並根據需要指定更新的頻率和時間:
33 6 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=phpadmin.dean.com >/dev/null 2>&1