広告・Googleアドセンス728px

Article(記事)

Web Server構築

投稿日:2004年7月11日 更新日:

ご注意ください
この記事は2年以上前に書かれたものですので、内容が古い可能性があります。

Apacheを起動しましょう。

○ /etc/httpd/conf/httpd.confを修正

サーバ管理者のメールアドレスを指定
#
# 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 webmaster@kamata-net.com

サーバ名前を指定
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work. See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
#ServerName new.host.name:80
ServerName www.kamata-net.com:80

URLに「/」を補完する
#
# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client. When set "On", Apache will use the value of the
# ServerName directive.
#
#UseCanonicalName Off
UseCanonicalName On

ログにはIPアドレスではなく、ホスト名を表示するように指定
#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups On

.htaccessを有効にする
<Directory "/var/www/html">
Options Indexes FollowSymLinks
# AllowOverride None
AllowOverride All
Order allow,deny
Allow from all
</Directory>

日本語が化けないようにする
#
# 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

○.htaccess変更

しらなかったんだけど、旧サーバはapache1.3で今回はapache2。
.htaccessの書式が一部古かったせいでtext/htmlとして処理できずに「ファイルのダウンロード」画面になってしまいindex.htmlが正常に表示されないという事象が発生しました。

本当は

[root@www]# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.kamata-net.com

HTTP/1.1 200 OK
Date: Sun, 11 Jul 2004 13:19:22 GMT
Server: Apache/1.3.6 (Unix) (Red Hat/Linux)
Last-Modified: Sun, 16 Jul 2000 03:49:48 GMT
ETag: "4002-48-397130dc"
Accept-Ranges: bytes
Content-Length: 72
Content-Type: text/html★

このように表示されなければいけないのに、新サーバでは、

[root@www2]# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
Host: blog.kamata-net.com

HTTP/1.1 200 OK
Date: Sun, 11 Jul 2004 12:36:28 GMT
Server: Apache/2.0.49 (Fedora)
Last-Modified: Sun, 16 Jul 2000 03:49:48 GMT
ETag: "199ec-48-67c8ef00"
Accept-Ranges: bytes
Content-Length: 72
Connection: close
Content-Type: text/x-server-parsed-html ★

Content-Typeが違う。いろいろ調べてみた結果、.htaccess中の以下の記述は古い。

古い.htaccess書式

Options None Includes ExecCGI

AddType text/x-server-parsed-html .html
AddType text/x-server-parsed-html .htm

正解はこちらでした。

新しい.htaccess書式

Options None Includes ExecCGI

AddHandler server-parsed .html
AddHandler server-parsed .htm

この記事は役に立ちましたか?評価をお願いいたします。
[合計: 0 平均: 0]

広告336px

広告336px

-Article(記事)
-Apache, Linux

Copyright© 蒲田ネット , 2017 AllRights Reserved.