Linux自宅サーバー構築
LinuxサーバーTOP
BBS
Linuxサーバー構築
INFORMATION
LINK
MAIL
 

 

webサーバの構築 Apacheの設定

最終更新 2003年6月18日

やっとこここまでこぎつけました。webサーバの設定です編集するファイルは/etc/httpd/conf/httpd.confです。設定ファイルは長いです全部約1000行もありました。編集する前にオリジナルを名前を別名に変えてコピーしておきましょう。また行数は環境などによって違うと思いますので参考程度にしてください。ほんじゃまいってみよー

43行目
Full、OS、Minor、Minimal、Major、Prodに変更可能です。
Fullの場合apacheサーバであることなどの詳細データが詳細に表示されるのでセキュリティのことを考えMinimalに設定。最初は大文字です。

# Don't give away too much information about all the subcomponents
# we are running. Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
ServerTokens OS

ServerTokens Minimal


83行目

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive Off

KeepAlive On


90行目

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

MaxKeepAliveRequests 1000


259行目

# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin root@localhost

ServerAdmin webmaster@paopao.org


274行目

#ServerName new.host.name:80

ServerName www.paopao.org:80


283行目最後の/などの未入力を自動補完します。

# ServerName directive.
#
UseCanonicalName Off

UseCanonicalName On


290行目
サーバのURL(この場合www.paopao.org)でリクエストがあった場合のトップページ(ホームページ)をおいておくディレクトリです。わたしは変更していません。サーバのURLでアクセスした場合/var/www/htmlディレクトリ内のindex.htmlという名前のHTMLファイルを表示します。

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"


300行目変更なし

# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>


329行目
その要求されたページがディレクトリにない場合、ディレクトリ内部の全てのファイルを一覧表にして送信してしまいます。ちょーお間抜けでセキュリティ上もよくないです。

# 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 <=Indexesを削除

Options FollowSymLinks


336行目変更なし

# 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

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all


380行目
ユーザーアカウントのディレクトリを定義。ユーザ(家族の誰か)がWEBサイトを公開する場合は、各自ユーザのディレクトリの中にwwwという名前のディレクトリ(パーミッションは755)を作成し、その中にアップロードします。

# 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 www


385行目変更なし。各ユーザのホームディレクトリの命令許可は全て#で起動停止です。

# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory /home/*/public_html>
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
# <Limit GET POST OPTIONS>
# Order allow,deny
# Allow from all
# </Limit>
# <LimitExcept GET POST OPTIONS>
# Order deny,allow
# Deny from all
# </LimitExcept>
#</Directory>


409行目
もしユーザが自分のwebページを作るときにトップページの拡張子は以下のものにしましょう。私の場合”index.htmlだよー”と嫁に言えばokです。

# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.html index.htm index.html.var


415行目ユーザーでありながら自分のディレクトリは、rootよりも自由に設定出来ることになってしまいます。非常にこまります。禁止!!

# AccessFileName: The name of the file to look for in each directory
# for access control information. See also the AllowOverride directive.
#
#AccessFileName .htaccess <=#をつけて禁止


518行目エラーページなどにアパッチのバージョン番号などを表示しないようにします。

# Optionally add a line containing the server version and virtual host
# name to server-generated pages (error documents, FTP directory listings,
# mod_status and mod_info output etc., but not CGI generated documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
ServerSignature On

ServerSignature Off


562行目
●/var/www/html以下のディレクトリでは全てCGIを使用可能にします。
● /home/ユーザー/wwwではcgi-binディレクトリを作成してそのディレクトリのみでCGIを許可する。
赤字の部分を追加しました。
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
#ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" <=#をつけて禁止

<IfModule mod_cgid.c>
#
# Additional to mod_cgid.c settings, mod_cgid has Scriptsock <path>
# for setting UNIX socket for communicating with cgid.
#
#Scriptsock run/httpd.cgid
</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
#<Directory "/var/www/cgi-bin">
# AllowOverride None
# Options None
# Order allow,deny
# Allow from all
#</Directory>

<Directory "/var/www/html">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

<Directory "/home/*/www/cgi-bin"> <=*なので全ユーザ(嫁だけ)を示す
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>


835行目(オリジナルの行数)
上記の設定のままではまだCGIを稼動させることは出来ませんのでこの行の#を取って有効にします。また拡張子として.cgiのほかに.plを加えます。記入時には頭のピリオドを忘れないように

#AddHandler cgi-script .cgi

AddHandler cgi-script .cgi .pl


754行目(オリジナルの行数)
アパッチ2.0の初期設定の標準言語は西ヨーロッパ言語になっています。日本語の文字コードのsjis、eucで作ったウェブサイトがきょーれつに文字化けしてしまいこれをみた方々はアクセスするたび、リロードするたびにブラウザの文字設定を日本語にしなくてはいけませんこれではアクセスしていただいた方々に申し訳ないので(それよりももうきてくれないよこれじゃ)以下の設定をします。
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#
LanguagePriority ja en da nl et fr de el it kr no pl pt pt-br ltz ca es sv tw

#
# ForceLanguagePriority allows you to serve a result page rather than
# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)
# [in case no accepted languages matched the available variants]
#
ForceLanguagePriority Prefer Fallback

#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to javascript and URL parsing
# which encourage you to always set a default char set.
#
AddDefaultCharset ISO-8859-1
AddDefaultCharset shift_jis
AddDefaultCharset EUC-JP
AddDefaultCharset none


入力ミスがないか確認

# httpd -t
Syntax OK


起動時の設定をしてスターーーート

#chkconfig --level 35 httpd on

#/etc/init.d/httpd start

あああぁっぁぁずがれだぁーーーやっとおわっだーーーさてこれでウェブサイトが後悔じゃなくて公開できますがはてしない更新の道が待っています・・・・・それではぐっどらっく


linuxトップ | dhcpにもどる | お次samba

 


linux自宅サーバーPAOPAO
リンクはご自由に!
yasu@paopao.org
 
パオパオ、ぱおぱお