第6回:PS3にLinux……定番のApache起動

さて、Linux初心者定番のApache起動をやってみます。

とりあえず設定を何もいじらずにApacheを起動させてみます。

[root@ps3 ~]# service httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for ps3.localdomain
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]

なんか警告が出てきましたけれど、とりあえず動いたようです。
Webブラウザを立ち上げて、http://XXX.XXX.XXX.XXXとPS3のIPアドレスを直打ちしてApacheを呼び出すと、おなじみの画面が現れました。


次にApacheの諸設定に取りかかります。まずはいったんApacheを停止します。

[root@ps3 ~]# service httpd stop
Stopping httpd: [ OK ]

Apacheの設定ファイルを開きます。

[root@ps3 ~]# vi /etc/httpd/conf/httpd.conf

■設定1
#
# 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 www.example.com:80
→独自ドメインを取っていないので、PS3 Linuxに当ててあるIPアドレスを指定
ServerName XXX.XXX.XXX.XXX:80


■設定2
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disable
→#をつけてコメントアウトする。
#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
→#をとってコメント解除する。
UserDir public_html
→下記2行を追加
AliasMatch ^/fedora(.*) /home/fedora/public_html/$1
← fedoraユーザーのみhttp://fedorasrv.com/fedora/のように~(チルダ)なしでアクセスできるようにする
AliasMatch ^/userdir/([^/]+)/(.*) /home/$1/public_html/$2
← 全てのユーザーでhttp://fedorasrv.com/userdir/ユーザー名/でアクセスできるようにする


■設定3
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
#
# Order allow,deny
# Allow from all
#

#
# Order deny,allow
# Deny from all
#

#


の#を取ってコメント解除。


AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

Order allow,deny
Allow from all


Order deny,allow
Deny from all


いったんファイルを保存して、文法チェッカーにかけてみます。

[root@ps3 ~]# apachectl configtest
Syntax OK

ということで、設定ファイルに問題ないようです。
Apacheを再起動します。

[root@ps3 ~]# service httpd start
Starting httpd: [ OK ]

今度は警告メッセージもなしでスカッと起動しました。
先ほどの設定で自分のホームディレクトリにファイルを置き、Apacheでアクセスできるようになりました。じゃあテストということで、ホームディレクトリに public_html というディレクトリを作ってWebからアクセスしてみます。

[hoge@ps3 ~]$ mkdir public_html

Webブラウザからアクセスすると、こんな画面になりました。


public_htmlファイル内は空なので、"Requested page not found"と言われますが、動作は正常です。

最後に、PS3 Linuxを起動したときにはApacheも自動起動するよう設定しておきます。

[root@ps3 ~]# chkconfig --level 35 httpd on

これで一通りApache周りの設定は完成です。

0 件のコメント:

コメントを投稿