i first installed mod_ruby on my debian and afterwards ( after figuring out that it was too slow ) i wanted to chagne to passenger for my apache
Now i've got the problem, that the passenger is successfully loaded by the apache, but is not used, even though i configured everything correctly, like:
<VirtualHost *>
ServerAdmin webmaster#localhost
ServerName xyz
DocumentRoot /var/www/vhosts/default/htdocs/
RailsBaseURI /rails
</VirtualHost>
Instad of the the passenger the cgi - module is used for displaying rails-apps... ( if i unload the cgi.conf and cgi-load from the "sites-enabled" folder, it's not working anymore... on the other hand it still works if i unload the passenger.load and passenger.conf files... )
So, how can i force the apache to use the passenger to display rails sites?
Assuming you have passenger installed and configured correctly with Apache ... Your DocumentRoot needs to point at the public directory of your rails app. Here's a working VirtualHost directive:
<VirtualHost *:80>
ServerName myapp.local
DocumentRoot "/path/to/myapp/public"
RailsEnv development
<directory "/path/to/myapp/public">
Order allow,deny
Allow from all
</directory>
</VirtualHost>
Beforehand, also make sure that named virtual hosts are turned on:
NameVirtualHost *:80
And also that you actually have the passenger model configured correctly. For example:
LoadModule passenger_module /path/to/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
PassengerRoot /path/to/ruby/gems/1.8/gems/passenger-2.2.5
PassengerRuby /path/to/bin/ruby
Did you reconfigure the relative_url_root in your rails application? For example, in config/environment.rb:
config.action_controller.relative_url_root = "/rails"
Related
I would like to deploy a Ruby on Rails application on the web, and for that matter I have used/deployed the following tools:
Capistrano, to deploy the app files to the target location
The Phusion Passenger module for Apache
I have enabled the Passenger module through sudo a2enmod passenger. I have also installed the passenger gem through the gem installer, and added it to the Gemfile of my rails app.
I have then created an Apache virtual host for the app 'myapp'.
myapp.conf
Alias /myapp /var/www/myapp/current/public
<VirtualHost *:80>
DocumentRoot /var/www/myapp/current/public
SetEnv SECRET_KEY_BASE 592da***************************************
<Directory /var/www/myapp/current/public>
PassengerEnabled on
PassengerResolveSymlinksInDocumentRoot on
PassengerAppRoot /var/www/myapp/current
PassengerAppType rack
PassengerStartupFile config.ru
Allow from all
Options -MultiViews
Require all granted
</Directory>
</VirtualHost>
The virtual host work, but when I access the URL in a web browser, it shows the files index in /var/www/myapp/current/public instead of the actual app. The reason for this seems to be that passenger is not started, but I can't figure out why. I have tried to tweak the myapp.conf file to help apache and passenger detect the app, but without success.
Could anyone help me fix this? Thanks in advance.
Additional info: the app is deployed on a Raspberry Pi 3 with Raspbian Jessie as OS.
Try this .This is for sub uri deployment.Error is because PassengerRuby path has not been mentioned. Also go through this link
https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/.
Alias /myapp /var/www/myapp/current/public
<VirtualHost *:80>
SetEnv SECRET_KEY_BASE 592da***************************************
PassengerRuby /path-to-ruby /* replace this with your ruby path
<Location /myapp>
PassengerBaseURI /myapp
PassengerAppRoot /var/www/myapp/current
PassengerEnabled on
</Location>
<Directory /var/www/myapp/current/public>
Allow from all
Options -MultiViews
Require all granted
</Directory>
</VirtualHost>
I am deploying a ruby-on-rails application.
I have configured apache and passenger and the http server is listening on port 80.
When I try to access the home page using the browser, I simply get a list of files and directories instead of the home page.
Following are snippets from the apache config.
/etc/apache2/apache2.conf
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
/etc/apache2/httpd.conf
LoadModule passenger_module /home/user1/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.27/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/user1/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.27
PassengerDefaultRuby /home/user1/.rvm/gems/ruby-2.3.0/wrappers/ruby
</IfModule>
/etc/apache2/sites-available/ubuntuvm-4.conf
<VirtualHost *:80>
ServerAdmin admin#ubuntuvm-4.com
ServerName ubuntuvm-4
ServerAlias www.ubuntuvm-4.com
DocumentRoot /home/user1/www/myapp/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What is going wrong?
Could it be that I am trying to access the page via the ip address
http://192.168.0.12?
If you want me to put any other config, please shout.
try to copy the content of the file /etc/apache2/sites-available/ubuntuvm-4.conf
to /etc/apache2/sites-enabled/ubuntuvm-4.conf
cp /etc/apache2/sites-available/ubuntuvm-4.conf /etc/apache2/sites-enabled/ubuntuvm-4.conf
You need to create your config like this
<VirtualHost *:80>
ServerName ubuntuvm-4
<Location /home/user1/www/myapp/public>
PassengerBaseURI /
PassengerAppRoot /home/user1/www/myapp
</Location>
DocumentRoot /home/user1/www/myapp/public
<Directory /home/user1/www/myapp/public>
AllowOverride all
RailsEnv production
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
</VirtualHost>
I had the same problem trying to deploy a 4.2.1 Rails app on Ubuntu 12.04 using Ruby 2.3.2 (RVM because .deb packaged version is damn too old !!) Apache 2.2 and Passenger 5.0.4 (.deb).
Well, after wasting days to try to figure out why passenger wouldn't start (I did this a thousand times, it always worked), I realized it was only because Passenger couldn't print its logs anywhere. So, if you already tried everything you read on forums, just try to add a path to a log file in your apache configuration :
PassengerLogFile /var/log/passenger.log
and it worked like magic. Hope this helps.
I have main Rails app working on system Ruby and Passanger. Following virtual host works just fine:
<VirtualHost x.x.x.x:80>
ServerName domain.com
DocumentRoot /home/john/apps/main_app/public
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.29
PassengerRuby /usr/bin/ruby
<Directory /home/deploy/apps/main_app/public>
PassengerEnabled On
AllowOverride All
Require all granted
Options -MultiViews
</Directory>
</VirtualHost>
Now I want to add second virtual host for my second app working on different Ruby/Passanger versions and different domain but on same machine:
<VirtualHost x.x.x.x:80>
ServerName domain2.com
DocumentRoot /home/deploy/apps/app/public
PassengerRoot /home/deploy/.rvm/gems/ruby-2.1.5#app/gems/passenger-4.0.59
PassengerRuby /home/deploy/.rvm/rubies/ruby-2.1.5/bin/ruby
<Directory /home/deploy/apps/app/public>
PassengerEnabled On
AllowOverride All
Require all granted
Options -MultiViews
</Directory>
</VirtualHost>
After enabling second VirtualHost the first one (main app) is not working anymore. In browser I have 403 error. Same situation for second app.
Error log from main application:
[Sun Feb 15 13:29:08.596451 2015] [autoindex:error] [pid 53380] [client x.x.x.x] AH01276: Cannot serve directory /home/john/apps/main_app/public:
No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm)
found, and server-generated directory index forbidden by Options directive, referer: x
After disabling second app first one is working. How can I make to work both apps in the same time?
The configurations are incorrect. The two virtual hosts are using two different Passenger versions, and loading two different Ruby versions.
<VirtualHost x.x.x.x:80>
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.29
PassengerRuby /usr/bin/ruby
</VirtualHost>
vs
<VirtualHost x.x.x.x:80>
PassengerRoot /home/deploy/.rvm/gems/ruby-2.1.5#app/gems/passenger-4.0.59
PassengerRuby /home/deploy/.rvm/rubies/ruby-2.1.5/bin/ruby
</VirtualHost>
Here is the content of my /etc/apache2/sites-available/default file
NameVirtualHost *:80
<VirtualHost *:80>
ServerName domain.com
# !!! Be sure to point DocumentRoot to ('public')!
DocumentRoot /var/www
</VirtualHost>
<VirtualHost *:80>
ServerName a.domain.com
# !!! Be sure to point DocumentRoot to ('public')!
DocumentRoot /home/user/A/public
<Directory /home/user/A/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName b.domain.com
# !!! Be sure to point DocumentRoot to ('public')!
DocumentRoot /home/user/B/public
<Directory /home/user/B/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName c.domain.com
# !!! Be sure to point DocumentRoot to ('public')!
DocumentRoot /home/user/C
<Directory /home/user/C/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
The intention is to "link" the subdomain names (such as a.domain.com) to a Rails application running on a specific port (with multiple low intensity Rails application on the same server). The configuration shown above works to redirect to the appropriate static page AND/OR rails application, except for one of them which has a problem:
The problematic Rails application runs properly when accessed via:
domain.com:port (or domain.com:4444 )
however when attempts to access the same Rails application via:
c.domain.com (subdomain linked to the directory where the Rails app lives)
it throws this error:
https://github.com/net-ssh/net-ssh (at master) is not yet checked out. Run `bundle install` first. (Bundler::GitError)
To be clear, the same Rails application WORKS properly when accessed from domain.com:port but fails with c.domain.com
Since one of the Rails applications in the collection works and another fails, I find this very puzzling. So far I cannot find anything like this in my searches.
Questions and suggestions are very welcome.
Thank you,
~ Allen
NEWS:
I'm still reading documentation in an attempt to understand why accessing the rails application by port or by sub domain (domainname.com:port .vs. sub.domainname.com) behaves differently. However, I did determine making apache the owner of the directory structure helped get access by sub domain working. (apache user = www-data )
chown -R www-data:www-data /home/user/app
resolved the issue for one of the rails apps. There was also a .htaccess file in the public directory which had to be removed and the need to use this version of the bundle command:
bundle install --path vendor/bundle
that was not needed for the other application running on a sub domain.
It seems I have technically solved the puzzle, however I still don't understand the why it was necessary for one application and not for another.
Are your document roots all symlinks to the same RAILS_ROOT directory? Or is there a copy of the app in each of the document roots?
I'm at my wit's end here with virtual hosting. I'm trying to install redmine and it works with the webrick test server, but when I tried to use passenger (mod_rails) to host and go to the address I specified when in the virtualhost part of my apache config file nothing happens. Here is the relavent section of /etc/httpd/conf/httpd.conf where I try to set up the virtual host:
<VirtualHost *:80>
SetEnv RAILS_ENV production
ServerName redmine.MYSITE.com:80
DocumentRoot /opt/redmine-1.0.5/public/
<Directory /opt/redmine-1.0.5/public/>
Options -MultiViews
Allow from all
AllowOverride none
</Directory>
However, when I got to redmine.MYSITE.com:80 nothing happens, I just get our normal home page. I have no idea what the problem is, any help our guidance would be greatly appreciated. If you need any other information, please tell me and I'll provide it.
It took me a while to get Redmine running under Passenger. This is what I have
Install passenger:
passenger-install-apache2-module
Edit Apache confg file:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby
Create a new directory in the default server:
<Directory>
/webserver_root/html/redmine
RailsBaseURI /redmine
AllowOverride all
Options -MultiViews
</Directory>
Lastly, make a link to the physical directory where your ruby apps live (ie NOT under /html or whatever directory you serve most Apache pages from. This MUST be a link to redmine's public subdirectory)
ln -s /webserver_root/ruby_apps/redmine/public /webserver_root/html/redmine
So Apache now tries to show all the public pages as normal, but all other pages get routed through passenger. You access it as a subfolder - eg. http://mywebserver/redmine
Your VirtualHost *:80 directive must be matched by a corresponding NameVirtualHost *:80 earlier in your config.
You can ask apache what it makes of your vhosts with the -S switch. Of course, the name of your server binary depends somewhat on how it was installed and on what OS/Distro.