![]() |
【Windowsでの遠隔計測にApacheを使おう!】 |
最終更新日 /2006/06/14/ |
|
|
|
|
|
|
![]() 【Windowsでの遠隔計測にApacheを使おう!】 「自宅のWindowsパソコンをサーバーにしてHPを公開したい」とか「WWWやLANで計測データを遠隔監視したい」などと思ったことはありませんか?Apacheは誰でも無償で使えるHTTPサーバーです。 このページではApacheの「基本的な設定方法」を紹介します。 Page 3 |
|
|||||
このドキュメントの先頭へ戻る |
![]() |
進む | ||||
|
【設定手順2】
次にApache HTTP server の基本設定を行います。 下の例では黄色の部分を設定しました。 1) ServerAdmin にはサーバー管理者へのメールアドレスを記入します。 2) ServerName にはドメインを取得し、DNSサーバーに登録済みのサーバー名称と使用するポート番号を記入します。 しかし、まだDNSサーバーに未登録であったり、LAN内でしか使わない場合にはIPアドレスと使用するポート番号を記入します。 3) DocumentRoot にはindex.htmをはじめとするweb公開するHTML文書が格納されたディレクトリ・パスを書きます。 "\"記号は使わず、"/"(バックスラッシュ)記号を使います。最後尾に"/"は入れません。 4) 使用するディレクトリ毎にアクセス権を指定することができます。<Directory >から</Directory>で囲まれた領域で指定します。 <Directory "C:/MyDoc/NeoTechLab/20060525"> は指定ディレクトリ"C:/MyDoc/NeoTechLab/20060525"に関するアクセス権を設定することを示しています。 Order allow,deny はアクセス許可者のリスト⇒アクセス禁止者のリストの順にアクセス権を設定することを示しています。 続くAllow from allでは取り敢えず全員にアクセス許可を出します。 次に改めてその中からアクセスを禁止するドメインやIPアドレスを指定してゆきます。 Deny from nantara.co.jp honyarara.com Deny from 133.10 では"nantara.co.jp"と"honyarara.com"、それと"133.10"を含むIPアドレスが禁止されています。 5) DirectoryIndex index.htmは例えばURL http://www.neo-tech-lab をアクセスした場合にデフォルトで呼び出されるHTML文書を指定する文です。 6) <FilesMacth>の部分は特定の条件を満たすファイルを不可視にする指定です。 デフォルトで下の例のように設定されています。これによって、.htaccess や .htpasswd のようなセキュリティー上閲覧されると困るファイルを不可視にすることができます。 7) LogFormatでは、カスタムログの書式の定義とその書式にニックネームをつけます。 カスタムログ書式の詳しい指定方法に関しては http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats を参考にしてください。 設定例)LogFormat "special" では %aでIPアドレス、%hでリモートホスト名、%tで標準英語時刻表記、%s>で最後の状態、%bがレスポンスのバイト数 などを記録している。 <IfModule log_config_module> LogFormat "%a %h %l %u %t %>s %b \"%r\" \"%{User-Agent}i\"" special CustomLog logs/access.log special </IfModule> 実際のログ) 192.168.0.3 ceres - - [16/Jun/2006:15:18:49 +0900] 304 - "GET / HTTP/1.1" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; .NET CLR 1.1.4322)" 192.168.0.3 ceres - - [16/Jun/2006:15:18:54 +0900] 304 - "GET /Music.files/Galactic.mid HTTP/1.1" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; .NET CLR 1.1.4322)" 192.168.0.3 ceres - - [16/Jun/2006:15:18:54 +0900] 304 - "GET /index.files/Background.jpg HTTP/1.1" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; .NET CLR 1.1.4322)" 192.168.0.3 ceres - - [16/Jun/2006:15:18:54 +0900] 304 - "GET /index.files/NeoTechLabLogo.gif HTTP/1.1" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; .NET CLR 1.1.4322)" 192.168.0.3 ceres - - [16/Jun/2006:15:18:54 +0900] 304 - "GET /index.files/Top_ip.jpg HTTP/1.1" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; .NET CLR 1.1.4322)" |
|
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# 'Main' server configuration # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #【ServerAdmin】サーバー管理者のメールアドレス ServerAdmin info@neo-tech-lab.com #【ServerName】サーバー名称と使用するポート # もし、DNSサーバーにサーバー名称を未登録ならIPアドレスとポートを記述する。 ServerName 192.168.0.14:80 #ServerName www.neo-tech-lab.co.uk:80 #【DocumentRoot】公開するHTMLドキュメントを置くルートディレクトリ #DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" DocumentRoot "C:/MyDoc/NeoTechLab/20060525" # Apacheは指定ディレクトリごとにアクセス許可を設定することができる。 #<Directory "C:/"> # Options FollowSymLinks # AllowOverride None # Order deny,allow # Deny from all # Allow form 192.168.0.14 # Satisfy all #</Directory> # 上の指定で特定の許可したもの以外のアクセスを禁止 <Directory "C:/MyDoc/NeoTechLab/20060525"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all Deny from nantara.co.jp honyarara.com Deny from 133.10 </Directory> #【DirectoryIndex】もしURLにディレクトリが指定された場合、自動的にindex.htmを選択 <IfModule dir_module> DirectoryIndex index.htm </IfModule> # セキュリティ上の問題で.htaccess や .htpasswd ファイルを不可視にする <FilesMatch "^\.ht"> Order allow,deny Deny from all </FilesMatch> # ErrorLogの位置 ErrorLog logs/error.log #【LogLevel】エラーログを残すレベルを指定する # debug, info, notice, warn, error, crit, alert, emergの指定が可能 LogLevel warn <IfModule log_config_module> # ログの書式ごとにニックネーム(combined, common)を付ける。 LogFormat "%a %h %l %u %t %>s %b \"%r\" \"%{User-Agent}i\"" special LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> # You need to enable mod_logio.c to use %I and %O LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> #アクセスログはcommon書式で設定する。 CustomLog logs/access.log special #CustomLog logs/access.log common #CustomLog logs/access.log combined #CustomLog logs/access.log combinedio </IfModule> |