Rails application isn't restarting after system reboot - ruby-on-rails

I have a Rails 4 application deployed with Apache and Passenger.
The configuration was provided by this thread and everything worked perfectly.
I created a whenever job that runs when the machine restarts, and I rebooted the machine to check if it works, and it does.
BUT, from some reason my web address is no longer reachable. It seems like the machine doesn't route the requests to the application (I get "this webpage isn't available" message from the browser).
I've double checked the /etc/httpd/conf/httpd.conf file to make sure the configuration still exists and it does.
I also tried to push again the application to the machine using cap production deploy, and didn't get any errors while doing that.
My configuration in the /etc/httpd/conf/httpd.conf file is the following:
<VirtualHost *:80>
ServerName csi-eng-perf.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/eng_performance/current/public/
<Directory /var/www/eng_performance/current/public/>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have no idea what have gone wrong.

Well, as it turns out #Substantial suggestion was correct.
I wasn't able to issue the apachectl status command (needed the installation of another package called links) but the restart command did the trick- apachectl -k restart.

Related

how to start my rails app in passenger using port 80

Hi I have deployed my rails app using passenger. but the problem is, it starts with the port 3000. I want to run my app on port 80. That is when I enter my app URL in address bar for example www.xyz.com, it should directly re-direct to my app's index page. but it does not. It goes to Apache’s welcome page. how to overcome this problem. I have tried in SO. but I did not get any solution. Thanks in advance
This is my VH conf file
<VirtualHost *:80>
ServerName http://0.0.0.0:80
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/School_Managements/public
<Directory /var/www/School_Managements/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
</VirtualHost>

Ruby + Passenger - Redmine deployment issue

I am trying to deploy Redmine on my web server.
I have chose to use passenger to deploy the ruby app.
I have tested with the rake's demo app, but when I pointed my VitualHost to the red mine public folder I got this error:
Directory index forbidden by Options directive: /var/www/redmine/public/
Can anyone help?
Virtual host:
<VirtualHost *:80>
ServerName redmine.myserver.com
DocumentRoot /var/www/redmine/public
ErrorLog /var/www/redmine/redmine-error-log
<Directory var/www/redmine/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
IMHO Passenger is missing some configuration in your example. Here is what I've in production :
<Directory /var/www/redmine>
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
</Directory>
Where /var/www/redmine was created as a symbolic link :
sudo ln -s /usr/share/redmine/public /var/www/redmine
You might also ensure that the rights are properly set on your redmine folder (the root one).
I have solved this issue.
The problem was caused by SElinux.
I had to enable the permissive mode.
setenforce 0
Then I have configured the Redmine app and set the correct permissions to the folders again.
In the end I have disabled the permissive mode:
setenforce 1

Seeing the document root instead of my rails app running, Ubuntu VPS with Phusion Passenger

