mysql - 在 Linux 服务器上使用 Mysql 安装 Rails 应用程序时出现问题

标签 mysql ruby-on-rails ruby linux web-hosting

我一直在关注 Host Gator 上的支持指南 我在第 5 步。

这是我在终端中遇到的第一个问题:

user@domain.com [~/rails_apps/app_name]# bundle install
Fetching gem metadata from http://rubygems.org/.......
Using rake (0.8.3) 
Using RedCloth (4.2.9) 
Using coderay (0.9.8) 
Using hoe (3.13.1) 
Using i18n (0.4.2) 
Using minitest (1.7.2) 
Installing mysql (2.9.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby extconf.rb 
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby
    --with-mysql-config
    --without-mysql-config


Gem files will remain installed in /home3/user/ruby/gems/gems/mysql-2.9.1 for inspection.
Results logged to /home3/user/ruby/gems/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
An error occured while installing mysql (2.9.1), and Bundler cannot continue.
Make sure that `gem install mysql -v '2.9.1'` succeeds before bundling.

然后我尝试使用 'gem install mysql -v '2.9.1':

user@domain.com [~/rails_apps/app_name]# gem install mysql -v '2.9.1'
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby extconf.rb
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby
    --with-mysql-config
    --without-mysql-config


Gem files will remain installed in /home3/user/ruby/gems/gems/mysql-2.9.1 for inspection.
Results logged to /home3/user/ruby/gems/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

我尝试使用以下方法更改文件夹的权限:

chown root:root user/bin/sudo 

没有任何运气。

这是我需要从 Host Gator 那里获得帮助的事情吗?

最佳答案

假设你在 Linux 上,你需要安装 mysql 开发库/头文件来编译 native 扩展:

sudo apt-get install libmysqlclient-dev

根据 linux 版本,您可能需要安装其他开发库。错误消息是否像这样:

checking for mysql.h... no

这表明您的盒子缺少相应的开发人员库/ header (在这种特殊情况下为 mysql。)

关于mysql - 在 Linux 服务器上使用 Mysql 安装 Rails 应用程序时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30092763/

相关文章:

ruby - 如何在 JRuby 中包含类依赖 jar?

php - cakephp 中主键字段的唯一性未得到验证

javascript - 如何在mysql查询中精确找到选定对 Angular 线区域之间的数据

ruby-on-rails - 对 ActiveRecord 模型虚拟属性进行类型转换

ruby-on-rails - 与 Ruby 2.0 或 1.9 相比,Ruby 2.1 的内存使用量增加

ruby - 我可以使用适用于 Ruby 的 Selenium-webdriver 自动阻止 Chrome 请求吗?

php - 无法获取更新查询以从内爆数组运行

MySQL 更新多行中 1 列的部分内容

ruby-on-rails - 设计助手(authenticate_user!,current_user,user_signed_in?)未初始化

ruby-on-rails - 如何检查类或模块是否已命名空间?