ドメインの取得もできたので、次にWebサーバーを構築していきます。
Webサーバーでよく知られているApache(httpd)を導入します。
作業は初期設定同様、基本的にスーパーユーザ(su)で行います。
- インストール
まずはインストールされているか確認。ServerMansは最初から入ってたかも。。。なのでまずはインストールされているか確認。
1rpm -qa | grep httpd
インストールされていなければ、下記コマンドを実行する
1yum -y install httpd
合わせてphpもインストールしておきましょう。
1yum -y install php php-mbstring - httpd.confの設定
インストールができたら、設定ファイルを編集します。
1vim /etc/httpd/conf/httpd.conf
ファイル内、該当箇所を編集します。
12345678910111213141516171819202122232425262728293031323334ServerTokens Prod # エラーページ等でOS名を表示しないServerName shamaton.orz.hm:80 # 取得したドメインにする<Directory "/var/www/html">...(省略)...# http://httpd.apache.org/docs-2.0/mod/core.html#options# for more information.#Options Includes ExecCGI FollowSymLinks # CGI,SSIの許可## 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 All # .htaccessを許可する...(省略)...ServerSignature Off # エラーページでサーバー情報を表示しない#AddDefaultCharset UTF-8 # 文字化けするのでコメントアウトAddHandler cgi-script .cgi .pl # CGIスクリプトに.plを追加する<Directory "/var/www/icons">Options MultiViews # iconsのファイル一覧を表示しないAllowOverride NoneOrder allow,denyAllow from all</Directory> - 不要ページ削除
これらのページは使わないので削除します。
12rm -f /etc/httpd/conf.d/welcome.confrm -f /var/www/error/noindex.html - ドキュメントルートの所有者を変更
ホームページを置く場所の所有者を自分にします。
12chown hoge. /var/www/html/ # 所有者をユーザー:hogeにするls-al # 所有者が変更されているか確認 - httpd起動
Webサーバーを起動しましょう。すでにしてるならrestartでOK。
12/etc/init.d/httpd start # apache(httpd)起動/etc/init.d/httpd restart # 再起動
テストページを作成して、こちらでアクセスできるかチェックしましょう。
WebsiteTestのラジオボタンにチェックを入れ、サーバーのアドレスを入力しましょう。
1echo test >> /var/www/html/index.html
結果のStatusにOKと表示されれば、外部からのアクセスが可能です。 - 後始末
最後にテストページを削除して完了です。
1rm -f /var/www/html/index.html - その他のテスト…
試してみたい、もしくは必要ならば行いましょう。
下記サイトが参考になります。
Webサーバー構築(Apache) – Webサーバー確認