Unable to deploy to Apache

Hi All,

Can someone please help? I've been banging my head against for wall
for 2 months; all of which has been spent trying to set up ROR. So I
actually haven't written 1 line of code :frowning: Any help would be greatly
appreciated :slight_smile:

I'm following the 4th edition of "Agile Web Development with Rails".
So, I'm able to deploy the site via WEBrick. However, when I go to my
URL (without using port 3000), I get the error message below. What am
I missing?

By any chance, have you run rake:db:migrate RAILS_ENV=production yet? If not, then one possible reason why you can't open the database is that it does not exist.

Walter

The problem is not with your web server but with your database file.
Check the database configured in config/database.yml exists and is
accessible by the user that runs Apache (I guess on CentOS that user
is called apache).

If not, you should run:
rake db:create

Hope this help.

Cheers!

Hi Leonardo,

Per my reply to Walter, I just ran "rake db:migrate
RAILS_ENV=production". However, I now get a "500 Internal Server
Error".

Below is my config/database.yml file and these are the permissions to
the db/production.sqlite3 file.

-rw-r--r-- 1 root root 5120 Mar 29 20:45 production.sqlite3

Do I have to change the ownership for this file?

Thanks,

Kal

(Re-posting)

Thanks Walter,

I think you are correct. I had neglected to set up a production
version of the database.

I just ran "rake db:migrate RAILS_ENV=production". However, I now get
a "500 Internal Server Error".

Anyway, here is the error from production.log. Any ideas?

Thanks,

Kal

(Re-posting)

Thanks Walter,

I think you are correct. I had neglected to set up a production
version of the database.

I just ran "rake db:migrate RAILS_ENV=production". However, I now get
a "500 Internal Server Error".

Anyway, here is the error from production.log. Any ideas?

Sure. rake assets:precompile and you should be good to go.

Walter

Hi Walter,

I did as instructed but now getting a "rake aborted! stack level too
deep" error (in /home/rubys/work/depot/app/assets/stylesheets/
scaffolds.css.scss).

I also tried modified "config.assets.compile = true" (from false)
within config/environments/production.rb but still no good :frowning:

Thanks,

Kal

Hi Walter,

I did as instructed but now getting a "rake aborted! stack level too
deep (in /home/rubys/work/depot/app/assets/stylesheets/
scaffolds.css.scss)" error.

I tried to modify "config.assets.compile = true: (from false) within
config/environments/production.rb but still no good :frowning:

What version of rake? What version of bundler? Have you run bundle install or bundle update on your server? I'm guessing in the dark here, but it sounds like you may not have everything the same on your server as your dev box, version-wise. If you were able to use the site locally, it should work on the server. Try running the site in production on your development machine, using

rake db:migrate RAILS_ENV=production
rake assets:precompile
rails server RAILS_ENV=production

to duplicate the experience locally. See if it's specific to this server.

Also, try prefixing your assets:precompile step on the server with bundle exec so you're sure you're getting the actual versions of everything when you do that.

Walter

Ok this might sound funny but , this problem is usually caused by lack
of javascript libraries in your rails setup so i would recommend you to
do this .

Install this gem and you should be ready to go

gem install therubyracer

If it works or it doesnt work let me know

My apologies Walter, et al.

I haven't had access to my computers within the last 24 hrs. I shall
look into your recommendations tonight.

As always, thank you for your assistance and prompt replies.

~Kal

Hi Walter,

Again, my apologies for the delay in reply. I'm more confused now
than before, so it took some time to poke around.

Firstly, I don't run a separate development and production server.
Does that matter?

Installed are rake (0.9.2.2) and bundler (1.0.21). I have not run
bundle install or bundle update

Typo: product listing are NOT displayed :frowning:

Hi L,

therubyracer (0.9.9) is already installed :frowning:

Thanks Anyway :slight_smile:

~Kal

Hi Walter,

Again, my apologies for the delay in reply. I'm more confused now
than before, so it took some time to poke around.

Firstly, I don't run a separate development and production server.
Does that matter?

