I have been trying to set up an Apache server utilizing Ruby on Rails and mySQL through Phusion Passenger. I have Apache v2.2.3, Passenger v3.0.13, Ruby v1.9.3, Rails v3.2.6, and mySQL v5.0.95.
Earlier, I encountered problems due to an incorrect Javascript runtime, but I was able to fix that by installing execjs and therubyracer. I was successfully able to create the website with SQLite, but I need to use mySQL instead.
Now, I have created a new project with the command "rails new myProject -d mysql" and added the appropriate gems to my Gemfile (that is, "gem 'mysql2','0.3.11'"; "gem 'execjs'"; and "gem 'therubyracer'").
My database.yml file looks like this (the test and production parts only differ in terms of name) :
development:
adapter: mysql2
encoding: utf8
database: myProject_development
pool: 5
username: root
password:
host: localhost
socket: /var/lib/mysql/mysql.sock
Now, the problem is not immediately apparent. From terminal, I cannot find any problems (that is, "rake db:create" runs correctly, no errors appear upon scaffolding, etc.), but when I visit the website, Passenger displays the following error:
And none of the webpages appear. So, where is my fault? I believe my Gemfile is correct, my database.yml seems to be updated, I can access mySQL from terminal, and I was able to run the website in SQLite. Any suggestions would be appreciated!
EDIT: My gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2','0.3.11'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'execjs'
gem 'therubyracer'
EDIT: Output of "bundle list":
Gems included by the bundle:
* actionmailer (3.2.6)
* actionpack (3.2.6)
* activemodel (3.2.6)
* activerecord (3.2.6)
* activeresource (3.2.6)
* activesupport (3.2.6)
* arel (3.0.2)
* builder (3.0.0)
* bundler (1.1.4)
* coffee-rails (3.2.2)
* coffee-script (2.2.0)
* coffee-script-source (1.3.3)
* erubis (2.7.0)
* execjs (1.4.0)
* hike (1.2.1)
* i18n (0.6.0)
* journey (1.0.4)
* jquery-rails (2.0.2)
* json (1.7.3)
* libv8 (3.3.10.4)
* mail (2.4.4)
* mime-types (1.19)
* multi_json (1.3.6)
* mysql2 (0.3.11)
* polyglot (0.3.3)
* rack (1.4.1)
* rack-cache (1.2)
* rack-ssl (1.3.2)
* rack-test (0.6.1)
* rails (3.2.6)
* railties (3.2.6)
* rake (0.9.2.2)
* rdoc (3.12)
* sass (3.1.20)
* sass-rails (3.2.5)
* sprockets (2.1.3)
* therubyracer (0.10.1)
* thor (0.15.4)
* tilt (1.3.3)
* treetop (1.4.10)
* tzinfo (0.3.33)
* uglifier (1.2.6)
EDIT: Oh, and I'm working off of CentOS 5.8 , by the way.
Add the following to your Gemfile:
gem 'mysql2'
Next run
bundle install
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.