We are setting up Rails applications on Ubuntu 22.04 and when I visit the application URL I get a listing of files from within the app's public directory. Does anyone have any thoughts as to why Phusion Passenger is not auto-detecting the Rails application?
Thank you
Chris
Passenger -v: 6.0.15
Apache -v: 2.4.52
I don't know if this will help anyone else but the below changes is what we did which then enabled Phusion Passenger to auto-detect the Rails application.
Server Admin removed the default 001-ssl.conf file which contained SSL statements and added them to the below .conf file.
Changed my symlink to eops -> /home/eops/app/eops/current. My symlink was found at /var/www/html/
My rails_apps.conf file to:
<IfModule mod_ssl.c>
<VirtualHost mydomain.com:443>
ServerName mydomain.com
ServerAdmin my_email_address
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
# Overall Rules For The DocumentRoot
<Directory /var/www/html>
# Relax Apache security settings
AllowOverride all
Require all granted
# MultiViews must be turned off
Options -MultiViews
</Directory>
# ------- Host apps below
# Shib protected at Application Level
<Directory /var/www/html/eops>
Allow from all
Options -MultiViews
# Uncomment below line if you are on Apache > 2.4
Require all granted
</Directory>
Alias /eops /home/eops/app/eops/current/public
<Location /eops>
# Require Shibboleth authentication
AuthType shibboleth
ShibRequestSetting requireSession 1
require valid-user
PassengerBaseURI "/eops"
PassengerStartupFile config.ru
PassengerAppType rack
PassengerAppRoot /home/eops/app/eops/current
RailsEnv staging
PassengerRuby /home/eops/.rbenv/versions/2.1.6/bin/ruby
</Location>
</VirtualHost>
Related
I have installed mod_passenger (passenger-install-apache2-module) and have the following in my Apache configuration:
LoadModule passenger_module /var/www/html/vendor/bundle/ruby/2.2.0/gems/passenger-5.0.24/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /var/www/html/vendor/bundle/ruby/2.2.0/gems/passenger-5.0.24
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.2.2/ruby
</IfModule>
RackEnv production
<VirtualHost *:80>
ServerName domain.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/html/public
<Directory /var/www/html/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
My Rails website is working however some URLs that end in .php or .txt do not get processed by Passenger resulting in a generic 404 page instead of the nicely formatted 404 page on my Rails site.
How can I route all file extensions to Passenger/Rails?
Or how can I make URLs that end in .php actually be processed by PHP.
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've been struggling with this for hours. It's the first time that I try to establish a server.
I have rails, passenger and apache installed.
In the httpd.conf here is what I wrote:
ServerRoot "/etc/httpd"
# Here I wrote the IP address, since I still did not manage the DNS
Listen ##.##.##.94:80
ServerAdmin root#localhost
ServerName ##.##.##.94:80 # Do I need this?
<Directory />
AllowOverride none
Require all denied
Options Indexes FollowSymLinks Includes ExecCGI
</Directory>
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-4.0.59/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-4.0.59
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>
<VirtualHost *:80>
ServerName ##.##.##.##
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/blah_blah/public_html/public
<Directory /var/www/blah_blah/public_html>
# 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>
The last section was produced by passenger (I did not! copy it from the instructions :-) ).
When I go to the IP address I get an error that the page was not found.
I have rails running with "rails s". Before that I reloaded the server and restarted it for the config file to take effect.
Also, I granted apache user permission to the www folder.
What is the problem?
I even tried to put an index.html file in the public folder of rail and tried to go there, but failed.
BTW - when I do it from the console:
wget http://0.0.0.0:3000
I get a 200 response which means that it is OK.
Where is the fault?
I think you should change the port:
<VirtualHost *:3000>
Because when you run rails s it run on port 3000.
I'm tryig to run ruby on rails and redmine on xampp. My operating system is windows 7.
I followed this tutorial: http://nlb-creations.com/2013/06/26/installing-ruby-on-rails-and-redmine-with-xampp-on-windows-7/
When I try to access localhost:3000 I get this:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
This is my setup in httpd.conf:
Listen 3000
LoadModule rewrite_module modules/mod_rewrite.so
#################################
# RUBY SETUP
#################################
<VirtualHost *:3000>
ServerName rails
DocumentRoot "c:/xampp/htdocs/dev-ruby/redmine/public/"
<Directory "c:/xampp/htdocs/dev-ruby/redmine/">
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
Require all granted
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi
</Directory>
</VirtualHost>
#################################
# RUBY SETUP
#################################
I tried many solutions but none of them worked. I also deleted .htaccess file but nothing changed. Any ideas please??
If your document root in C:\ disk, you should change the xampp folder (and subfolders) permissions for your user.
I'm working on setting up a pair of redmine instances on a single server under apache.
The first worked fine and I have a virtualhost set up for it with the following vhost config:
<VirtualHost *:80>
ServerName tickets.domain.com
DocumentRoot /var/www/redmine
RailsEnv production
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
</VirtualHost>
The second I needed to setup as a subdirectory off of the main default site:
Alias /ops/ "/var/www/ops/"
<Directory "/var/www/ops/">
RailsEnv ops
RailsBaseURI /ops
PassengerResolveSymlinksInDocumentRoot on
</Directory>
So server/ops is the url for the second instance.
The trouble I'm having is that when I restart apache, whichever url you hit first seems to "win" and it breaks the other instance of the site. If I hit the /ops url then it loads just fine, but going to tickets. will cause me to get permission denied errors because all of the urls have /ops in them (for the JS and other files)
If I restart apache and hit the tickets. site first, it loads just fine but then I get 404 errors from Redmine on the /ops url.
This is on Ubuntu with a redmine PPA and both /var/www/ops and /var/www/redmine are symlinks to the shared redmine source code with their own environments defined (production and ops).
Any hints on how I can make these two live side by side successfully?
Thanks
this is my apache configuration hosting multiple redmine instances (domain.tld/dev1, domain.tld/dev2, ...).
You also have to change :key and :session_path in config/initializers/session_store.rb of each redmine setup.
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
Servername domain.tld
ServerAdmin webmaster#domain.tld
DefaultInitEnv RAILS_ENV production
DefaultInitEnv GEM_PATH /var/lib/gems/1.8
DocumentRoot /var/www/default-ssl
<Directory /var/www/default-ssl>
AuthType Basic
AuthName "secure section"
AuthUserFile /etc/apache2/htpasswd
Require valid-user
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 "Application error Rails application failed to start properly"
AllowOverride None
Order allow,deny
allow from all
</Directory>
LogLevel warn
ErrorLog /ssl_error.log
CustomLog /ssl_access.log combined
ServerSignature Off
SSLEngine on
SSLCertificateFile /etc/ssl/certs/domain.tld.crt
SSLCertificateKeyFile /etc/ssl/private/domain.tld.key
SSLCACertificateFile /etc/ssl/certs/domain.tld.ca
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
BrowserMatch "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
Alias /dev1 /var/www/default-ssl/dev1/public
<Directory /var/www/default-ssl/dev1/public>
PassengerAppRoot /var/www/default-ssl/dev1
RailsBaseURI /dev1
Require user user1 user2
</Directory>
Alias /dev2 /var/www/default-ssl/dev2/public
<Directory /var/www/default-ssl/dev2/public>
PassengerAppRoot /var/www/default-ssl/dev2
RailsBaseURI /dev2
Require user user1
</Directory>
...
</VirtualHost>
</IfModule>
passenger distingues configs based on paths. Please take a look into the Ubuntu bug database:
Multiple instance of redmine does not work with passenger
create directories for every config:
/var/lib/redmine/*configname*
create symlink from redmine dir:
ln -s /usr/share/redmine /var/lib/redmine/*configname*/passenger
in your apache virtual host you can add alternative PassengerAppRoot:
PassengerAppRoot /var/lib/redmine/*configname*/passenger