未配置生产数据库 [英] Production database is not configured
问题描述
在我的服务器上,mysql 正在运行.
On my server, mysql is running.
$ pgrep mysql
28636
Rails 控制台命令有效.
Rails console command works.
anand@app-Staging:~/public_html/app_staging/current$ rails console staging
Loading staging environment (Rails 3.0.19)
irb(main):001:0>
但是当我从浏览器访问应用程序时,乘客会抛出这个错误.
But when i access the app from browser, passenger is throwing this error.
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 配置
Here is my apache config
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
Here is my config/database.yml
staging:
adapter: mysql2
encoding: utf8
database: app_staging
username: root
password: xxxxxx
host: localhost
我已经重新启动 mysql 并尝试过.还重新启动了apache.我已经检查了 apache 配置文件中的乘客配置行.
I have restarted mysql and tried. Also restarted apache. I have checked passenger config lines in apache config file.
没有任何效果.我是不是错过了什么.请帮忙.
Nothing works. Am i missing something. Please help.
推荐答案
我应该指定 Rails 环境,例如 RackEnv staging
for Rails 版本 >= 3.x
I should specify the Rails environment like RackEnv staging
for Rails versions >= 3.x
这个配置解决了这个问题.
This config fixed the issue.
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>
这篇关于未配置生产数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!