ホームページサーバー (Webサーバー)の構築
設定が不要なレンタルサーバーもあるよ→ Click Here!

このページでは、自宅サーバーにホームページ表示ができるように設定し、ホームページを掲載して、ネットワーク上(イントラやインターネット)で閲覧できる仕組みを構築する方法を書いてみました。これによって社内の簡単なイントラネットも構築できますよ。
なお、条件として、Apacheがインストールされていることが必要です。もし、インストールされていない場合は、インストールをしてください。

▼設定ファイルの編集

 ・httpd.confファイルを編集する。 /etc/httpd/confの直下にあるはずだが、インストールした方法によって少し変わる場合がある。

[root@linux ~]# vi /etc/httpd/conf/httpd.conf ← viでhttpd設定ファイル編集
ServerTokens OS

ServerTokens Prod   
← エラーページ等でOS名を表示しないようにする

ServerAdmin root@localhost

ServerAdmin webmaster@zou-san.homeip.net  
← エラーページ等に表示される管理者メールアドレスを指定

#ServerName new.host.name:80

ServerName zou-san.homeip.net:80  
← サーバー名を指定(各自のサーバー名だよ)

<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
  ↓
Options Includes ExecCGI FollowSymLinks 
 ← CGI,SSIの使用を許可する
  
※Indexesはindex.htmlなどのファイルをディレクトリィに配置しておかないと
    構造が丸わかりになってしまうので扱いに注意しましょう。
    Indexesはセュリティ上は外してしまったほうがいいです。


#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
  ↓
AllowOverride All  
← .htaccessの使用を許可するという意味
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 
← 長すぎるURI(414エラー)はログに記録しない

#
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
SetEnvIf Request_URI "default\.ida" no_log  
  ← 追加(wormからのアクセスをログに記録しないという設定)
SetEnvIf Request_URI "cmd\.exe" no_log     
←       〃
SetEnvIf Request_URI "root\.exe" no_log     
←       〃
SetEnvIf Request_URI "Admin\.dll" no_log     
←       〃
SetEnvIf Request_URI "NULL\.IDA" no_log    
←       〃
SetEnvIf Request_URI "\.(gif)|(jpg)|(png)|(ico)|(css)$" no_log  
← 追加(gif,jpg,png,ico,cssへのアクセスをログに記録しない)
SetEnvIf Remote_Addr 192.168.1 no_log   
    ← 追加(内部からのアクセスをログに記録しない)
CustomLog logs/access_log combined env=!no_log 
← 上記以外のアクセスをログに記録する

ServerSignature On

ServerSignature Off   
     ← エラーページ等でApacheのバージョンを表示しないようにする

AddDefaultCharset UTF-8

#AddDefaultCharset UTF-8 
    ← コメントアウト(デフォルトの文字のコード)

#AddHandler cgi-script .cgi

AddHandler cgi-script .cgi .pl   ← CGIスクリプトに.plという拡張子を追加


LanguagePriority ja en ca cs da de el eo es et fr he hr it ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
※日本語の文字化け防止に上記のように日本語をあらわす、ja を一番頭にもってくる。

 ・ユーザーディレクトリを公開する設定(/~zousan/などのようにユーザーごとにスタートページを持つ設定)

#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disable     
 ← コメントにしてユーザーディレクトリを使用可能にする

#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#
UserDir public_html     
← public_html の下にhtmlを置くよっていう設定

<user directory ....

 ・スタートページで特定のユーザーのページを表示させるようにする設定(サーバーのメインアドレスに表示させるHPの場所を指定)

DocumentRoot "/var/www/html"
   ↓
DocumentRoot "/home/zousan/public_html"  
← 特定のユーザーを指定する。この場合はzousanを指定している。

 ・Webサーバーの起動(手動による起動方法)


[root@linux ~]# /etc/init.d/httpd start     ← httpd起動のコマンド

 ・ホームページ表示等のテストをして、動作がうまく行く場合は、Webサーバーの自動起動の設定をする。(サーバーの再起動時自動起動する)

[root@linux ~]# chkconfig httpd on         ← httpd 自動起動設定のコマンド

[root@linux ~]# chkconfig --list httpd      
← httpd 自動起動設定確認をする
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off    
← ランレベル2〜5のonを確認する


■これで、ホームページを表示する仕組みができました。
次は、インターネットの世界に自分のサイトを公開しましょう!

外部に公開するのにはダイナミックDNSを使います。


戻る Webページの表示確認  Click Here!
メールサーバーの設定 ダイナミックDNSについて  ゾウの使用しているブラウザです
プロキシサーバーの設定 快適だよ。
2006.02.4 更新