在80端口启动webrick(mysql2 gem问题) [英] Start webrick in port 80 (mysql2 gem issue)

查看:147
本文介绍了在80端口启动webrick(mysql2 gem问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  rails server -p 80 $ b $我试图让我的webrick在80端口服务。 b  

但是拒绝访问。我后来明白,使用端口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:/Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in require中的
require '/ bibrary/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in
需要'
from / Library' /Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in 每个'
from /Library/Ruby/Gems/1.8/gems/ bundler-1.0.12 / lib / bundler / runtime.rb:66:在
require'
来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in 每个来自/Library/Ruby/Gems/1.8的
/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in
需要从/Library/Ruby/Gems/1.8/gems/bundler-1.0.12购买
/lib/bundler.rb:120:in 需要从/ Library / Ruby / Gems的/Users/ccool2486/Sites/fs2_test/config/application.rb:7
中的
/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28:in
需要从/Library/Ruby/Gems/1.8/gems/railties-3.0获得
.6 / lib / rails / commands.rb:28从/Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27:in >点击从/Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27
从脚本/导轨获得的
:6:在 require'
from script / rails:6



解决方案

mysql2 gem没有安装在使用的ruby运行时间中。然而,因为这对你没有sudo的工作,我怀疑你已经安装rvm,并且在没有sudo的情况下执行rails时默认使用rvm ruby​​(已安装mysql)。但是当你做sudo的时候,你最可能使用的是没有安装mysql2的系统ruby。



所以简而言之,如果你安装了rvm并且正在使用它。只需使用:

  rvmsudo rails server -p 80 


I am trying to get my webrick serve in port 80. I tried:

rails server -p 80

but get a access denied. I later understood that using port 1-1024 needs a root permission, so I tried this instead

sudo rails server -p 80

However, now i get a mysql2 error this time. Don't know what happened here. I tried to run:

rails server -p 1025

and it's working fine, I think it's something about root and mysql2. Can anyone help?

below is the error message in console:

/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): Library not loaded: libmysqlclient.18.dylib (LoadError) Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle from /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:inrequire' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in each' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:inrequire' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in each' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:inrequire' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in require' 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:inrequire' from /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:in tap' from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27 from script/rails:6:inrequire' from script/rails:6

解决方案

It seems that the mysql2 gem is not installed in the ruby run time that is used. however as this works for you without sudo, i suspect that you have rvm installed and you are using the rvm ruby (which has mysql installed) by default when lunching rails without sudo. but when you do sudo you are most probably using the system ruby which doesn't have mysql2 installed.

so in short if you have rvm installed and is using that. just use:

rvmsudo rails server -p 80

这篇关于在80端口启动webrick(mysql2 gem问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