Trouble deploying a Rails app (Linode, Passenger) - ruby-on-rails

I'm a brand new Rails user, I'm following this tutorial- http://ruby.railstutorial.org/chapters/a-demo-app#top . Had no issues accessing the demo app (from Chapter 2) on the local server. However having issues deploying to my Linode server. Here's what I've done:
Push the local app to BitBucket
Clone the repo on Linode to: /srv/www/preziki/first_app
Bundle install
rake db:migrate
Update VirtualHost for preziki:
ServerAdmin oleg#preziki.com
ServerName preziki.com
ServerAlias www.preziki.com
DocumentRoot /srv/www/preziki/first_app/public
ErrorLog /srv/www/preziki/logs/error.log
CustomLog /srv/www/preziki/logs/access.log combined
a2ensite preziki
Restart apache
Reload apache
If I go to www.preziki.com (or 176.58.104.181), I see the default Rails "Welcome aboard" page. If you click the "About your application environment" link, you get the "Sorry but something went wrong" error. If I go to www.preziki.com/users, (like I could with localhost/users), I get teh "Sorry but something went wrong" error.
If I point VirtualHost to the dir where I have a "Hello world!" index.html file, then preziki.com displays it without a problem.
What am I doing wrong?
Thank you.

First thing you can see the "default Rails" environment, means check your web server(apache) is working fine. because its a static request.
Second things when you want to go into application environment, then their is a problem means your application is not deploy properly.
Few thing you need to check.
1. Give the application directory all permission.
2. bundle install properly
3. Set RailsENV in virtual host
4. rake db:migrate properly.
5. Check your log file what problem it is showing.
<VirtualHost *:80>
ServerName localhost
DocumentRoot /home/user/project/trunk/public
PassengerEnabled on
RailsEnv development
<Directory /home/user/project/trunk/public>
</Directory>
</VirtualHost>

It sounds like you're nearly there. My guess is that the app has a problem connecting to the database. But to see for yourself what the problem is, look in the production log file:
/srv/www/preziki/first_app/log/production.log
That will usually tell you everything you need to know. Another thing you can do to debug is to use the console on the server, in production mode:
bundle exec rails console production

Related

RailsEnv misspelled or defined by a module not included in the server configuration

I am following this link http://blog.redpanthers.co/2015/10/how-to-deploy-a-rails-app-with-passenger-and-apache-in-ubuntu-14-04/ in order to install ruby on rails with rvm and passenger. I was fine until I got to configuring my demo.conf file using this command sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/demo.conf. When I tried to change RailsEnv production to RailsEnv dev or RailsEnv development it says that perhaps RailsEnv is misspelled or defined by a module not included in the server configuration. I tried to change this setting because the link says its necessary to be in the development environment in order to see the welcome aboard page. I dont know how to give you a copy of my error log file as I am running ubuntu 14.04 server on vmware and I can't copy out of that. I have pastebinit installed, so if anyone knows how I can copy code from the error.log file to show you why I am getting this error, please advise. Also I would like to know how to configure the acccess control as I am using apache 2.4 and the link im following isnt very clear. I would appreciate any help on this as I am doing it for a college project and I am hitting many walls with completing this installation. please bare in mind I am new to linux.
RailsEnv development AND restarting apache should do the trick:
service apache2 restart

How to change the configuration file to deploy a rails app with apache? on a subdomain

I was given an url http://XXXXXX.XXXX.XXX/avrccalendar/
and was asked to deploy my rails app on it.
At the beginning, there was a static webpage index.html in the /www directory, which is nothing but a message and was deleted by me.
This is my first time to deploy a rails app and I set my .conf like this:
VirtualHost *:80>
ServerName XXXXXX.XXXX.XXX/avrccalendar
DocumentRoot /home/avrccalendar/calendar/public
RailsEnv production
/VirtualHost>
I set it up that way, because I think rails app creates dynamic content, thus I didn't put the app files in the /www directory. However, when I visit the website it still get the static webpage index.html.
I cannot find whers the configuration is that set the url to return that static webpage.
And i would like to know how I should set .conf to make it to visite my rails app.
I have already installed passenger. The environment is Ubuntu 14.04.
Any advice would be helpful. Thank you~!