I am running ubuntu on my VPS and have installed apache as well as phusion passenger to deploy my rails apps with. I went through the setup for phusion passenger and everything installed just fine. I edited the apache configuration files and have appended the information below. I have also made sure that the Virtualhost is not being overridden the default host and when I changed that and refreshed a browser I was brought to the public directory of my rails app instead of having the rails app being executed. Any help would be appreciated.
additions to /etc/apache/apache2.conf
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-3.0.8/ext/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.8
PassengerRuby /usr/bin/ruby1.8
PassengerDefaultUser www-data
<VirtualHost *:80>
ServerName localhost
DocumentRoot /home/bodylabel/globify/public
<Directory /home/bodylabel/globify/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
/etc/apache2/sites-enabled/000-default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
/etc/host.conf
# The "order" line is only used by old versions of the C library.
order hosts,bind
multi on
Just ran sudo passenger-status and got back the following:
*** Cleaning stale folder /tmp/passenger.44591
*** Cleaning stale folder /tmp/passenger.44300
*** Cleaning stale folder /tmp/passenger.44372
*** Cleaning stale folder /tmp/passenger.44200
*** Cleaning stale folder /tmp/passenger.21157
*** Cleaning stale folder /tmp/passenger.43944
*** Cleaning stale folder /tmp/passenger.21589
*** Cleaning stale folder /tmp/passenger.44878
ERROR: Phusion Passenger doesn't seem to be running.
the obligatory dumb question, but, did you restart apache?
Also, although this probably isn't the source of your problem, you may want to use the debian-esque method of deploying sites here and drop that virtualhost config into /etc/apache2/sites-available and run a2ensite to activate it.
There's probably a similar construct in place for modules-available and modules-enabled, where you might put that passenger code, rather than in apache2.conf.
You have two VirtualHost with the ip/port name *:80. Apache will do one of two things here. If you have a matching NameVirtualHost directive in your config then it will look for ServerName (and ServerAlias) directives within those two virtual host sections, and if the incoming request matches those server names/aliases then it will serve that virtual host.
Otherwise, it will serve the first VirtualHost block that is defined first in your configuration files. So, which one is being served will depend on the order that sites-enabled/000-default is included relative to the location of the VirtualHost section in apache2.conf

Setting up Rails app on Apache with passenger - Rails doesn't seem to load

