我发现自己遵循本教程“如何在Ubuntu 14.04上使用Puma和Nginx部署Rails应用程序”(official documentation),以便将ngnix用作负载均衡器。 我按照所有步骤工作正常,我想,但最后,当我配置nginx配置文件时,我无法访问localhost(0.0.0.0:3000)它显示“无法连接”。我检查过程是否正在运行,是的......
我在这里放一些文件
/etc/nginx/sites-available/iaw2015.conf
sudo ln -sf /etc/nginx/sites-available/iaw2015.conf /etc/nginx/sites-enabled/iaw2015.conf
我运行此命令# Change to match your CPU core count
workers 2
# Min and Max threads per worker
threads 1, 6
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
# Set up socket location
bind "unix://#{shared_dir}/sockets/puma.sock"
# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
# Set master PID and state locations
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"
activate_control_app
on_worker_boot do
require "active_record"
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
end
来创建链接。
config / puma.rb(在我的项目中)
import math
def polysum(n, s):
a = ((0.25 * n * s ** 2) / (math.tan(math.pi / 2)))
p = ((n * s) ** 2)
total = a + p
return '%.4f' % round(total)
print polysum(8, 8)
答案 0 :(得分:0)
根据您发布的内容,您尝试连接的端口3000上没有任何内容正在运行。相反,应用服务器正在位于以下位置的套接字上运行:
/var/www/iaw2015/shared/sockets/puma.sock
首先,检查应用是否正在运行communicate with it through the socket。
接下来,尝试连接到http://127.0.0.1/这将连接到运行Nginx的端口80。它应该有代理到您的应用程序并返回结果。