复制步骤
- 我创建了数据库并进行了迁移
- 我运行了
rails server
这就是结果:
[3957] Puma starting in cluster mode...
[3957] * Version 3.10.0 (ruby 2.5.1-p57), codename: Russell's Teapot
[3957] * Min threads: 5, max threads: 5
[3957] * Environment: development
[3957] * Process workers: 4
[3957] * Preloading application
[3957] * Listening on tcp://0.0.0.0:80
Exiting
Traceback (most recent call last):
22: from bin/rails:4:in `<main>'
21: from bin/rails:4:in `require'
20: from /home/my_username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<top (required)>'
19: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
18: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
17: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
16: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
15: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
14: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'
13: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'
12: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:147:in `block in perform'
11: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:53:in `start'
10: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/server.rb:297:in `start'
9: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/rack/handler/puma.rb:69:in `run'
8: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/launcher.rb:183:in `run'
7: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/cluster.rb:397:in `run'
6: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/runner.rb:144:in `load_and_bind'
5: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:88:in `parse'
4: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:88:in `each'
3: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:105:in `block in parse'
2: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:270:in `add_tcp_listener'
1: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:270:in `new'
/home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:270:in `initialize': Permission denied - bind(2) for "0.0.0.0" port 80 (Errno::EACCES)
配置puma以使用不同的端口。
# config/puma.rb
port(ENV.fetch('PORT', 3000))
在生产设置PORT=80
中,在本地开发unset PORT
中。
Rails默认在端口3000上侦听,您可能已经更改了一些设置,使其在端口80上运行。常规用户无法打开1024以下的端口。–微薄的♦
Permission denied - bind(2) for "0.0.0.0" port 80 (Errno::EACCES)
只有root
可以绑定1024以下的端口。不要将本地开发服务器作为root
运行!相反,配置1024以上的端口。