I'm serving three Ruby on Rails apps on one server, two of which are running on the system default ruby 2.0, and one running on ruby 2.2. For the latter I have set the PassengerRuby in my VirtualHost as follows:
<VirtualHost 137.154.17.242:80>
ServerName myappaddress.com
DocumentRoot /var/www/html/myapp/current/public
RailsEnv production
PassengerRuby /home/30036712/.rvm/rubies/ruby-2.2.0/bin
<Directory /var/www/html/myapp/current/public>
AllowOverride all
Options -MultiViews Indexes
</Directory>
</VirtualHost>
When I restart the server and refresh the page on the app I get an access denied to ruby 2.2 in my .rvm:
*** ERROR ***: Cannot execute /home/30036712/.rvm/rubies/ruby-2.2.0/bin: Permission denied (13)
Do I need an additional access setting somewhere? The other two apps run fine using ruby 2.0 (and permissions on the .rvm folders are exactly the same)
You specified the Ruby bin directory. But you really need to specify the Ruby wrapper script. See https://www.phusionpassenger.com/library/config/apache/reference/#setting_correct_passenger_ruby_value
Related
I know rails is the ruby framework and apache is the server of rails.While what is Phusion Passenger used for? Is it a server or a deploy tool?
Now I am trying to deploy my rails app on the server,while I don`t know how to use Phusion Passenger and apache to get my app running ):
thanks in advance
Phusion Passenger is just an apache mod that needs to be activated in the virtual host your application is using, telling apache which version of Rails is used and other configurations like this one. So basically, Apache uses Passenger to run Ruby on Rails applications.
You have to read this in order to install Passenger : https://www.phusionpassenger.com/download (just scrool down a little to read the open source version documentation).
And this in order to set it up and run it for one of your applications : http://www.modrails.com/documentation/Users%20guide%20Apache.html#_configuring_phusion_passenger So, yeah, a lot of text in here but you don't need to read everything fortunately.
Besides, when you install it, Passenger will tell you exactly what to write in your Virtual Host configuration and basically, there are only 2 lines of text. : )
Most of the time, if you have a virtual Host that looks like so :
<VirtualHost *:80>
ServerName www.wsgiapp.com
DocumentRoot /webapps/wsgiapp/public
<Directory /webapps/wsgiapp/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
Passenger will tell you to write something like this once installed :
<VirtualHost *:80>
ServerName www.wsgiapp.com
DocumentRoot /webapps/wsgiapp/public
PassengerRuby /usr/bin/ruby
PassengerRoot /somewhere/passenger/x.x.x
<Directory /webapps/wsgiapp/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
I need run 2 versions of ruby with my apache and I can try new passenger experimental. But I don't know how install it, because when I try this:
sudo ./bin/passenger-install-apache2-module
Installations is ok, but file mod_passenger.so don't exist.
Passenger 3.x supports a single ruby interpreter only.
5.2. PassengerRuby
This option allows one to specify the Ruby interpreter to use.
This option may only occur once, in the global server configuration. The default is ruby.
Passenger 4.x supports multiple rubies natively: (excert from the docs)
6.2. PassengerRuby
This option allows one to specify the Ruby interpreter to use.
Since version 4.0.0, this option may occur in the following places:
In the global server configuration.
In a virtual host configuration block.
In a or block.
In .htaccess, if AllowOverride Options is on.
If you want to use a different Ruby interpreter for two different applications then you should define different PassengerRuby directives in different virtual host blocks.
In versions prior to 4.0.0, only a single Ruby version is supported for the entire Apache instance, so PassengerRuby may only occur in the global server configuration.
The default value is ruby, meaning that the Ruby interpreter will be looked up according to the PATH environment variable.
you can use passenger gem, start your app in standalone mode with passenger and use reverse proxy into your apache conf(httpd).
<VirtualHost *:80>
ServerName locahost
DocumentRoot /home/test/www/second_app/public
RailsEnv development
PassengerEnabled off
ProxyPass / http://127.0.0.1:3000
ProxyPassReverse / http://127.0.0.1:3000
</VirtualHost>
I'm trying to deploy my first rails app on a mediatemple (dv) and i'm not having any luck.
I'm trying to use phusion passenger so i went over to http://www.modrails.com/videos/passenger.mov and watched the tutorial on installing this. I did everything with no issues and I'm when i point to my ip, i see an apache page and not my rails app.
I noticed that on mediatemple, I had to create a vhosts.conf file and run a command to reconfigure my project to look at this vhosts.conf file. Reference - http://kb.mediatemple.net/questions/1621/Why+is+my+vhost+file+not+being+used+by+Apache%3F#dv_40 For the last step I did /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain xxx.xx.xx.xx instead of reconfigure all.
Here's what my vhosts.conf file looks like:
LoadModule passenger_module
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby
<VirtualHost *:80>
ServerName xxx.xx.xx.xx
DocumentRoot /var/www/vhosts/myProject/httpdocs # <-- be sure to point
to 'public'!
<Directory /var/www/vhosts/myProject/httpdocs>
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
</Directory>
</VirtualHost>
Anybody have any luck deploying a rails app on a mt (dv) that can shed some advice to a rails noob?
I've just go this done on my dv server so here is a quick walk through. I will assume that you are working with Ruby 1.9.3 and Rails 3.2, and running all of the commands below as root.
You also have the latest version of rake and passenger install on your server. If not, try:
gem update --system
gem install rake
gem install passenger
Next step is to login to your MediaTemple admin panel. Click on the Admin button (not the Plesk one) for the domain you are interested and choose "Root Access and Developer Tools" option. Install the developer tools (this will take about 10mins).
Once that's done, ssh into your server and do the following:
passenger-install-apache2-module
There is a pretty good guided installation so I won't go into details here. You may need to install some additional dependencies here via yum so check the output of this script carefully.
Once that's out of the way, go and edit your httpd.conf file. This is saved under /etc/httpd/conf/httpd.conf. You will want to add the following lines to the end of it (please note the paths may vary as I am using rvm to manage my ruby installations and gemsets).
# Passenger Module for Apache (For Rails apps)
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125#rails32/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125#rails32/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125#rails32/ruby
PassengerDefaultUser root
At this point you should be ready to create a new rails app so remove everything from your httpdocs folder and issue the following command while logged in as the domain user (not root!)
rails new /path/to/httpdocs
Edit your vhost.conf file (or create a new one) in /var/www/vhosts/www.domain.com/conf (you will need to do this as root).
ServerName domainname.com
ServerAlias domainname.com
DocumentRoot /var/www/vhosts/domainname.com/httpdocs/public
<Directory "/var/www/vhosts/domainname.com/httpdocs/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RailsEnv development
RailsBaseURI /
And finally, issue
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain xxx.xx.xx.xx
And restart apache
/usr/sbin/apachectl -k restart
That should be it!
This link really helped me with the whole thing: http://www.twohard.com/blog/setting-rails-passenger-mediatemple-dv35-servers
What's the easiest way to point domain.com to my RoR app? When I don't include the port, ie domain.com:3000 it lists the directory.
If you are using apache, you need to use a rails mod to get it working. The best one is Phusion Passenger. It is very easy to set up, follow their directions, set up your virtual host and you'll be on your way. Again, apache cannot serve rails apps without extra additions.
It sounds like you are getting the mongrel/webrick servers that you run with ruby script/server or rails server confused with apache. In production don't even bother with webrick or mongrel if you've got apache running. Install Passenger. Then its easy, just go to your conf file and add your VirtualHost.
<VirtualHost *:80>
ServerName www.domain.com
DocumentRoot /webapps/mysite/public
<Directory /webapps/mysite/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
I have been struggling to get passenger to run my Rails/Rack apps.
Steps I used (as root):
Clean Debian 6 installation
aptitude install apache2, (Ruby
requirements taken from RVM),
git-core, curl, (and some more
packages too I guess)
getting rvm installed (system wide)
installing ruby 1.9.2-p180, and
setting it to be used as default
installing passenger gem, and
running the apache2 module
installation (getting apache2
prequisites along the way)
creating
/etc/apache2/mods-available/passenger.load
and placing:
LoadModule
passenger_module ... (the one
printed after apache2 passenger
module got installed)
creating
/etc/apache2/mods-available/passenger.conf
and placing:
PassengerRuby ...
PassengerRoot ... (the ones printed after apache2
passenger module got installed)
ap2enmod passenger (and getting apache restarted afterwards)
mkdir /var/www
setting /var/www to be user: root, group: www-data
creating /var/www/testapp and copying my rails app there
creating /etc/apache2/sites-available/testapp and placing in there:
<VirtualHost *:80>
ServerName localhost/testapp
DocumentRoot /var/www/testapp/public
<Directory /var/www/testapp/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
ap2ensite testapp
bundle install from within /var/www/testapp
/etc/init.d/apache2 restart
After opening in the browser: localhost/testapp I can only see my rails app structure (it didnt fire the page)
I don't know what I have done wrong. It seems to be pretty much okay. I am concerned about file permissions, groups and so on, although I have no clue how should I set these up. How should permissions be structured? Apart from that, anything else that looks suspicious?
Thanks!
ServerName can't have slashes in it. Just make ServerName localhost, and go to http://localhost to visit your site.
If you need multiple websites deployed on localhost, you can do that, but you need to follow the extra steps here:
http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rails_to_sub_uri