さくらのVPS

Apacheとは?

  • Webサーバソフトとして、標準的な「Apache(アパッチ)」をインストールしてみます。
  • Apache以外だと、「nginx(エンジンエックス)」も人気が出てきているようです。

(参考)
http://ja.wikipedia.org/wiki/Apache_HTTP_Server
http://ja.wikipedia.org/wiki/Nginx

Apacheのインストール

(参考)
http://akibe.com/2010/09/centos-setup-4-apache/

  • yumでApacheをインストール
# yum -y install httpd
# httpd -v
# /etc/rc.d/init.d/httpd start
# chkconfig httpd on
# chkconfig --list httpd

httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

Apache設定ファイルの編集

  • 元ファイルをコピーしてから vi で開きます。
# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
# vi /etc/httpd/conf/httpd.conf

(以下の表記で、「--」は削除する行、「++」は追記する行を意味しています。つまり、「--」と「++」の二つ合わせて、書き換える部分を示しています。)

  1. レスポンスヘッダにOSのバージョンを表示させない
    -- ServerTokens OS
    ++ ServerTokens Prod
  2. KeepAliveを有効にする
    -- KeepAlive Off
    ++ KeepAlive On
  3. サーバー管理者の指定
    -- ServerAdmin root@localhost
    ++ ServerAdmin info@mydomain.com
  4. サーバー名の指定
    -- ServerName new.host.name:80
    ++ ServerName mydomain.com:80
  5. DocumentRootの確認
    DocumentRoot "/var/www/html"
  6. ディレクトリ内のファイル表示を無効化
    <Directory "/var/www/html">
    :
    -- Options Indexes FollowSymLinks
    ++ Options -Indexes FollowSymLinks → mod_rewriteを使う場合はダメ?
    :
    </Directory>
  7. indexの設定
    -- DirectoryIndex index.html index.html.var
    ++ DirectoryIndex index.html index.php index.cgi index.html.var

Apache設定のチューンナップ

(参考)
http://d.hatena.ne.jp/koujirou6218/20101129/
=必要に応じて設定値を変更する。

Apache再起動で設定変更を反映

# /etc/rc.d/init.d/httpd restart

DocumentRootの所有者変更

Apacheで公開ディレクトリーとなっている「/var/www/html」 というディレクトリのユーザーとグループを「sakura」に変更します。
(この設定メモでは、作業用ユーザーのアカウント名を「sakura」として説明しています。)

# chown sakura:sakura /var/www/html

これで、WinSCPやFFFTPで、コンテンツのファイルやフォルダをアップロードできるようになるはず。
=公開ディレクトリーの所有者を変更していないと、「アクセス権限がない」というようなエラーが出ます。


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2011-05-01 (日) 22:57:46 (4737d)