我试图让我的webrick服务在80端口。我试过了:
rails server -p 80
但拒绝访问权限。我后来才知道使用端口1-1024需要root权限,所以我尝试了这个
sudo rails server -p 80
但是,这次我得到一个mysql2错误。不知道这里发生了什么。我试着跑:
rails server -p 1025
并且它工作正常,我认为这是关于root和mysql2的。有人可以帮忙吗?
下面的是控制台中的错误消息:
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle:dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2 /mysql2.bundle,9):未加载库:libmysqlclient.18.dylib(LoadError) 参考自:/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle 原因:找不到图像 - / Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle 来自/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8 from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in
require' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in
require' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:ineach' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in
require' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:ineach' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in
require' 来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:inrequire' from /Users/ccool2486/Sites/fs2_test/config/application.rb:7 from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28:in
require' 来自/Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28 from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27:intap' from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27 from script/rails:6:in
require' 来自script / rails:6
答案 0 :(得分:23)
似乎mysql2 gem没有安装在使用的ruby运行时。但是,因为这对你没有sudo工作,我怀疑你已经安装了rvm并且你正在使用rvm ruby(安装了mysql)默认情况下在没有sudo的情况下运行rails。但是当你做sudo时,你很可能正在使用没有安装mysql2的系统ruby。
所以简而言之,如果您安装了rvm并且正在使用它。只需使用:
rvmsudo rails server -p 80
答案 1 :(得分:0)
我使用rails server -p 8080,它适用于我