I am trying to set up Rails on a Ubuntu instance by following along with documentation such as https://help.ubuntu.com/community/RubyOnRails. I am trying to set up the app from the Rails Getting Started page here: http://guides.rubyonrails.org/getting_started.html.
What I have done so far:
Installation of Ruby/RubyGems/Rails through RVM and GEM (this installed Ruby 1.9.2 and Rails 3.0.7)
Installation of the mysql and mysql2 module (latter which didn't work)
Creation of rails app (blog app as tutorial is instructing)
Sym linking of /home/me/www/blog/public/ from /var/www/blog/
Creation of DB through rake
Installation of passenger module for Rails execution in Apache
Running of passenger-install-apache2-module to configure Apache
Deletion of public.html file from public/ rails app folder so that my controller/view can fire
Configuration of sites-available files for virtual hosts
Configuration of Rails routing
I believe it is the last two steps that are tripping me up, partly due to lack of familiarity with Apache and Rails (I am new to both).
In my virtual host file I am trying to point to the blog public dir in /var/www/blog. For my Rails route I have root :to => "home#index" as instructed.
When I browse to the http:// url I should normally be seeing my "Hello, Rails!" page per section 4.3 of the Getting Started guide, however all I see is the directory listing from Apache. Static pages work but not Rails processing.
At this point I am unclear if the passenger module is even doing anything or where to look for any evidence of what is happening. I tried various things like running the Rails app off a different virtual host called "blog" at http:///blog and the routing worked (static pages and all) but no Rails as above.
Update: after playing around some more, I now get a new error message (404):
Not Found
The requested URL /dispatch.cgi was
not found on this server.
I have since determined that this cgi 404 was caused by a rewrite rule I had added to .htaccess from guidance from the help.ubuntu.com page I pointed out above. Looks like it wasn't necessary or applied to an older version of Rails. The inconsistencies in instructions when looking up help online is disorienting! Removing the file leaves me with the previous problem though.
Here's the entry in the Apache log that I believe correlates with the first error. Although I am no longer getting this error it seems, may be related to something else I was trying before...
[Fri May 27 22:49:41 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9 with Suhosin-Patch Phusion_Passenger/3.0.7 configured -- resuming normal operations
[Fri May 27 22:51:18 2011] [error] [client 192.168.1.141] File does not exist: /var/www/blog/rails, referer: http://192.168.1.138/blog/
Here's the most recent entry with the 404 on the cgi thing:
[Sat May 28 08:01:18 2011] [error] [client 192.168.1.141] File does not exist: /var/www/blog/dispatch.cgi
What could I be missing? Thanks!
Additional details as requested. Apache sites file:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/blog/
RailsEnv development
# <Directory />
# Options FollowSymLinks
# AllowOverride None
# </Directory>
<Directory "/var/www/blog/">
Options Indexes FollowSymLinks -MultiViews +ExecCGI
AllowOverride All
Order allow,deny
allow from all
# AddHandler cgi-script .cgi
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Another update: I was able to get it working, finally, by using a top level DocumentRoot (/var/www) and basing my Rails app off that using RailsBaseURI. This maps to the "Deploying to a sub URI" section of the Phusion Passenger instructions. It is used as http:///blog which is not really what I wanted to get, but it's kind of irrelevant as I am using this just to learn Rails in a virtual. I will need to go and work on getting it working as a top level app again sometime later. Here's my current (final) VirtualHost file for reference:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
RailsEnv development
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
</Directory>
RailsBaseURI /blog
<Directory /var/www/blog/>
Options Indexes FollowSymLinks -MultiViews +ExecCGI
AllowOverride All
Order allow,deny
allow from all
# AddHandler cgi-script .cgi
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Deploying a Ruby on Rails application
Suppose you have a Ruby on Rails
application in /webapps/mycook, and
you own the domain www.mycook.com. You
can either deploy your application to
the virtual host’s root (i.e. the
application will be accessible from
the root URL, http://www.mycook.com/),
or in a sub URI (i.e. the application
will be accessible from a sub URL,
such as
http://www.mycook.com/railsapplication).
Deploying to a virtual host’s root
Add a virtual host entry to your
Apache configuration file. Make sure
that the following conditions are met:
The virtual host’s document root must
point to your Ruby on Rails
application’s public folder.
The Apache per-directory permissions
must allow access to this folder.
MultiViews must be disabled for this
folder.
For example:
<VirtualHost *:80>
ServerName www.mycook.com
DocumentRoot /webapps/mycook/public
<Directory /webapps/mycook/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
You may also need to tweak your
file/folder permissions. Make sure
that the following folders are
readable and executable by Apache:
this public folder.
the application’s config folder.
all parent folders. That is, /webapps/mycook and /webapps must also
be readable and executable by Apache.
Then restart Apache. The application
has now been deployed.
Read the whole docs here
Double check to make sure passenger is loading your application by typing
sudo passenger-status
This will show you an error if passenger isn't loaded or the below if it is. Note the part where it shows you which application or applications it has loaded and what the current uptime is:
----------- General information -----------
max = 6
count = 1
active = 0
inactive = 1
Waiting on global queue: 0
----------- Application groups -----------
/home/rourkem/public_html/evecord.com/current:
App root: /home/rourkem/public_html/evecord.com/current
* PID: 18976 Sessions: 0 Processed: 5 Uptime: 23m 55s
Be sure to delete the file index.html from the public directory of your application.

Apache and passenger setup virtualhost restart failing

I have installed passenger on my Ubuntu 10.x server and I am running Apache2. I have followed the instruction "I think" pretty well. After setting up my virtual host and trying to restart I am getting a failed to start apache error because Documentroot takes one argument. I have the document root set is the thing so I am wondering if you guys could offer some suggestions as to what I may be doing wrong.
I have all my virtual hosts in separate files by domain name, so the directory structure on the server is something like this
/etc/apache2/sites-available/dev.mydomain.com
/etc/apache2/sites-enabled/dev.mydomain.com
both files have the following in them but restarting apache only fails when I put the vhost info in the enabled file.
<VirtualHost *:80>
ServerName dev.mydomain.com
DocumentRoot /home/myfolder/dev/vb/public # <-- be sure to point to 'public'!
<Directory /home/myfolder/dev/vb/public>
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
</Directory>
</VirtualHost>
Thanks for any help you can offer.
Comments in httpd.conf must go on their own line.
have you given before defining VirtualHost
NameVirtualHost *:80
if this given remove those commented line after document root and try

Resources