LoginSignup
26
25

More than 5 years have passed since last update.

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

Last updated at Posted at 2015-07-20

インストール

コマンド
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 .

アクセス確認

完了

参考

26
25
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
25