Wednesday, January 27, 2010

mod_rails We're sorry, but something went wrong. message

After running rails by exec'ing script/server I installed mod_rails/Phusion to run rails through apache.

I was getting this message

"We're sorry, but something went wrong. message"

Not a lot of help, and I was uanble to find much in the logs and user manuals either.

Solution:

1) By default, mod_rails runs your app in production mode. When you're running rails through script/server it is in development mode.

2) You can either run rake db:migrate RAILS_ENV="production" which will build the production database from the values in database.yml

3) Or if you want to keep on using the dev database add this line to your apache virtual host



RailsEnv development

Thursday, January 21, 2010

cakephp mod_rewrite optimizations

A few people on the wordpress forums were discussing ways to improve the performance by editing the .htaccess file. Since WP and cakephp along with other PHP frameworks use a similar method of improving URLs, here's my attempt at improving cakephp's ./webroot/.htaccess

# http://www.phpdeveloper.org/news/13883 optimizations
RewriteEngine On

# images in these dirs tells mod_rewrite to stop processing
# '-' means to pass request unchanged. ie serve it immediately
RewriteRule ^(img|css|js)/(.*)\.(gif|jpe?g|png|ico)$ - [L,NC]
# these other files are served as is anywhere in ./webroot
RewriteRule \.(swf|css|js)$ - [L,NC]
# If File is a file or is a DIR then skip (1 rule) and serve the file
# (vs before where it was !-f AND !-d Not a file AND not a dir, two checks vs less than two if the first one matches)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [S=1]
# else rewrite the request
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]