我已經安裝了最新穩定版本NGINX的(1.10)軌,NGINX不加載部署的應用程序
在我的Rails項目我已經創建nginx.conf
文件:
upstream puma_myapp {
server unix:///var/www/myapp/shared/tmp/sockets/myapp.sock;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /var/www/myapp/current/public;
access_log /var/www/myapp/current/log/nginx.access.log;
error_log /var/www/myapp/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma_myapp;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
我已經通過部署我的Rails應用程序Capistrano的。它將我的應用程序刪除。
現在/etc/nginx
沒有sites-enabled
文件夾。我創建這個文件夾,然後我寫了這個:
sudo ln -nfs "/var/www/myapp/current/config/nginx.conf" "/etc/nginx/sites-enabled/myapp"
然後我重新啓動我的nginx的:
sudo service nginx restart
當我打開我的網頁地址,我仍然得到nginx的默認頁面,爲什麼發生這種情況?
我puma.rb
文件是:
#!/usr/bin/env puma
directory '/var/www/myapp/current'
rackup "/var/www/myapp/current/config.ru"
environment 'production'
pidfile "/var/www/myapp/shared/tmp/pids/puma.pid"
state_path "/var/www/myapp/shared/tmp/pids/puma.state"
stdout_redirect '/var/www/myapp/current/log/puma.error.log', '/var/www/myapp/current/log/puma.access.log', true
threads 4,16
bind 'unix:///var/www/myapp/shared/tmp/sockets/myapp.sock
workers 0
我var/log/nginx/error.log
文件顯示此:
2016/08/16 10:07:01 [error] 10157#10157: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 178.88.194.6, server: localhost, $
2016/08/16 10:14:49 [error] 10157#10157: *3 open() "/usr/share/nginx/html/phpMyAdmin/scripts/setup.php" failed (2: No such file or directory), client: 203.110.167.86, $
2016/08/16 10:14:55 [error] 10157#10157: *4 open() "/usr/share/nginx/html/pma/scripts/setup.php" failed (2: No such file or directory), client: 203.110.167.86, server:$
2016/08/16 10:15:00 [error] 10157#10157: *5 open() "/usr/share/nginx/html/myadmin/scripts/setup.php" failed (2: No such file or directory), client: 203.110.167.86, ser$
2016/08/16 10:36:20 [error] 26599#26599: *1 open() "/usr/share/nginx/html/admin" failed (2: No such file or directory), client: 178.88.194.6, server: localhost, reques$
2016/08/16 10:42:11 [error] 27962#27962: *1 open() "/usr/share/nginx/html/admin" failed (2: No such file or directory), client: 178.88.194.6, server: localhost, reques$
你還可以發佈你的'puma.rb'嗎? – slowjack2k
我剛剛纔意識到你的小提示:沒有'sites-enabled'文件夾。你使用哪個操作系統?你是否通過包管理器安裝nginx?當'sites-enabled'沒有退出時,這可能意味着你的nginx不包含'sites-enabled'中的配置,你必須在你的nginx.conf中加入include/etc/nginx/sites-enabled/*;' – slowjack2k
嘗試在您的獨角獸puma.rb文件中使用'listen'而不是'bind',以及您的puma錯誤日誌的輸出是什麼意思? nginx在'/ var/log/nginx/error.log'或其他上面指定的日誌中有錯誤嗎? – yekta