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>
Related
Background:
I have my web app running on unbuntu 18.04 + Apache & Passenger. I am using ruby 2.5 and rails 5.2. Right now the the project is running in development env.
Not sure if more info is needed so please ask. Thanks for anyone who can help. I am considering switching to NGINX and using ruby gem cap.
Question:
I am trying to configure Passenger to run my rails app in Production, but I can only make it run in development env. When I try to make changes for production env, it just stops working...
after changes I am running
sudo apache2ctl restart
sudo service apache2 restart
My .conf file
<VirtualHost *:80>
ServerName dev1.example.net
#ServerAlias dev1.example.net
#ServerAdmin webmaster#localhost
DocumentRoot /home/augustus/dev/xxx/public
RailsEnv development
PassengerRuby /home/augustus/.rbenv/versions/2.5.0/bin/ruby
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/augustus/dev/xxx/public >
# Allow from all
AllowOverride all
Options -MultiViews
# Options FollowSymLinks
Require all granted
</Directory>
:What I have tried
I am setting the RailEnv to 'production'
I have also reinstalled the repo completely
I read over other stack overflow post's about this. I am not having issues getting it running, but just putting it in production. When I visit the webpage (www.example.com), it gives me the "we're sorry, but something went wrong"..
the most helpful link was
OS X: Development & Production Deployment for RoR with Apache and Passenger
&& passenger dox
https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/digital_ocean/apache/oss/bionic/deploy_app.html
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 am using the Google Cloud Engine ruby stack, which uses RVM and Passenger on Debian 7. After following the Passenger configuration manual, I am only seeing a directory of the app's files when I navigate to the server root.
Here's the /etc/apache2/apache2.conf
<VirtualHost *:80>
ServerName http://130.211.149.208
DocumentRoot /var/www/myapp
<Directory /var/www/myapp>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
</VirtualHost>
Figured it out. The problem was /var/www/myapp should be /var/www/myapp/public
I was running only my django applications with apache2 mod_WSGI but now I want to add Rails (Passenger) applications to the same server. I installed Passenger and it's working fine.
After searched while I found a way to run it on www.myserver.com so I have:
www.myserver.com -> rails app
www.myserver.com/app1 -> django app 1
www.myserver.com/app2 -> django app 2
The problem is I don't know how to config httpd.conf file to run for example: www.myserver.com/myrailsapp -> rails app.
I'm on Ubuntu Server 10.04 and Apache2
httpd.conf:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/apache2/mod_passenger.so
PassengerRuby /usr/bin/ruby
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.2/
Include /etc/apache2/rails.conf
<VirtualHost www.myserver.com:80>
ServerName www.myserver.com.com
WSGIScriptAlias /hello /home/user/django/projects/hello/hello.wsgi
<Directory /home/user/django/projects/hello>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias /app1 /home/user/django/projects/app1/app1.wsgi
<Directory /home/user/django/projects/app1>
Order allow,deny
Allow from all
</Directory>
Alias /static/admin /home/user/django/src/django/contrib/admin/media
ErrorLog /home/usero/django/projects/logs/error.log
CustomLog /home/user/django/projects/logs/access.log combined
</VirtualHost>
At line: Include /etc/apache2/rails.conf
DocumentRoot /home/user/ruby/projects/redmine/public
<IfDefine PASSENGER>
RailsBaseURI /redmine
</IfDefine>
This include (rails.conf) is what made the Rails app run but I can put anything on 'RailsBaseURI /redmine' but nothing changes.
Q: How can I do www.myserver.com/redmine redirects to /home/user/ruby/projects/redmine/public ?
Any help is welcome.
Thanks.
Use passenger for the rails support for Apache and
apache2-mod-python ( sudo apt-get install apache2-mod-python ) for the django part.
It worked with me ;)
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.