俺はDebian使いなので、apacheのパッケージメンテナのディフォルト設定を多く使っているのでほとんどカスタマイズしてないです。
が、俺の知識が無いために結構苦労した事もあったのでメモを残そうかと。
やりたかった事は
- apacheのディフォルト文字コードiso-8859の解除
- $HOME/public_html/をユーザーのディフォルトに
- $HOME/public_html/cgi-bin/でCGIやSSIの実行
- Namazu検索で/usr/share/doc/以下の文書を検索
これくらいですな。
ちなみに、apacheを動作させてるコンピュータに接続できるクライアントが高度に信頼できる場合のみ以下をお読み下さい。この設定のせいでクラックされたとか、コンピュータの挙動がおかしくなったとかいっても責任はとれないッス。
現在入れてるapache関連のパッケージは以下に示します。
- apache
- apache-common
- apache-doc
- libapache-mod-auth-plain
- libapache-mod-cgi-debug
- libapache-mod-filter
- libapache-mod-gzip
- libapache-mod-layout
- libapache-mod-perl
- libapache-mod-ruby
- libapache-mod-speedycgi
- libapache-mod-ssl
- libapache-mod-ssl-doc
- libapache-mod-text2html
- webmin-apache
まぁ、あんまり入れ過ぎても使い切れませんから、俺程度ならこれくらいで十分過ぎますね。
いじった設定ファイルは/etc/apache/http.confです。
apacheのディフォルト文字コードiso-8859の解除
apacheを入れたてではでページ毎に文字コードを設定しても無視され、日本語が文字化けしてしまいます。これを解除するために、以下の設定をしました。
/etc/apache/http.conf
# Default charset to iso-8859-1 (ttp://www.apache.org/info/css-security/). AddDefaultCharset on
以上にある AddDefaultCharset on の部分をコメントアウトし、AddDefaultCharset off を書き加え。以下のようにしました。
/etc/apache/http.conf
# Default charset to iso-8859-1 (ttp://www.apache.org/info/css-security/). #AddDefaultCharset on AddDefaultCharset off
以上の変更でMozillaやGaleon(GEKKOだから比較する意味はないかも…)の文字コード自動判別が効くようになりました。
$HOME/public_html/をユーザーのディフォルトに
ディフォルトで設定されていたかは忘れましたが一応紹介。
この設定が無いとapacheのルートフォルダ/var/www/以下しか見る事ができません。そこで個々のユーザがWeb Pageを公開できるようにしたいと思います。
/etc/apache/http.conf
#
# 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 PROPFIND>
Order allow,deny
Allow from all
</Limit>
<Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Order deny,allow
Deny from all
</Limit>
</Directory>
これで /home/hoge/public_html/ が http://localhost/~hoge/ になります。
ちなみにこの設定ではCGI&SSIは動きません。
$HOME/public_html/cgi-bin/でCGIやSSIの実行
以下に示すように ## User Setting 以下を追加して下さい。
/etc/apache/http.conf
#
# 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/ /usr/lib/cgi-bin/
#
# "/usr/lib/cgi-bin" could be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
## User Setting
<Directory /home/*/public_html/cgi-bin/>
AllowOverride None
Options Indexes FollowSymLinks MultiViews ExecCGI
Order allow,deny
Allow from all
</Directory>
あと、拡張子で実行するかどうかの設定をします。とりあえず標準的なもの(.cgi;.sh;.pl)を設定しています。
/etc/apache/http.conf
# # AddHandler allows you to map certain file extensions to "handlers", # actions unrelated to filetype. These can be either built into # the server or added with the Action command (see below). # # If you want to use server side includes, or CGI outside # ScriptAliased directories, uncomment the following lines. # # To use CGI scripts: # AddHandler cgi-script .cgi .sh .pl
以上で /home/hoge/public_html/cgi-bin/http://localhost/~hoge/cgi-bin/ 以下でCGIが動くようになります。
SSIも動かしたい場合は Option に Includes を追加すると動くようになります。
Namazu検索で/usr/share/doc/以下の文書を検索
ディフォルトでは以下のようになっています。~
/etc/apache/http.conf
# Allow access to local system documentation from localhost. # (Debian Policy assumes /usr/share/doc is "/doc/", at least from the localhost.) Alias /doc/ /usr/share/doc/ <Location /doc> order deny,allow deny from all allow from 127.0.0.0/255.0.0.0 Options Indexes FollowSymLinks MultiViews </Location> <Directory "/usr/share/doc"> </Directory>
このままでは127から始まるネットワークと255から始まるネットワークに属しているコンピュータからのみ閲覧できます。しかし、私のコンピュータは192.168.xxx.xxxなので閲覧できない事になります。
この問題を回避するために以下のように修正しました。
/etc/apache/http.conf
# Allow access to local system documentation from localhost. # (Debian Policy assumes /usr/share/doc is "/doc/", at least from the localhost.) Alias /doc/ /usr/share/doc/ <Location /doc> # order deny,allow # deny from all # allow from 127.0.0.0/255.0.0.0 order allow,deny allow from all Options Indexes FollowSymLinks MultiViews </Location> <Directory "/usr/share/doc"> </Directory>
これですべてのコンピュータで閲覧できます。セキュリティーの問題がある方は適宜変更して下さい。おれはプライベートIPだしGatwayにはFireWallもついてるしプライベートネットワークの中には俺しかいないんでこのままでいいや。
最後に、rootになって # /etc/init.d/apache restart と打つと設定が反映されます。
0 件のコメント:
コメントを投稿