Help us understand the problem. What is going on with this article?

[nginx] Amazon Linuxにnginxをインストールする (nginx本家パッケージ)

More than 5 years have passed since last update.

インストール

コマンド
sudo rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
コマンド
sudo yum install nginx --disablerepo=amzn-main -y
コマンド
which nginx
結果(例)
/usr/sbin/nginx

起動

コマンド
sudo service nginx start
コマンド
sudo chkconfig nginx on
/etc/yum.repos.d/nginx.repo
priority=1

アクセス確認

コンテンツディレクトリ作成

mkdir -p ${HOME}/`date +%Y%m%d`-handson/main/_build/html
cd ${HOME}/`date +%Y%m%d`-handson/main/_build/html
pwd
/home/ec2-user/20150720-handson/main/_build/html
コマンド
cat << EOF > /home/ec2-user/20150720-handson/main/_build/html/index.html
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="utf-8">
  <title>Title</title>
</head>

<body>

<h1>Hello!</h1>
<!-- comment -->

</body>
</html>
EOF

cat /home/ec2-user/20150720-handson/main/_build/html/index.html

設定(例)

/etc/nginx/conf.d/default.conf
#root   /usr/share/nginx/html;
root   /home/ec2-user/20150720-handson/main/_build/html;
コマンド
sudo nginx -t 
結果(例)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
コマンド
sudo service nginx restart

パーミッション変更

コマンド
cd ~
chmod 755 .

アクセス確認

完了

参考

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away