1. Bring up a new instance with default AMI
2. Change SSH connection from .pem file dependent to username/password authentication:
+ SSH to server using .pem file as ec2-user account
+ Create a new account and change the ssh configuration to Password Authentication:
sudo su -
useradd -m deploy
passwd deploy
visudo --> add deploy user as sudoer
vi /etc/ssh/sshd_config --> enable PasswordAuthentication
/etc/init.d/sshd reload --> restart sshd server
3. Re-log in as deploy user
4. Update ruby to 1.9
+ sudo yum install ruby19
+ cd /usr/bin
+ sudo su -
+ for f in /usr/bin/*1.9
do
ln -fs $f ${f%1.9}
done
5. Install passenger and nginx
+ sudo su -
+ gem install passenger
+ passenger-install-nginx-module
6. Deploy application with passenger
Phuc on Rails
I'm a software developer that has been doing professional web application development with Ruby on Rails. These are my postings of various things that I've figured out and learned that I thought might be helpful.
Thursday, September 19, 2013
Tuesday, November 13, 2012
Sunday, November 4, 2012
Set Up RoR development environment for Mac OS X 10.8.2
1. Set up Git
1b. Set up Git merge tool:
+ Install p4merge
+ Create a new text file in /usr/local/bin called p4merge, make it executable, and add following lines:
+ Create a new text file in /usr/local/bin call p4diff, make it executable and add following lines:
+ Open your git configuration file (probably ~/.gitconig) and add these lines:
2. Install Command Line Tools for Xcode (OS X Mountain Lion) if you don't want to install the whole Xcode
3. Install rvm and ruby 1.9.3
4. Enabling Apache - Using 3rd party Preference Panel
4b. Starting built-in Apache server automatically.
5. Install MySQL
6. Install homebrew
7. Install ImageMagick
http://code.google.com/p/git-osx-installer/downloads/detail?name=git-1.8.0-intel-universal-snow-leopard.dmg&can=3&q=&sort=-uploadedAlthough it's named as Snow Leopard, it works with Mountain Lion.
1b. Set up Git merge tool:
+ Install p4merge
+ Create a new text file in /usr/local/bin called p4merge, make it executable, and add following lines:
#!/bin/sh /Applications/p4merge.app/Contents/MacOS/p4merge $*
+ Create a new text file in /usr/local/bin call p4diff, make it executable and add following lines:
#!/bin/sh
[ $# -eq 7 ] && /usr/local/bin/p4merge "$2" "$5"
+ Open your git configuration file (probably ~/.gitconig) and add these lines:
[merge] keepBackup = false; tool = p4merge [mergetool "p4merge"] cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED" keepTemporaries = false trustExitCode = false keepBackup = false [diff] external = p4diff
2. Install Command Line Tools for Xcode (OS X Mountain Lion) if you don't want to install the whole Xcode
https://developer.apple.com/downloads/index.action
3. Install rvm and ruby 1.9.3
curl -L https://get.rvm.io | bash -s stable source /Users/phucquang/.rvm/scripts/rvm rvm install 1.9.3 rvm use 1.9.3 rvm --default 1.9.3
4. Enabling Apache - Using 3rd party Preference Panel
http://amz.clickontyler.com/WebSharing.dmgOR 3rd party application (recommended)
http://clickontyler.com/virtualhostx/
4b. Starting built-in Apache server automatically.
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
5. Install MySQL
Go to http://dev.mysql.com/downloads/mysql/#downloads, and download Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive
6. Install homebrew
ruby < (curl -fsSk https://raw.github.com/mxcl/homebrew/go)
7. Install ImageMagick
brew install imagemagick --use-tiff
Monday, September 10, 2012
Service check using Bash script, sendmail with Google Account, and cron
Bash script
#!/bin/sh SERVICE='jobs:work' if [ `ps ax | grep -v grep | grep $SERVICE | wc -l` = 1 ] then echo "$SERVICE service running, everything is fine" else ( echo "To: alert@abc.com" echo "Subject: $SERVICE is down.Install sendmail using Google Account on EC2" ) | sendmail -t fi
sudo su apt-get update && apt-get install ssmtp vi /etc/ssmtp/ssmtp.conf AuthUser=abc@abc.com AuthPass=abcabc FromLineOverride=YES mailhub=smtp.gmail.com:587 UseSTARTTLS=YESInstall cron job for checking every 5 minutes
*/5 * * * * ~/jobs_check.sh
Tuesday, September 4, 2012
Rails, jQuery, and JSONP
Client side:
Server side:
$.get(url, function(data){ console.log(data); }, "jsonp");
Server side:
render :json=>{:abc=>"abc"}, :callback=>params[:callback] and return
Wednesday, June 6, 2012
Thursday, May 17, 2012
Running rake background processes
nohup rake pricing:convert_spig RAILS_ENV=production &> /dev/null &
Subscribe to:
Posts (Atom)