Apache webserver error - ruby-on-rails

i am running my ruby on rails application on a mac os x 10.7 on Apache Web Server with Passenger plugin. My httpd.conf file is as follows.
LoadModule passenger_module /Users/Ahmad/.rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/Ahmad/.rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19
PassengerRuby /Users/Ahmad/.rvm/wrappers/ruby-1.9.3-p392/ruby
NameVirtualHost *:80
<VirtualHost *:80>
ServerName qchext.local
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot "/Users/Ahmad/Sites/redbytes_projects/qchext/public"
<Directory "/Users/Ahmad/Sites/redbytes_projects/qchext/public">
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
ServerName qchext.local
error_log file
[notice] caught SIGTERM, shutting down
[notice] Digest: generating secret for digest authentication ...
[notice] Digest: done
[warn] mod_bonjour: Skipping user 'Ahmad' - no valid index file.
[notice] Apache/2.2.22 (Unix) Phusion_Passenger/3.0.19 DAV/2 configured -- resuming normal operations
Please guide me what wrong i ve done.

The SIGTERM you see is used to restart Apache, did you install the latest Apache with mod_passenger and not the Apache that comes bundled with OSX (Assuming that this is what you are running RoR on).

Related

Passenger 403 error

I am trying to install passenger for my rails app, but I dont know where is the problem.
Fallow the files:
httpd.conf
LoadModule passenger_module /usr/local/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/lib/ruby/gems/2.1.0/gems/passenger-4.0.53
PassengerDefaultRuby /usr/local/bin/ruby
</IfModule>
<VirtualHost *:80>
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/vagrant/shitatta/public
<Directory /home/vagrant/shitatta/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>
error_log:
[Sun Feb 22 09:49:20 2015] [error] [client 192.168.33.1] (13)Permission denied: access to / denied
[Sun Feb 22 09:49:20 2015] [error] [client 192.168.33.1] (13)Permission denied: access to /favicon.ico denied
The user that execute passenger and the web server doesn't have access to
/home/vagrant/shitatta/public
You should in my opinion make some changes:
Login with your user (vagrant)
Create a directory /opt/web/
Copy your project in /opt/web/shitatta
Go to /opt/web
Change auth access like : chmod 755 shitatta/*
Change owner : chown -R vagrant:vagrant shitatta
Change your apache conf with new paths
Add your user to www-data adduser vagrant www-data or any other user that will use Apache
If you have a permission denied when you run command, add sudo before each command. In my opinion it's a mistake to store your website in your home folder.
You should read about rails :
What permissions are needed for apache Passenger

Deploy ruby on rails app with passenger and apache

I want to deploy my ruby on rails application on Red Hat Enterprise Linux Server release 6.5 server
I have done the following:
Server version: Apache/2.2.15 (Unix)
rvm install ruby
gem install rails
gem install passenger
passenger-install-apache2-module
then I added the following line on my httpd.conf file
LoadModule passenger_module /home/myname/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/myname/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50
PassengerDefaultRuby /home/myname/.rvm/gems/ruby-2.1.2/wrappers/ruby
</IfModule>
alos I added the following to my httpd.conf
<VirtualHost *:80>
ServerName www.whatever.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/whatever/public
<Directory /var/www/whatever/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>
Additional info
rvm 1.25.31
I restarted the httpd and I cannot see my app running on whatever.com
I have bought the domain and redirected it to the IP of my machine.
What is wrong?
There's a number of reasons why this can happen, #user1876128 had some internal network issues and it wasn't acutally apache at fault.
For this apache setup to work, your network needs to allow http traffic to port 80 of your server box.
It's also advisable to allow traffic on port 3000, so you can run up a rails dev server on the same address (plus :3000) to check any changes before they're up.
You can log in to most domestic routers by pointing your browser at 192.168.0.1 or 192.168.1.1, then using the password (which is either written on your router, or the default password you can find online, or you've already changed it). And setting up a service for port 80 and your server box.
You need to uncomment the line indicated below and restart your apache service (sudo service apache2 restart or similar sudo /etc/init.d/apache2 restart)
<VirtualHost *:80>
ServerName www.whatever.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/whatever/public
<Directory /var/www/whatever/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>
This is a common issue with the default stuff from passenger. Chances are you're on a newer version of apache which means # Uncomment this if you're on Apache >= 2.4: would apply.

Apache2 multiple name-based virtual hosts on one machine with rails/rack

Am stuck on configuring apache to serve up two different sites with Name based virtual hosts at:
http://experimental/
and
http://api.experimental/
On one machine this setup works fine, and apache reports this:
apachectl -D DUMP_VHOSTS
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:* is a NameVirtualHost
default server experimental (/etc/apache2/sites-enabled/00-nowa.conf:3)
port * namevhost experimental (/etc/apache2/sites-enabled/00-nowa.conf:3)
port * namevhost api.experimental (/etc/apache2/sites-enabled/00-nowa.conf:15)
Syntax OK
On the 2nd machine this does not work, both URLS end up pointing to the first app, it's output of the same command is which has additional : lines:
apachectl -D DUMP_VHOSTS
apache2: apr_sockaddr_info_get() failed for experimental
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Tue May 14 15:36:08 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
[Tue May 14 15:36:08 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:* experimental (/etc/apache2/sites-enabled/00-nowa.conf:3)
*:* api.experimental (/etc/apache2/sites-enabled/00-nowa.conf:15)
Syntax OK
The vhost files for each machine are this for the broken one:
<VirtualHost *>
ServerName experimental
RailsEnv production
DocumentRoot /home/nowa/nowa_app/nowa/current/public
<Directory /home/nowa/nowa_app/nowa/current/public >
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName api.experimental
RackEnv production
PassengerMinInstances 2
PassengerMaxPoolSize 10
DocumentRoot /home/nowa/nowa_app/services/api_gateway/current/app
</VirtualHost>
And working:
<VirtualHost *>
ServerName experimental
RailsEnv production
DocumentRoot /home/nowa/nowa_app/nowa/current/public
<Directory /home/nowa/nowa_app/nowa/current/public >
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName api.experimental
RackEnv production
PassengerMinInstances 2
PassengerMaxPoolSize 10
DocumentRoot /home/nowa/nowa_app/services/nowa_api_gateway/current/app
</VirtualHost>
Why is the output of apachectl -D DUMP_VHOSTS different?
What have I missed? :C
Asked on the #httpd irc room and turns out apache was misinterpreting
<VirtualHost *>
as an IP based vhost entry, not a name based one, changing it to this fixed it:
<VirtualHost *:80>
This was because NameVirtualHost was defined like this on the broken server:
NameVirtualHost *:80
Complete working config:
<VirtualHost *:80>
ServerName experimental
RailsEnv production
DocumentRoot /home/nowa/nowa_app/nowa/current/public
<Directory /home/nowa/nowa_app/nowa/current/public >
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName api.experimental
RackEnv production
PassengerMinInstances 2
PassengerMaxPoolSize 10
DocumentRoot /home/nowa/nowa_app/services/api_gateway/current/app
</VirtualHost>

Mac OSX Lion Apache + RubyOnRails + mod_passenger

I'm trying to learn how to develop web application with Ruby On Rails but I've incurred in a silly error.
I'm trying to use Phusion Passenger aka mod_rails to use Apache instead of WEBrick; I've installed the module via gem and run the
sudo passenger-install-apache2-module
command to install passenger; then I edited the http.conf file adding
LoadModule passenger_module /Users/Stopped/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/Stopped/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.19
PassengerRuby /Users/Stopped/.rvm/wrappers/ruby-1.9.3-p327/ruby
added the VirtualHost
<VirtualHost *:80>
ServerName rails.local
DocumentRoot "/Users/Stopped/RoR/prova/public"
<Directory /Users/Stopped/RoR/prova/public>
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
restarted Apache with sudo apachectl restart but It's not working :( If I lookup in localhost I see the "It works!" page but if I go at rails.local there is not my Rails app :(
Passenger is loaded
Apache/2.2.22 (Unix) Phusion_Passenger/3.0.19 DAV/2 PHP/5.4.9 Server at localhost Port 80
Any ideas?
PS: This is "apachectl -S" output
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server rails.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
port 80 namevhost rails.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
Syntax OK
SOLUTION
Uhm... I solved it, adding 127.0.0.1 rails.local to my hosts file but I can't understand why; can someone explain this to me? ._.
you can't use a wildcard with localhost in your hosts file. you have to explicitly specify each subdomain for localhost in your hosts file. if you're looking for an alternative, you could buy a domain name and point that domain name to 127.0.0.1 with a wildcard. you could even go a step further and have a skeleton app which points different subdomains to different applications by mapping the routes.

Installed Phusion Passenger on Server but apache2 didn't install in /etc/apache2/

I am following instructions on how to deploy rails application on server.
I did the following:
sudo gem install passenger
passenger-install-apache2-module
Everything is successful so far. But next on instruction he uses:
nano /etc/apache2/sites-enabled/000-default
Problem is there is no apache2 directory in etc. Therefore, I have no clue where the file I need to stick this information is:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.mywebsite.com
DocumentRoot /var/www/mywebsite/public
<Directory /var/www/mywebsite/public>
Options Indexes FollowSymLinks -MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Thanks for any response.
Apache is separate and will not be installed with phusion passenger. You need to install it by yourself and it depends on your OS (it seems you are on a linux system), so you may try something like this in the command line:
apt-get install apache2

Resources