If you start rails with rails server (and no other arguments) you are starting the development environment, which means you are running the development server. This uses a different database than production, and by default listens on port 3000. When you start rails under Passenger or another proxy system, you are starting the production environment, which uses a different (production) database and listens on the default port 80 (depends on your Apache config, actually).

Installed are rake (0.9.2.2) and bundler (1.0.21). I have not run
bundle install or bundle update

You really must do this on the server, having done it on the desktop computer will not have instantiated the gems on the server, and you can pretty much guarantee failure to run.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Although, I am thinking that it's a permission issue now.

Permissions is a valid concern here -- how did you get the files over to your server? What exact method did you use to copy the files from your desktop computer to the server?

Walter

Hi Walter,

Very sorry for the confusion.

When I mention server, I'm actually referring to the box, not a
service(s).

I'm actually running everything from a virtual dedicated server
(through GoDaddy.com).

I'm not testing any of the aforementioned items on a desktop nor am I
deploying to Apache via (localhost); everything is live.

As stated in my initial posting "I'm able to deploy the site via
WEBrick. However, when I go to my URL (without using port 3000), I
get the error message below".

Of course, the original error message no longer appears (thanks to
your advise :).

I found the following posting, what do you think of item 4?

http://www.cowboycoded.com/tag/passenger/

Thanks,

~Kal

Hi Walter,

Very sorry for the confusion.

When I mention server, I'm actually referring to the box, not a
service(s).

I'm actually running everything from a virtual dedicated server
(through GoDaddy.com).

I'm not testing any of the aforementioned items on a desktop nor am I
deploying to Apache via (localhost); everything is live.

Are you writing the app on the server? Aren't you building the app on your local machine?

As stated in my initial posting "I'm able to deploy the site via
WEBrick. However, when I go to my URL (without using port 3000), I
get the error message below".

Of course, the original error message no longer appears (thanks to
your advise :).

I found the following posting, what do you think of item 4?

http://www.cowboycoded.com/tag/passenger/

That's very interesting. I think that makes a lot of sense. Make a new user, then `chown - R new_user /path/to/rails/root` and see if that makes a difference.

Walter

Hi Walter,

I was wrong; creating a new user 'app_user', adding it to the sudoer
file, and then applying 'chown - R app_user /home/rubys/work/depot'
did work.

I was just reading too deep into Cowboy's (http://www.cowboycoded.com/
tag/passenger/) instructions, which didn't pertain to my setup
(specifically, the part about NGINX).

However, my setup was still not working and I think my problem
involves asset pipeline (Sprockets).

This is further complicated by me following the "Depot" exercise in
the 4th edition of "Agile Web Development with Rails"

I've since rebuilt the entire test app with a couple of simple pages
and no database content.

I ran "RAILS_ENV=production bundle exec rake assets:precompile" and
successfully got it to appear on Apache.

This is warrants much investigation but at least I know everything
wired properly.

Thanks Again,

~Kal
PS: I really don't know about ROR. It's really kludgy to say the
least :frowning:

I get the same error. I am also using passenger, although I don't
always use it. I am also using RVM.

I noticed an error that popped up in my email from rake (I am working on
a Mac) that showed an error from rake 1.8.X something or other, instead
of the rake from 1.9.2 that I am running. I suspect that deep in some
of the code, someone is diddling the path incorrectly. I don't have
time right now to chase it down, but I thought that this might at least
help.

I get the same error. I am also using passenger, although I don't
always use it. I am also using RVM.

I noticed an error that popped up in my email from rake (I am working on
a Mac) that showed an error from rake 1.8.X something or other, instead
of the rake from 1.9.2 that I am running. I suspect that deep in some
of the code, someone is diddling the path incorrectly. I don't have
time right now to chase it down, but I thought that this might at least
help.

That's an excellent point. Look in your Apache configuration and make sure that the path to Ruby in your Passenger configuration block includes your rvm prefix, and to the Ruby you think you're using. You may not be running the same Ruby for Passenger as your application, and that's guaranteed to be awful.

Walter

Hi Walter,

They look correct... (from httpd.conf)

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/
passenger-3.0.11/ext/apache2/mod_passenger.so

PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11
PassengerRuby /usr/local/bin/ruby