gpt4 book ai didi

ruby-on-rails-3 - 在端口 80 启动 webrick(mysql2 gem 问题)

转载 作者:行者123 更新时间:2023-12-04 02:54:09 25 4
gpt4 key购买 nike

我试图让我的 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): 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:in
require' 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:in
require' 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:in
require' 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:in
require' 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:in
require' from script/rails:6

最佳答案

似乎在使用的 ruby​​ 运行时中没有安装 mysql2 gem。但是,由于这对没有 sudo 的您有效,我怀疑您安装了 rvm,并且在没有 sudo 的情况下使用 Rails 时,默认情况下您正在使用 rvm ruby​​(安装了 mysql)。但是当您执行 sudo 时,您很可能使用的是未安装 mysql2 的系统 ruby​​。

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

rvmsudo rails server -p 80

关于ruby-on-rails-3 - 在端口 80 启动 webrick(mysql2 gem 问题),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5840633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com