AmazonLinuxでWEBサーバー環境構築

会社のサービスリリース前の練習用の環境でやってみた。
AmazonLinuxはCentOSベースでCentOSのやり方でいいと思う。


まずApacheが入ってるか確認

[ec2-user@ip-10-146-47-44 ~]$ apachectl -v
-bash: apachectl: command not found

入ってないらしい。

というわけで入れる。
ついでにviだと死んじゃうのでemacsも入れる。

sudo yum install httpd
sudo yum install emacs

特に問題なくインストール可能


※今更知ったけどemacsでCtr-s押しながら検索
二回押すと次の候補
Ctr-rで逆向きに検索
それとCtr-x,uで一回戻る。

yum -y install php php-mbstring
emacs /etc/httpd/conf/httpd.conf 

httpd.confを以下のように編集する

# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks
  ↓
    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 None
  ↓
    AllowOverride All ← .htaccessの許可

<IfModule mod_userdir.c>
 &#160; &#160;#
 &#160; &#160;# UserDir is disabled by default since it can confirm the presence
 &#160; &#160;# of a username on the system (depending on home directory
 &#160; &#160;# permissions).
 &#160; &#160;#
 &#160; &#160;UserDir disable
    ↓
  UserDir public_html


ServerSignature On
↓
ServerSignature Off ← エラーページでサーバー情報を表示しないようにする

AddDefaultCharset UTF-8
↓
#AddDefaultCharset UTF-8 ← コメントアウト(文字化け対応)

#AddHandler cgi-script .cgi
↓
AddHandler cgi-script .cgi .pl ← CGIスクリプトに.plを追加

<Directory "/var/www/icons">
    Options Indexes MultiViews
    ↓
    Options MultiViews ← iconsディレクトリのファイル一覧を表示しないようにする
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

あと、自分のホームディレクトリのパーミッションを変える

chmod 707 (username)

とかでいいのかな?とりあえず自分のは外部公開するやつじゃないので
777とかにしたけど。

ちなみにドキュメントルートはデフォルトで/var/www/html

http://centossrv.com/apache.shtml