Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple sinatra app with sqlite3 works when using WEBrick but not when using apache and passenger
    primarykey
    data
    text
    <p>I'm getting a "500 Internal Server Error" message when my app tries to write to my sqlite3 database.</p> <p>Everything works fine when I'm using WEBbrick, but I get the above error when I'm using Apache and Passenger. My app loads the first page but fails when it tries to POST. </p> <p>Here is how I have everything setup:</p> <p>awesome.rb file:</p> <pre><code>require 'sinatra' require 'data_mapper' require 'dm-core' require 'dm-migrations' require 'slim' APP_ROOT = File.expand_path(File.dirname(__FILE__)) DataMapper::setup(:default, "sqlite3://#{APP_ROOT}/emails.db") class Email include DataMapper::Resource property :id, Serial property :email, String, :required =&gt; true end DataMapper.finalize get '/' do slim :index end post '/add' do Email.create params[:email] redirect '/' end </code></pre> <p>config.ru file:</p> <pre><code>require '/var/www/awesome' root_dir = File.dirname(__FILE__) set :environment, ENV['RACK_ENV'].to_sym set :root, root_dir set :app_file, File.join(root_dir, 'awesome.rb') disable :run run Sinatra::Application </code></pre> <p>httpd.conf file:</p> <pre><code>&lt;VirtualHost *:80&gt; ServerName foo.com DocumentRoot /var/www/public &lt;Directory /var/www/public&gt; AllowOverride None Options FollowSymLinks Options -MultiViews Order Allow,Deny Allow from all &lt;/Directory&gt; &lt;/VirtualHost&gt; </code></pre> <p>this is at the very bottom of my apache2.conf file:</p> <pre><code>LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.18/ext/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.18 PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p327/ruby </code></pre> <p>I've also given the group www-data write access to /var/www </p> <p>--UPDATE--</p> <p>Here is the output for the "ps axu | grep Pass" command:</p> <pre><code>root 28373 0.0 0.7 220936 1884 ? Ssl 13:15 0:00 PassengerWatchdog root 28377 0.1 1.0 2067100 2528 ? Sl 13:15 0:10 PassengerHelperAgent root 28379 0.0 3.8 111856 9508 ? Sl 13:15 0:00 Passenger spawn server nobody 28382 0.0 1.8 169332 4632 ? Sl 13:15 0:00 PassengerLoggingAgent </code></pre> <p>I'm running everything as the root user. This is just a test server and I wanted to just get everything working first. I had troubles before with installing ruby system wide so I started over with a clean server and I haven't added any other users.</p> <p>--UPDATE 2--</p> <p>emails.db was already set for everyone to read it with chmod 777, but I just changed it to chmod 666. Here is my ls -l output:</p> <pre><code>-rw-rw-r-- 1 root www-data 442 Dec 23 13:15 awesome.rb -rw-rw-r-- 1 root www-data 215 Dec 23 12:41 config.ru -rw-rw-rw- 1 www-data www-data 12288 Dec 23 12:56 emails.db -rw-rw-r-- 1 root www-data 54 Dec 23 10:55 hello.rb drwxrwxr-x 2 root www-data 4096 Dec 22 14:50 log drwxrwxr-x 2 root www-data 4096 Dec 22 15:34 public drwxrwxr-x 2 root www-data 4096 Dec 23 12:03 tmp drwxrwxr-x 2 root www-data 4096 Dec 22 17:16 views </code></pre> <p>I then restarted apache with "/etc/init.d/apache2 restart". I know going from chmod 777 to chmod 666 wouldn't fix my problem, but it is probably a little more secure. I re-ran my app and I still get the same "HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request." I'm pretty sure it still has something to do with apache and sqlite3 because when I comment out the "Email.create params[:email]" line I don't get the error.</p> <p>--UPDATE 3--</p> <p>Here is the output of "tail -f /var/log/apache2/error.log":</p> <pre><code>96.18.233.137 - - [24/Dec/2012 20:46:54] "GET / " 200 706 0.0274 96.18.233.137 - - [24/Dec/2012 20:46:54] "GET /favicon.ico " 404 18 0.0013 96.18.233.137 - - [24/Dec/2012 20:47:01] "POST /add " 14 - 0.0046 </code></pre> <p>And that is all it shows. Chrome shows:</p> <pre><code>Request Method:POST Status Code:500 Internal Server Error </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload