Open Sec-il-n opened 3 years ago
sudo vi /etc/nginx/conf.d/アプリケーション名.conf
↓カリキュラム(現状 ↓ Nginx confファイル)
upstream unicorn {
server unix:/var/www/アプリケーション名/shared/tmp/sockets/unicorn.sock;
}
server {
listen 80;
server_name EC2のIPアドレス;
root /var/www/アプリケーション名/shared/public;
access_log /var/log/nginx/アプリケーション名_access.log;
error_log /var/log/nginx/アプリケーション名_error.log;
location ~ ^/assets/ {
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://unicorn;
}
}
追記
postメソッドでもエラーが出ないようにする
$ cd /var/lib
$ sudo chmod -R 775 nginx
参考
変更前
drwxrwx--- 3 nginx root 17 Mar 8 13:22 nginx
編集後はリロード
$ sudo nginx -s reload
Nginx confファイル doc p.8 & /Users/secil/workspace/dic/dic_graduate/EC2側設定ファイル
編集後はリロード
$ sudo nginx -s reload
リスタート コマンド
sudo systemctl restart nginx
\=
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx start
sudo nginx -s reload
bundle exec cap production deploy:check
※ この時点ではERROR linked file /var/www/achieve/shared/.env does not exist on xx.xxx.xxx.x
が出る。
→環境変数設定
以下 issue6にも記載済み
$ sudo su -
# amazon-linux-extras install nginx1
$ chkconfig nginx on
$ systemctl start nginx
EC2インスタンスのIPアドレスにアクセスして確認