Where to install Nginx when using rvm - ruby-on-rails

Where do I want to install Nginx when I am using RVM. It defaults to the system version 1.8.7. I need it to use 1.9.3
Where do you want to install Nginx to?
Please specify a prefix directory [/opt/nginx]:

First of all, specify your ruby version.
rvm install 1.9.3 (if you don't already have it)
rvm use 1.9.3 (--default)
Then you need:
gem install passenger
cd /your gems dir (such as ~/.rvm/gems/ruby-1.9.3-p0/gems)/passenger/bin
./passenger-install-nginx-module
What about destination directory? All to your decision:
if it's developer's/learning machine - recommend to install in ~/nginx
if it's something like 'production' - create user for web application, cut him rights, install rvm and all rails enviroments for him, nginx install to common directory (/opt/nginx) for access to nginx from several accounts simultaneously.
General rule: RVM & Rails (web app) is for one user => nginx may be for one user. In a different way => global

Related

Why rvmsudo is needed to install passenger

I have browsed around but unable to find why rvmsudo is needed for passenger installation.
I am installing passenger with nginx in my server and I'm using RVM. According to the passenger user manual I need to use rvmsudo to install passenger if I have rvm installed.
Whats the difference between using rvmsudo and without using rvmsudo. Is using rvmsudo to system wide install needed despite having rvm installed locally only ? (just use gem install passenger)
Thank You !
sudo grants a command root permissions to the current user to carry a certain activity (given the user is allowed to use sudo). That said, on installing passenger you need root permission to install files at required locations.
One simple thing to do that comes to mind instantly is:
sudo rvm passenger-install-nginx-module
This won't work! Here's the explanation:
However, this won't work at all. sudo will start a new subshell.
That new subshell's environment will be completely different, and
won't contain RVM, nor will it have access to your user's RVM without
trying to hack in RVM's environment variables yourself.
Therefore you are required to use the solution provided by RVM i.e. rvmsudo. It will pass on any environment variables that RVM set up to get you to the correct Ruby along with sudo privileges, which is exactly what you need to install passenger in this example.

How to manage ruby gems in linux?

As I have started using Linux (Ubuntu) to broaden my knowledge, but the flow for ruby (rails) development does not feel so smooth as on Mac OSX.
Do you use rvm to manage ruby gems in Linux?
One particular issue I face is that I could install rails with only sudo command. But this forces me to use sudo for all the time under my rails project.
P.S.
Might be I am missing some point with the way you do things in Linux so it is not related to ruby (or rails) at all.
It is preferred to use rvm. we can install ruby and rails without rvm as well, but we can have only one version at a time. You can find the instructions to install rvm from following link - rvm installation.
If you are the only person working on ruby rails, install in single user mode(doesn't need to go with sudo)
Installing ruby and rails only using superuser privileges means you're installing it from distribution packages. That's not recommended, and you get unneeded overload writting sudo before any rails command.
Install rvm or rbenv in your home directory and things should be smooth.

Uninstall Ruby on Rails cpanel server

I'm sitting here with a cPanel server, and I want to uninstall ruby, and ruby on rails.
I can see there is /scripts/installruby, but not a remove.
Does anyone know how I can uninstall ruby and rails from my server? So I can free up the space given I don't use it anyway?
Please note that I do have full root access to the server!
It depends on what you run. If Ruby was installed through a packet manager like apt you can simply use that to uninstall it.
apt-get remove ruby
If the ruby install was a build from source you obviously either want to find the sources and do a make uninstall or you simply delete the folders where ruby is at (which ruby gives you the paths)
Ruby on Rails is only a gem inside ruby - so deleting the ruby folder with the gem folder in it will also remove rails. Make sure to clean up your path of any references to the ruby/bin and gem/bin folders and you should be good.
Then you have to figure out what application server was running ruby on your box. And uninstall those seperatly (passenger, unicorn, mongrel etc)..

How do I install Ruby gems when using RVM?

I set up RVM and used it to install Ruby and a few other libraries. As I was going through various tutorials and set-ups of other technologies like Rails, I began getting confused about what I should do via RVM and what I should just do as the tutorials suggest.
One example is the RubyGems tutorial here:
http://rubygems.org/pages/download
Should I download that tar file they are talking about? Seems unnecessary since that is what I thought RVM was for. Do I even need RubyGems? What is that for really?
Also, how do I actually get Rails? Is there a precise RVM command to actually download and install Rails?
It helps me to think of RVM as a layer of abstraction between you and the ruby ecosystem.
Without RVM: ruby, gems, and ruby related binaries (like rake, spec, gem, etc) are all installed directly into your operating system directories.
With RVM: ruby related stuff is intercepted by rvm so that ruby, gems, and ruby related binares are "installed" into ~/.rvm dir in a nice, clean, organized way. RVM sits between ruby, gems, and related binaries and the operating system. It provides a way to have multiple ruby environments (with different gems and binaries) on the same machine.
So, no matter whether you have rvm installed or not, you should be able to run the commands almost exactly(*) as they appear in any tutorials out there on the web. In other words, you can sort of "forget" that RVM is installed; the ruby ecosystem should work just as if it wasn't installed.
So, yep, you're gonna have to run gem install rails, etc.
Hope that helps clear the confusion.
(*) There are some small differences. For example: you shouldn't run commands as sudo when RVM is installed.
Should I download that tar file they are talking about?
No. Ruby 1.9+ includes gems. RVM retrofits it for 1.8+.
In general, be careful with any directions you find on the internet explaining how to install anything, unless you have enough experience to understand completely what they want you to do. In particular, any time they want you to install something using sudo or as root.
Specifically, when working with RVM, you do NOT want to use sudo to install Ruby, or any gem. RVM works by setting up a sandbox for your development, and relies on your account's environment, modifying your path so any Ruby requests go to the currently selected RVM-managed Ruby or gems or any commands they install. sudo pushes your normal environment to the side, substituting root's temporarily, installs whatever you asked it to do with root's permissions, then reverts to your environment.
When you go to run the command, or find the gem, as you, it can't be found by RVM's Ruby, because the file was installed outside RVM's sandbox, or, it can't be read or modified, because it's owned by root. Whatever the actual cause, the end result will be weeping and gnashing of teeth.
RVM doesn't subvert the gem functionality. gem is used to install and manage Ruby gems, and RVM tweaks it to use the sandbox for all its machinations. You get added functionality because of RVM's support of gemsets, but gem works as it always has, only it has "big brother", RVM, controlling its world.
No need to install rubygems. RVM should have already installed rubygems. RVM is (in my opinion) useful for managing different installations of ruby (say 1.8.7 and 1.9.2) or different gemsets. If you just have one version of ruby and don't care about different gemsets, RVM isn't really that much of a change. If you want to just install rails, just use gem install rails. If you have an existing rails 3 app, install bundler first gem install bundler and then bundle install to get rails and other gem dependencies.

ruby 1.9 and 1.8.7 installed how do I make app use 1.8.7

I have two version of ruby installed 1.9 and 1.8.7(via macports) how do I make my app run with 1.8.7?
And How can i uninstall 1.9?
TIA
Firstly: switch to rvm it's excellent for ruby management
If you don't want to then I believe you can remove the ruby package with (if installed with macports) with the following:
sudo port uninstall ruby19
To start using the new version of ruby you need to find where it is installed (it's something like /opt/local/<...>)
Then go to the Binary folder and add it to path.
export PATH=/opt/local/<...>:$PATH
Removing the old one, you might need to change some env variables as well.
Use RVM
EDIT: added sudo to port command and changed standard location

Resources