Posts Tagged → osx
How to Install RVM and Rails 3 on Snow Leopard
This is a continuation of my post on installing Ruby version manager or multiple versions of Ruby for Unix. This time it's about OS X 10.6.1 or the Snow Leopard.
Snow Leopard includes Ruby and Rails by default if you install XCode. The version is 1.8.7 and 2.2.2 for each, respectively. This would not suffice for most developers because we need to start porting to Ruby 1.9 and start experimenting with Rails 3. The goal is to just keep moving forward and use the best version that exists.
Update: Since I am getting a lot of feedback regarding this post. I noticed it's not newbie-friendly. Sorry. Here are the missing steps.
My Apache2 is installed in /usr/local and PHP5 is compiled by source. I do not use what Leopard has by default because it wasn't working well for me.
In case it happens for you and you want to install PHP5 and more modules. See the following guides:
Compiling Apache in 64-bits Mode on Leopard
Starting Apache at boot on Leopard
I also installed Fink
So at the very least, you can skip reading what's written on the links above if your Apache2 installed is OK.
Install WGET (but you can also use curl) or just download via web browser.
tar -xzvf wget-latest.tar.gz cd wget-1.11.4/ ./configure make sudo make install
Install Readline
wget ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz tar -xvzf readline-6.0.tar.gz cd readline-6.0 ./configure make sudo make install
Install Most
wget ftp://space.mit.edu/pub/davis/most/most-5.0.0.tar.gz tar xvzf most-5.0.0.tar.gz cd most-5.0.0 ./configure make sudo make install
RVM installation for OS X.
Please read the guides on the website of Wayne. Click here to go there.
Note: The path "/usr/local" is important. This makes a bit of a difference between installing on Ubuntu/Debian and OS X.
sudo gem install rvm #install rvm rvm-install rvm install 1.8.7 -C --enable-shared,--with-readline-dir=/usr/local rvm install 1.9.1 -C --enable-shared,--with-readline-dir=/usr/local rvm install 1.9.2 -C --enable-shared,--with-readline-dir=/usr/local rvm 1.8.7 --default
Install Prerequisites
Git
Hivelogic tutorials are good. Check out how to install Git on Leopard.
SQLite 3
wget http://www.sqlite.org/sqlite-amalgamation-3.6.22.tar.gz tar xvzf sqlite-amalgamation-3.6.22.tar.gz cd sqlite-3.6.22/ ./configure make sudo make install
MySQL
Download from MYSQL website
Select the version compatible with your Mac.
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
Install Rails 3.0 Pre
rvm use 1.8.7%rails3 gem install rake rack test-spec thor sqlite3-ruby gem install mysql -- --with-mysql-dir=/usr/local/mysql git clone git://github.com/rails/rails.git && cd rails rake package && gem install -f */pkg/*.gem pkg/*.gem cd arel && thor :build && thor :install cd ~
And all this didn't take time for me even while writing this post. I now have a successful install for Rails 3 Pre. Same result with Ubuntu Karmic Koala.
Katherine-Pes-iMac:~ katz$ rails -v Rails 3.0.pre rails new yourawesomeapp -d mysql
I suggest replacing the .gitignore file immediately with the .gitignore you've been using or add those necessary entries.
An example of a complete .gitignore file is here.
But often this is just what you need:
*~ .#* .DS_Store backups/* #[I keep some files relevant to the application like the database dump on the same folder] log/* #[we don't need the the log files submitted
Keep adding in other entries later.
Update:
Install Rails 3 Beta
gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n gem install rails --pre
Some guides out there are wrong. Do not use "sudo" when you are using RVM. Your gems are on your user's home directory.
If things are not working and you have followed installation guides. You're missing an important part which is called the .bash_profile. Please review your .bash_profile first. I can't explain every line but every line is important.
This is what I have right now:
Katherine-Pes-iMac:~ katz$ cat .bash_profile
export PATH=/usr/local/bin/:/usr/local/sbin/:/opt/local/bin/:/opt/local/sbin/
:/Users/katz/.rvm/rubies/ruby-1.8.7-p248/bin:
/Users/katz/.rvm/gems/ruby-1.8.7-p248/bin:
/Users/katz/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
export PATH="/usr/local/bin:/usr/local/sbin:
/usr/local/mysql/bin:$PATH"
export APACHE2="/usr/local/apache2/bin"
export PATH="${APACHE2}:${PATH}"
export EDITOR='mate -w'
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PAGER=most
if [[ -s /Users/katz/.rvm/scripts/rvm ]] ; then source /Users/katz/.rvm/scripts/rvm ; fi
alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"
. /sw/bin/init.sh
function gemdir {
if [[ -z "$1" ]] ; then
echo "gemdir expects a parameter, which should be a valid rvm Ruby selector"
else
rvm "$1"
cd `rvm gemdir`
pwd
fi
}
As you can see, there's RVM code. If you follow RVM installation properly you should have something like that. Aliases are shortcuts for starting/stopping MYSQL but mine is automatically loaded on startup.
Have fun :)
This post by Katz Pe is from BridgeUtopia.
Installing Nginx with Passenger on Snow Leopard Using MacPorts
Install MacPorts if you don’t have it.
Download and install the Portfile
git clone git://github.com:crigor/admoolabs-ports.git ports cd ports/nginx-0.7.64-passenger-2.2.8 sudo port -v install
You need to have ruby installed to compile passenger. In case you don’t have ruby, you can also get it from macports.
sudo port -v install ruby
If you have an older version of nginx installed using macports, it might move nginx.conf to nginx.conf.altered. Copy it back to nginx.conf if you need it. You can also use this nginx.conf.
Edit /opt/local/etc/nginx.conf and add the following lines inside http {}
passenger_root /opt/local/lib/passenger; passenger_ruby /opt/local/bin/ruby;
Change the ruby path if you’re not using ruby from macports.
For each rails app, you need to add the following, also inside http {}
server {
server_name labs.local;
root /Users/crigor/admoolabs/labs/public;
access_log /opt/local/var/log/nginx/labs.local.access.log;
error_log /opt/local/var/log/nginx/labs.local.error.log;
passenger_enabled on;
rails_env development;
}
Check if your syntax is correct.
sudo /opt/local/sbin/nginx -t
If it is, you’ll see
the configuration file /opt/local/etc/nginx/nginx.conf syntax is ok configuration file /opt/local/etc/nginx/nginx.conf test is successful
Start nginx with
sudo /opt/local/sbin/nginx
You won’t get any output if it starts correctly. Check if nginx is running
ps -e | grep nginx -i (You should see something like these lines) nginx: master process /opt/local/sbin/nginx nginx: worker process PassengerNginxHelperServer /opt/local/lib/passenger /opt/local/bin/ruby 3 4 0 6 0 300 1 nobody 4294967294 4294967294 /tmp/passenger.10755
MacPorts added a startup item which is disabled by default. To start it,
sudo launchctl load -w /Library/LaunchDaemons/org.macports.nginx.plist
You can stop nginx with
sudo launchctl stop org.macports.nginx
but it would just be started right away. If you want it to remain stopped, use
sudo launchctl unload /Library/LaunchDaemons/org.macports.nginx.plist
When you make changes to the config, reload the config with
sudo /opt/local/sbin/nginx -s reload
Check the other nginx options using
/opt/local/sbin/nginx -h
One more thing…
When you add a rails or rack app, you need to specify a different server_name. You need to add it to /etc/hosts
127.0.0.1 localhost labs.local
Don’t you think it would be great if you can handle this automatically? Me too. Stay tuned for more. This shouldn’t be a pane pain.
This post by Christopher Rigor is from crigor.com.
Recent Comments