Remove Bitnami Jenkins Access page

I have bitnami jenkins installed.
I have no problem with the url http://yourhost/jenkins but i need to delete the Bitnami Welcome page. is any idea?
The documentation (https://wiki.bitnami.com/Components/Bitnami_info_page) says that the bnconfig tool should be used. However for me this doesn't work and I changed it manually in the apache configuration files.
To do so, change in file /opt/bitnami/apache2/conf/bitnami/bitnami.conf the lines:
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
and
<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apache2/htdocs"
into:
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apps/jenkins/htdocs"
and
<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apps/jenkins/htdocs"
Then restart apache:
sudo /opt/bitnami/ctlscript.sh restart apache
This si brutal but it works, and the vhost (http://yourhost/jenkins should also work) :)
Note that the main documentation (https://wiki.bitnami.com/Native_Installers_Quick_Start_Guide) says in part "How to change the default page that appears when accessing the installation?" that changing it manually is the way to go, but suggest to use a modified version of the main page. I guess this is fine if you have several apps installed.

prevent page caching with Rails and Passenger in Development Environment

I am running Rails 3 and Passenger 2 and I don't know why but my page is still cached despite having this configuration (in one of my virtual hosts):
<VirtualHost *:80>
ServerName railstut.dev
ServerAlias *.railstut.dev
DocumentRoot "/home/ygamretuta/dev/railstut/public/"
RailsEnv "development"
<Directory "/home/ygamretuta/dev/railstut/">
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
I tried it in Firefox with the browser cache disabled (via web developer plugin) so I don't think there's a problem with the browser cache. I always need to restart the server to see the changes made (even with some minor changes like replacing a text).
What could be the problem?
EDIT
Passenger seems to be setting the environment to production despite there being a RailsEnv config option.
EDIT
Passenger runs on production environment as seen on some of my pages accessing the DB. It looks for the database name configured in the production section in the database.yml file.
http://groups.google.com/group/phusion-passenger/browse_thread/thread/ddb9dbbad0bfe679
If you have existing file cache page cache entries, they will supercede the dynamic request even after restarting. You should clear your tmp or cache directories if you have ever used the file store for caching.

Directory listing instead of Rails site after Passenger/REE upgrade

Having updated Passenger and Ruby Enterprise Edition to the latest versions today, I am now seeing a directory listing instead of my Rails app. Here's the Passenger part of my Apache config:
#LoadModule passenger_module /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/passenger-2.1.3/ext/apache2/mod_passenger.so
#PassengerRoot /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/passenger-2.1.3
#PassengerRuby /opt/ruby-enterprise-1.8.6-20090201/bin/ruby
LoadModule passenger_module /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby
RailsEnv production
RackEnv production
PassengerMaxPoolSize 30
PassengerPoolIdleTime 600
PassengerMaxInstancesPerApp 10
PassengerUseGlobalQueue on
This config is definitely being loaded, the vhost is definitely pointing at the public directory of the app. The app itself works fine when run from the Rails console.
You'll see in the config above that the old passenger settings are commented out. If I comment out the new Passenger lines and uncomment out the old ones (i.e. switch to the older version of passenger), the app works fine again.
Tried reinstalling passenger/REE, no difference. There are no relevant entries in the Apache error log or Rails log.
Any help appreciated!
I was able to solve this using:
PassengerResolveSymlinksInDocumentRoot
It seems that Passenger no longer handles public directories that are symlinks to your app elsewhere by default. Turning this option on fixed all the issues.
I realized that I had /etc/hosts pointing the public URL of my app to 127.0.0.1 for my test callbacks in twitter.
It will simply keep showing a blank file listing.
removed the entry from /etc/hosts and everything came back to normal

Resources