我正在尝试部署位于 /opt/rails/my_app 中的铁路应用程序。 为此,我安装了 passenger gem 并使用 passenger-install-nginx-module 配置了 nginx。我可以访问静态欢迎页面,但是当我尝试其他页面如主页(由 rails generate controller home index 生成)时,浏览器一直在等待响应。
当我在端口 3000 上使用 rails s
部署应用程序时,不会发生这种情况。
更新
当我执行 passenger-install-apache2-module
时,我得到 g++: unrecognized option '-R/usr/local/lib'。我认为我需要将“-R/usr/local/lib”更改为“Wl,-R/usr/local/lib”才能正确编译 LoggingAgent。你能告诉我如何更改make文件吗?
最佳答案
关于 NGINX,听起来好像是您的某些文件和/或目录的权限问题。我会改为将应用程序移动到专用的/home 目录。例如,如果您有一个名为 tester 的用户,您的 nginx.conf 会说(以下内容适用于生产环境中的我:
server {
listen YOURIPADDRESSHERE:80; #use :443 if SSL is being used.
server_name YOURFULLDOMAINNAMEHERE;
#uncomment out following if ssl is used.
#ssl on;
#ssl_certificate /etc/ssl/private/YOUR_chained.crt;
#ssl_certificate_key /etc/ssl/private/YOUR.key;
#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 5m;
#ssl_protocols SSLv3 TLSv1;
#ssl_ciphers HIGH:MEDIUM;
#ssl_prefer_server_ciphers on;
root /home/tester/YOURRAILSAPPNAME/public; # <--- be sure to point to 'public'!
passenger_enabled on;
charset utf-8;
access_log /var/log/nginx/YOURFULLDOMAINNAMEHERE-ssl_access.log;
error_log /var/log/nginx/YOURFULLDOMAINNAMEHERE-ssl_error.log warn;
location /home/tester/YOURRAILSAPPNAME/public/ {
root html;
index index.html index.htm;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
然后确保您的权限正确(所有文件 755,目录 644)。
关于ruby-on-rails - 部署 Rails 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6257824/