我在这里遵循写得很好的教程:https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-unicorn-and-nginx-on-ubuntu-14-04。
在我开始使用NginX运行服务器之前,一切都顺利进行。当我到达运行命令RAILS_ENV=production rails server --binding=server_public_IP
的位置时,我能够跳到网络上的另一台机器并使用浏览器访问该页面。
一旦我走到尽头,我觉得我没有任何打嗝或任何事情到达那里,但我不能让页面出现了,我不知道怎么弄清楚什么是错误。我假设我的服务器正在运行,但这里有一些有用的信息:
当我在nginx上运行服务状态时:
<user>@aws-ubuntu:~/<app>$ sudo service nginx status
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2015-10-22 23:33:32 UTC; 16min ago
Process: 2797 ExecStop=/bin/sleep 1 (code=exited, status=0/SUCCESS)
Process: 2794 ExecStop=/sbin/start-stop-daemon --quiet --stop --signal QUIT --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 2806 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 2804 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 2826 (nginx)
CGroup: /system.slice/nginx.service
├─2809 Passenger watchdog
├─2812 Passenger core
├─2817 Passenger ust-router
├─2826 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─2827 nginx: worker process
├─2828 nginx: worker process
├─2829 nginx: worker process
└─2830 nginx: worker process
Oct 22 23:33:32 aws-ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Oct 22 23:33:32 aws-ubuntu systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
Oct 22 23:33:32 aws-ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.
当我在unicorn_<app>
上运行服务状态时:
<user>@aws-ubuntu:~/<app>$ sudo service unicorn_<app> status
● unicorn_<app>.service - LSB: starts the unicorn app server
Loaded: loaded (/etc/init.d/unicorn_<app>)
Active: active (exited) since Thu 2015-10-22 23:33:39 UTC; 18min ago
Docs: man:systemd-sysv-generator(8)
Process: 2847 ExecStop=/etc/init.d/unicorn_<app> stop (code=exited, status=0/SUCCESS)
Process: 2848 ExecStart=/etc/init.d/unicorn_<app> start (code=exited, status=0/SUCCESS)
Oct 22 23:33:35 aws-ubuntu systemd[1]: Starting LSB: starts the unicorn app server...
Oct 22 23:33:35 aws-ubuntu unicorn_<app>[2848]: Starting <app>
Oct 22 23:33:35 aws-ubuntu su[2849]: Successful su for <user> by root
Oct 22 23:33:35 aws-ubuntu su[2849]: + ??? root:<user>
Oct 22 23:33:35 aws-ubuntu su[2849]: pam_unix(su:session): session opened for user <user> by (uid=0)
Oct 22 23:33:39 aws-ubuntu systemd[1]: Started LSB: starts the unicorn app server.
netstat for port:
<user>@aws-ubuntu:~/<app>$ sudo netstat -ntlp | grep LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 2826/nginx -g daemo
最后,我不知道这是否有帮助,但这是服务器实际上能够从内部做出响应:
<user>@aws-ubuntu:~/<app>$ curl localhost:8080/tasks
<!DOCTYPE html>
<html>
<head>
<title><App></title>
<link data-turbolinks-track="true" href="/assets/application-e17d3eb99df904ad26a6d0d744384921.css" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/assets/application-9eda54d248a655ae0a4b2932bd94d30b.js"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="mZeiuMQNcRe31Eiy1asvCeTDIXGrByjCt/DwWQzDL+E=" name="csrf-token" />
</head>
<body>
<div class="container">
<h1>Listing tasks</h1>
<table>
<thead>
<tr>
<th>Title</th>
<th>Note</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<br>
<a href="/tasks/new">New Task</a>
</div>
</body>
</html>