在我的服务器上,mysql正在运行。
$ pgrep mysql
28636
Rails控制台命令可以正常工作。
anand@app-Staging:~/public_html/app_staging/current$ rails console staging
Loading staging environment (Rails 3.0.19)
irb(main):001:0>
但是当我从浏览器访问应用程序时,乘客正在抛出此错误。
Your application's database configuration file might be written incorrectly. Please check it and fix any errors.
The database server may not be running. Please check whether it's running, and start it if it isn't.
Error message:
production database is not configured (ActiveRecord::AdapterNotSpecified)
Exception class:
ActiveRecord::AdapterNotSpecified
Application root:
/home/anand/public_html/app_staging/current
这是我的apache配置
anand@app-Staging:/etc/apache2/sites-enabled$ cat app_staging
<VirtualHost *:80>
ServerName myappstaging.org
ServerAlias *.myappstaging.org
DocumentRoot /home/anand/public_html/app_staging/current/public
RailsEnv staging
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^OPTIONS
RewriteRule .* - [R=405,L]
XSendFile on
</VirtualHost>
这是我的config / database.yml
staging:
adapter: mysql2
encoding: utf8
database: app_staging
username: root
password: xxxxxx
host: localhost
我重启了mysql并试过了。还重启了apache。我在apache配置文件中检查过乘客配置行。
没有任何作用。我错过了什么。请帮忙。
答案 0 :(得分:1)
我应该像Rails版本&gt; = 3.x
那样为RackEnv staging
指定Rails环境
此配置修复了此问题。
anand@app-Staging:/etc/apache2/sites-enabled$ cat app_staging
<VirtualHost *:80>
ServerName myappstaging.org
ServerAlias *.myappstaging.org
DocumentRoot /home/anand/public_html/app_staging/current/public
RackEnv staging
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^OPTIONS
RewriteRule .* - [R=405,L]
XSendFile on
</VirtualHost>