2003年5月18日 星期日

Apache 的 Log 介紹 (access.log)

參考Apache網站:
http://httpd.apache.org/docs/current/mod/mod_log_config.html


於Apache的設定檔中(httpd.conf)可以找到相關設定
access.log 預設值為

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""

LogFormat "%h %l %u %t \"%r\" %>s %b"

%h:遠端連線主機(通常為IP地址)
%l:遠端身分驗證(IdentityCheck), 通常顯示為"-", 表示這個請求沒有使用者名稱進行身份驗證, 如果使用者名稱存在, 這個欄位會顯示該名稱
%u:如果有做使用者驗證,則紀錄下使用者名稱, 如果沒有通常顯示為"-", 表示這個請求沒有遠端使用者名稱
%t:紀錄連線時間
%r:紀錄連線的請求,格式為 {%m %U%q %H}
        %m:請求方式(GET、POST、OPTIONS...等)
        %U:請求的路徑 url
        %q:查詢的字串
        %H:請求的協議
%s:遠端連線本機回應狀態 (200、403、404、500...等)
%b:伺服器回應的資料量bytes數
%{Referer}i:連線請求來源的網址, 如果用戶端直接輸入網址或是使用一個沒有 referrer的 HTTP方法(如 GET), 這個欄位就會是"-"
%{User-Agent}i:使用者代理, 使用者端的瀏覽器資訊


舉例:
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"

IP:127.0.0.1 的 frank使用者連線, 於 10/Oct/2000:13:55:36 從 http://www.example.com/start.html 以 GET 要求 apache_pb.gif這個檔案, 使用 Win98及 Mozilla瀏覽器

2003年5月7日 星期三

Linux上的網頁流量統計工具-Webalizer

Red Hat Linux 系統中預設就放置了一套網頁流量統計工具: Webalizer, 不需特別設定, 只要 Apache Web Server 啟用之後開始有網頁瀏覽紀錄Log, Webalizer便會自動執行建立出流量統計網頁.

1. Webalizer設定檔放在 /etc/webalizer.conf

2. webalizer.conf 內容
w-studio.idv.tw


2003年5月6日 星期二

使用PHP查看Apaceh Server詳細狀態

另外一種用瀏覽器查看 Apache Server 狀態的方式, 就是使用 PHP

只要建立一個 PHP 檔, 內容為:
<?php
phpinfo();
?>

於瀏覽器網址上輸入檔名, 例: http://www.domain.com/phpinfo.php
接著就能秀出 Apache Server 的詳細資料




2003年5月5日 星期一

查看Apache Server資訊(Server-Info)

Server-Info 可以從瀏覽器觀看 Apache Server 的模組資訊
如同 Server-Ststus 一樣, Server-Info 模組同樣也需載入才能瀏覽, 預設是載入的

LoadModule info_module modules/mod_info.so


同樣的Server-Info這個目錄(路徑)預設是沒有開放的, 須將註解拿掉才能使用
# Allow remote server configuration reports, with the URL of
#  http://servername/server-info (requires that mod_info.c be loaded).
# Change the ".your-domain.com" to match your domain to enable.
#
#<Location /server-info>
#    SetHandler server-info
#    Order deny,allow
#    Deny from all
#    Allow from .your-domain.com
#</Location>
為了網站安全同樣也把 Allow from .your-domain.com 嚴格設定

在網站網址後輸入 /server-info 之後, 則會出現 Apache Server 模組的所有資訊

如果只是想看Server基本資訊, 則在網址處輸入 /server-info?server

利用Apache Server查看主機狀況(Server-Status)

前面有說到在Apache Server設定裡有個可以使用瀏覽器查看主機狀況的功能, 也就是要載入status_module這個模組, 預設是有載入

LoadModule status_module modules/mod_status.so

不過預設目錄(路徑)是沒有開啟, 須把註解拿掉才能使用

# Allow server status reports, with the URL of http://servername/server-status
# Change the ".your-domain.com" to match your domain to enable.
#
#<Location /server-status>
#    SetHandler server-status
#    Order deny,allow
#    Deny from all
#    Allow from .your-domain.com
#</Location>

為了安全問題最好將Allow from .your-domain.com這條嚴格設定, 以免任何人都能看到




2003年5月4日 星期日

Apache2.0.40 的設定(in Red Hat 9 Linux)-3

關於Apache2.0.40設定的第三部分: 虛擬主機(Virtual Host)

虛擬主機也就是不同的網址(FQDN)使用同一個IP, 要建立虛擬主機要先有DNS Server設定好網址或是向網域註冊單位申請一個網域名稱(domain)

#NameVirtualHost *
.虛擬主機的網址

.虛擬主機的相關設定
#<VirtualHost *>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

Apache2.0.40 的設定(in Red Hat 9 Linux)-2

關於Apache2.0.40的設定第二部分, 為Server的主要設定, 介紹幾個重要部分:

ServerAdmin root@localhost
.系統管理者的E-mail, 可設定或不設

ServerName localhost.localdomain:80
.網站網址的設定, 預設為local, 如有申請網址則可設為 www.your-domain.com:80
Apache Server 預設首頁


Apache2.0.40 的設定(in Red Hat 9 Linux)-1

Apache的設定檔位在 /etc/httpd/conf/httpd.conf, 開頭就說到設定總共分為三個部分:

1.控制整個Apache Server操作的指令(全域環境)
2.定義Server參數的指令, 這些指令還為所有虛擬主機的設置提供默認值
3.虛擬主機的設置, 允許將Web請求發送到不同的IP地址或主機名, 並讓它們由同一個Apache Server處理


第1部分幾個重要設定:
ServerRoot "/etc/httpd"
.Apache 設定檔放在這裡

Listen 80
.Apache預設使用的port, 如無特別需求則不要更改, 記得之前還有一個Port 80的設定, 這版被拿掉了

Include conf.d/*.conf
.Apache其他設定檔位置

LoadModule ***_module modules/mod_***.so
.動態分享物件Dynamic Shared Object (DSO), Apache的功能模組, 搭配<IfModule ***>***</IfModule>標籤使用


Apache 2.0.40 in Red Hat Linux 9 設定檔

其實設定不多, 只是一大堆說明, 之後再慢慢介紹

#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs-2.0/> for detailed information about
# the directives.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned. 
#
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process as a
#     whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' server,
#     which responds to requests that aren't handled by a virtual host.
#     These directives also provide default values for the settings
#     of all virtual hosts.
#  3. Settings for virtual hosts, which allow Web requests to be sent to
#     different IP addresses or hostnames and have them handled by the
#     same Apache server process.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "/etc/httpd" will be interpreted by the
# server as "/etc/httpd/logs/foo.log".
#

2003年5月3日 星期六

安裝Red Hat Linux 9 (Shrike)

Red Hat Linux 9 (Shrike), 這版算是 Red Hat 的最終桌面版, 之後都以伺服器版開發, 也就是Red Hat Enterprise Linux 版, 而桌面版後來與 Fedora 合併, 之後都以 Fedora Core 發行

1. 開始安裝, 使用的是 Red Hat Linux 9 (Shrike), 注意是9而不是9.0
w-studio
2. 這時會跳出測試光碟, 跳過即可