Fedora 11
Sponsored Link

httpd 設定2009/06/14

[1] Webサーバーの設定です。一般ユーザーでのWebサイトの公開と 任意のディレクトリでのCGIの実行ができるように設定します。SSIは必要性が薄いため未使用にします。 サーバーの名前等は自分の環境に置き換えて設定してください。
[root@www1 ~]#
vi /etc/httpd/conf/httpd.conf


# 44行目:変更

ServerTokens
Prod


# 74行目:キープアライブオン

KeepAlive
On


# 248行目:管理者アドレス指定

ServerAdmin
root@srv.world


# 262行目:サーバーネーム指定

ServerName
www1.srv.world:80


# 317行目:変更 (Indexes は削除)

Options FollowSymLinks
ExecCGI


# 324行目:変更

AllowOverride
All


# 352行目:#をつけてコメント化

#
UserDir disable

# 359行目:行頭の#を削除

UserDir public_html

# 367行目 - 378行目:行頭の#を削除

<Directory /home/*/public_html>
    AllowOverride
All
# 変更

    Options
ExecCGI
# CGI有効

    <Limit GET POST OPTIONS>
         Order allow,deny
         Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
         Order deny,allow
         Deny from all
    </LimitExcept>
</Directory>

# 388行目:ディレクトリ名のみでアクセスできるファイル名を追加

DirectoryIndex index.html
index.cgi index.php


# 521行目:変更

ServerSignature
Off


# 744行目:コメント化

#
AddDefaultCharset UTF-8

# 781行目:行頭の#を削除しCGIとして扱うファイルの拡張子を追加

AddHandler cgi-script .cgi
.pl


[root@www1 ~]#
/etc/rc.d/init.d/httpd start

Starting httpd:
[ OK ]

[root@www1 ~]#
chkconfig httpd on

[2] HTMLテストページを作成して動作確認をします。以下のようなページが表示されればOKです。
[root@www1 ~]#
cd /var/www/html

[root@www1 html]#
vi index.html


<html>
<body>
<div style="width:100%;font-size:40px;font-weight:bold;text-align:center">
Test Page
</div>
</body>
</html>
 
[3] CGIテストページを作成して動作確認をします。以下のようなページが表示されればOKです。
[root@www1 ~]#
cd /var/www/html

[root@www1 html]#
vi index.cgi


#!/usr/local/bin/perl

print "Content-type: text/html\n\n";
print <<"EOM";
<html>
<body>
<div style="width:100%;font-size:40px;font-weight:bold;text-align:center">
CGI Test Page
</div>
</body>
</html>
EOM
exit;


[root@www1 html]#
chmod 705 index.cgi

 
[4] PHPテストページを作成して動作確認をします。以下のようなページが表示されればOKです。
[root@www1 ~]#
cd /var/www/html

[root@www1 html]#
vi index.php


<html>
<body>
<div style="width:100%;font-size:40px;font-weight:bold;text-align:center">
<?php
print Date("Y/m/d");

?>
</div>
</body>
</html>
 
関連コンテンツ