Ruby on rails 运行nginx服务器的应用程序未显示
我在Digital Ocean中有一个rails应用程序,运行nginx、Ubuntu14.04、postgresql和capistrano 问题是,当我访问我的服务器地址(xxx.xxx.xxx.xxx)时,它没有显示,这是在我使用Ruby on rails 运行nginx服务器的应用程序未显示,ruby-on-rails,ubuntu,nginx,capistrano,Ruby On Rails,Ubuntu,Nginx,Capistrano,我在Digital Ocean中有一个rails应用程序,运行nginx、Ubuntu14.04、postgresql和capistrano 问题是,当我访问我的服务器地址(xxx.xxx.xxx.xxx)时,它没有显示,这是在我使用cap production deploy推送到服务器后发生的,我也执行了以下命令: sudo服务nginx重启 sudo服务nginx重新加载 触摸tmp/restart.txt 什么也没有,当我用sudo nginx-t检查配置文件状态时,它会说: nginx:
cap production deploy
推送到服务器后发生的,我也执行了以下命令:
sudo服务nginx重启
sudo服务nginx重新加载
触摸tmp/restart.txt
什么也没有,当我用sudo nginx-t
检查配置文件状态时,它会说:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
为什么会这样?有线索吗
这是我的nginx.conf文件:
user deploy;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deploy/.rbenv/shims/ruby;
# passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
# passenger_ruby /usr/bin/passenger_free_ruby;
##
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
提前感谢。首先,如果您的应用程序正在使用PostgreSQL,请确保它使用正确的用户、数据库和表按预期运行 然后,您可能需要检查
passenger\u root
和passenger\u ruby
指令是否正确。我有以下资料:
passenger_root /home/myuser/.rvm/gems/ruby-2.2.2/gems/passenger-5.0.18;
passenger_ruby /home/myuser/.rvm/gems/ruby-2.2.2/wrappers/ruby;
另外,我不确定在http块中使用SSL配置是否正确。我相信SSL指令属于https块。您还需要确保用户部署
存在且正确无误
我看到你们也有这个指令:
include /etc/nginx/sites-enabled/*;
您需要确保/etc/nginx/sites enabled/中有一个文件定义指向您网站的服务器块,例如:
server {
listen 80;
server_name <some IP address here> yourdomain.com;
root /home/youruser/yourwebsite/public;
passenger_enabled on;
location ~ ^/(assets)/ {
expires max;
add_header Cache-Control public;
gzip_static on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
服务器{
听80;
服务器名称yourdomain.com;
root/home/youruser/yourwebsite/public;
乘客_开启;
地点~^/(资产)/{
最大值;
添加_头缓存控制公共;
gzip_静态开启;
}
错误\u第500页502 503 504/50x.html;
location=/50x.html{
根html;
}
}
(此配置假定您有一个Ruby on Rails网站。您需要根据应用程序进行相应调整。)这里的基本部分是server\u name
指令,它告诉Nginx响应该DNS条目并执行一些操作
您能否同时找到您遇到的具体错误消息。您可能需要查看nginx日志或应用程序日志,以了解错误所在。您可以粘贴nginx.conf文件吗?另外,我在nginx.conf上添加了de code,ps aux | grep nginx@DaniG2k的输出是什么,从您给我的命令中得到的输出在这里:看起来您在nginx中使用了Phusion乘客(我提到,因为您声明您运行了
touch tmp/restart.txt
,当您尝试访问服务器IP时,您会收到什么错误/消息?另外,作为补充说明,您可以运行一个名为BIND的服务,该服务将IP地址转换为域名,这样您就不必键入IP地址来访问服务器。我还将发布输出您的问题中的access.log
和error.log
的t。我需要在服务器名上放置一个域吗?如果我当前没有域怎么办?好的,我知道我有它,就像示例yourdomain.com一样。如果您没有域,请删除域名,然后只放置分配给您的IP地址。