四.下面開始在debian 下部署nginx
首先不須要太多包,只須要 pcre, ssl and zlib
aptitude install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-devphp
root@houzaicun:/home/nginx-1.0.10# ldconfig -p |grep pcre
libpcreposix.so.3 (libc6,x86-64) => /usr/lib/libpcreposix.so.3
libpcreposix.so (libc6,x86-64) => /usr/lib/libpcreposix.so
libpcrecpp.so.0 (libc6,x86-64) => /usr/lib/libpcrecpp.so.0
libpcrecpp.so (libc6,x86-64) => /usr/lib/libpcrecpp.so
libpcre.so.3 (libc6,x86-64) => /lib/libpcre.so.3
libpcre.so (libc6,x86-64) => /usr/lib/libpcre.socss
檢查庫文件pcrehtml
root@houzaicun:/home# tar -zxvf nginx-1.0.10.tar.gznginx
root@houzaicun:/home# cd nginx-1.0.10/web
root@houzaicun:/home/nginx-1.0.10# ./configure --prefix=/usr/local/nginx-1.0.10數據庫
make && make installapache
useradd -s /usr/sbin/nologin -M wwwvim
編輯主配置文件:windows
root@houzaicun:/www# vim /usr/local/nginx-1.0.10/conf/nginx.conf後端
user www;
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 65325;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream testser1 {
server 192.168.3.107:7000 weight=5;
}
server {
listen 80;
server_name www.hou.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://testser1;
proxy_redirect off;
proxy_set_header Host www.hou.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
index index.html index.htm;
}
}
}
具體解釋看 個人nginx學習總結。
http://hzcsky.blog.51cto.com/1560073/502778
這裏這個意思是 nginx 80 端口 後端apache7000 。
修改 apache的端口
40 Listen 80 改成7000
重啓服務使其生效!
root@houzaicun:/home/nginx-1.0.10# /usr/local/nginx-1.0.10/sbin/nginx
root@houzaicun:/home/nginx-1.0.10# ps -aux |grep nginx
先修改apache 否則 80端口被佔用
http://192.168.3.107 測試nginx
http://192.168.3.107:7000/info.php 測試修改後的 apache
nginx反向代理結束
五.awstats日誌分析工具安裝與配置
軟件介紹:
Awstats是一個開源的日誌分析工具,它使用Perl語言開發,不只可用於分析
Apache服務器的訪問日誌,還能夠用於分析samba tomcat squid乃至windows
系統中的IIS等網絡服務的日誌信息.
Awstats的軟件包可發從http://awstats.sourceforg.net下載.
解壓並釋放awstats軟件包,執行目錄中的awstats_configure.pl腳本進行安裝。
cd /tools
wget http://awstats.sourceforge.net/files/awstats-6.95.tar.gz
tar zxvf awstats-6.95.tar.gz -C /usr/local
mv /usr/local/awstats-6.95 /usr/local/awstats
cd /usr/local/awstats/tools
./awstats_configure.pl
.............................................
1:輸入apache的安裝路徑
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/apache-2.2.21/conf/httpd.conf#這裏輸入apache的配置文件路徑;
2:下面選擇y 將httpd服務的日誌記錄格式改成 "combined",以便記錄更多詳細信息.
-----> Check and complete web server config file /usr/local/apache-2.2.21/conf/httpd.conf
Warning: You Apache config file contains directives to write 'common' log files
This means that some features can't work (os, browsers and keywords detection).
Do you want me to setup Apache to write 'combined' log files [y/N] ?
3:下面選擇 y 建立新的配置文件.
-----> 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] ?
4:定義日誌分析的目標網站名稱(www.hou.com)
-----> 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:
> www.hou.com
5:定義awstats配置文件的存放目錄(默認爲 /etc/awstats/data)
-----> 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
6:配置完成
-----> Create config file '/etc/awstats/awstats.www.hou.com.conf'
Config file /etc/awstats/awstats.www.hou.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=www.hou.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.www.hou.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.hou.com' with command:
> perl awstats.pl -update -config=www.hou.com
You can also read your statistics for 'www.hou.com' with URL:
> http://localhost/awstats/awstats.pl?config=www.hou.com
Press ENTER to finish...
:修改配置文件
須要在awstats的配置文件中修改所要統計的日誌文件的路徑.查找"LogFile"配置行並修改成正確位置.
vim /etc/awstats/awstats.www.hou.com.conf
##########################################################################################
#設置httpd logfile的位置 +51
LogFile="/www/logs/aw.log"
#設置要分析的服務日誌類型 w表示爲web日誌 +64
LogType=W
#設置日誌格式1表示採用 NCSA apache combined/ELF/XLF log format +123
LogFormat=1
#設置要分析的域名 +154 +169
SiteDomain="www.hou.com"
HostAliases="www.hou.com 127.0.0.1 localhost"
#設置awstats的數據庫存放目錄
DirData="/usr/local/awstats/data"
#設置DirCgi +213 +223
DirCgi="/usr/local/awstats/wwwroot/cgi-bin"
DirIcons="/usr/local/awstats/wwwroot/icon"
#設置經過瀏覽器刷新頁面 +240
AllowToUpdateStatsFromBrowser=1
##########################################################################################
設置相關目錄的權限
mkdir /usr/local/awstats/data
mkdir /www/logs/
touch /www/logs/aw.log
chmod 777 aw.log
:修改httpd.conf配置
vi /usr/local/apache-2.2.21/conf/httpd.conf
##########################################################################################
#Directives to allow use of AWStats as a CGI
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
#This is to permit URL access to scripts/files in AWStats directory.
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
394 # Virtual hosts
395 Include conf/extra/httpd-vhosts.conf 開啓虛擬主機
vim /usr/local/apache-2.2.21/conf/extra/httpd-vhosts.conf
NameVirtualHost 192.168.3.107
<VirtualHost 192.168.3.107>
DocumentRoot "/www"
ServerName www.hou.com
ErrorLog "/www/logs/err.log"
CustomLog "www/logs/aw.log" combined
</VirtualHost>
重啓apache
root@houzaicun:/www/logs# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.hou.com
Create/Update database for config "/etc/awstats/awstats.www.hou.com.conf" by AWStats version 6.95 (build 1.943)
From data in log file "/www/logs/aw.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: 0
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 0 new qualified records.
設置cron計劃任務,以便定時運行日誌分析程序
echo "5 2 * * * root /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.hou.com" >> /etc/crontab
訪問本身的頁面2次,而後
http://192.168.3.107/awstats/awstats.pl?config=www.hou.com
出現數據爲成功!