gpt4 book ai didi

ruby-on-rails - Nginx:欢迎使用 Nginx!页面一直显示

转载 作者:太空宇宙 更新时间:2023-11-03 16:43:39 25 4
gpt4 key购买 nike

为了让 Nginx 和 Passenger 为我的 Rails 应用程序工作,我已经尝试了一天多,但我得到的只是:Nginx 欢迎页面。为什么?

我已经在默认位置/opt/nginx安装了Nginx,像这样:

# Install passenger gem
$ gem install passenger

# Install dependencies for Nginx/Passenger
$ apt-get install libcurl4-openssl-dev

# Compile it
$ passenger-install-nginx-module

文件 /opt/nginx/conf/nginx.conf 的(我认为)相关部分如下所示:

http {
passenger_root /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.29;
passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p353/ruby;

server {
listen 80;
server_name www.my-domain.com;
root /home/deploy/current/public;
passenger_enabled on;

location / {
root html;
index index.html index.htm;
passenger_enabled on;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
passenger_enabled on;
}

...

当我检查“根位置”(公共(public))时,我可以看到应用程序就在那里(它是用 Capistrano 部署的):

$ ls /home/deploy/current/public
404.html 422.html 500.html assets css favicon.ico js robots.txt system

...或向上一级:

$ ls /home/deploy/current
app Capfile config.ru doc Gemfile.lock log public resque.pid script tmp
assets_manifest.yml config db Gemfile lib LOG Rakefile REVISION test vendor

查看 Rails production.log,我可以看到它从未超出编译 Assets 的范围:

$ tail -f /home/deploy/current/log/production.log
Compiled page_specific/some_file_5.css (137ms) (pid 28316)
Compiled page_specific/some_file_4.css (19ms) (pid 28316)
Compiled page_specific/some_file_3.css (3ms) (pid 28316)
Compiled page_specific/some_file_2.css (3ms) (pid 28316)
Compiled page_specific/some_file_1.css (16ms) (pid 28316)
Compiled application.css (3131ms) (pid 28316)

查看 Nginx error.log,我没有发现任何错误(正常访问 URL(“主页”)似乎没有创建任何条目):

$ tail -f /opt/nginx/logs/error.log

并且查看 Nginx access.log,我看不出任何错误(正常访问 URL(“主页”)似乎没有创建任何条目):

$ tail -f /opt/nginx/logs/error.log
[ 2013-12-29 01:16:55.6792 2099/7fa534fca740 agents/Watchdog/Main.cpp:697 ]: All Phusion Passenger agents started!

还有:

  • 我确定 Nginx 正在运行(因为我看到了欢迎页面)
  • 我确定 nginx.conf 文件 正在被 Nginx 考虑(即如果我取消注释 #access_log logs/access.log main; 而没有取消注释#log_format main,它会提示)
  • 我在:Rails 3.2.16/ruby​​ 2.0.0p353/Ubuntu 13.10

这里可能出了什么问题?

最佳答案

神圣的。使其工作显然需要的是:

注释掉/删除安装时默认添加的“location/”指令:

    # location / {
# root html;
# index index.html index.htm;
# passenger_enabled on;
# }

(如果有人知道原因,我很想知道。)

关于ruby-on-rails - Nginx:欢迎使用 Nginx!页面一直显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20824071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com