Merb, DataMapper, Upload Progress, Nginx, Rack, Mongrel, Subversion on SilverRack VPS

Posted by Aaron Qian Fri, 27 Jun 2008 15:23:00 GMT

Note: This guide is from my own experience, if it didn’t work for you, or you caught mistakes in this site, please feel free to leave your comments/suggestion/corrections, and I’d be more than happy to update this article.

So You Want A Production Site?

After playing with merb 0.9.4 and datamapper 0.9.3 on my local development enviorment, I was delighted with this killer combo for their innovation, ease of use, clarity, and stability. I’ve made a little project with merb and wanted to test out how hard it would be to setup as production server. This blog is a tutorial on what I did to get it working.

Get your VPS

A few of the projects I worked before are currently using SilverRack slice to host their Rails applications, and from the past experience it was a good pick.

So I went straight to their website and filled out their purchase form. I used the following options:

  • 256MB slice
  • railsconf coupon code. ($5 discount, don’t know if it works with other packages)
  • ubuntu 8.10 hardy

Initial setup

After the purchase, you will get an email with instruction to login to your slice with SSH. You can setup your DNS setting by logging in to SilverRack as well.

Now let’s get your new shinny Ubuntu VPS some basic apps! Logging in to your VPS as root and get this puppy going.

Fix some perl locale complaints Note, if you encounter errors similar to below:

perl: warning: Setting locale failed

The remedy is:

apt-get install --reinstall language-pack-en

Update your apt repository

Update sources.list:

nano /etc/apt/sources.list

Paste the following into sources.list:

deb http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy main restricted

deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates main restricted

deb http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe

deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse

deb http://archive.canonical.com/ubuntu hardy partner
deb-src http://archive.canonical.com/ubuntu hardy partner

Update the package database:

apt-get update

Upgrade to the latest version of all base packages:

apt-get upgrade

Install some basic tools

apt-get install bash man-db cron wget lynx git-core subversion build-essential 

Add a default user

adduser <username>

Give sudo access

Open sudoer config file:

nano /etc/sudoers

Add the following line at the end:

ALL=(ALL) ALL

Disable root login via SSH

Edit the sshd config file:
nano /etc/ssh/sshd_config

Find this line:

PermitRootLogin yes

and change to:

PermitRootLogin no

Restart SSH

/etc/init.d/ssh restart

Install Merb and Datamapper

Setup Ruby, Gems, and Rake

Get ruby:
apt-get install ruby irb ri rdoc rubygems ruby1.8-dev libzlib-ruby libyaml-ruby libreadline-ruby libncurses-ruby libcurses-ruby libruby libruby-extras libfcgi-ruby1.8 build-essential libopenssl-ruby libdbm-ruby libdbi-ruby libdbd-sqlite3-ruby sqlite3 libsqlite3-dev libsqlite3-ruby libxml-ruby libxml2-dev
Update your gem to latest
gem update --system

If you see something like this:

uninitialized constant Gem::GemRunner (NameError)

Then open /usr/bin/gem and Insert the following:

require 'rubygems/gem_runner'

After this line:

require 'rubygems'

Install Merb and Datamapper Dependencies

Type the following into your console:
gem install erubis rake json_pure rspec rack hpricot mime-types addressable english rspec

Now you can go have some coffee while the gems download and compile…

Download the latest gems from GitHub

mkdir ~/gems
cd ~/gems
git clone git://github.com/wycats/merb-core.git
git clone git://github.com/wycats/merb-more.git
git clone git://github.com/wycats/merb-plugins.git
git clone git://github.com/sam/extlib.git
git clone git://github.com/wycats/do.git
git clone git://github.com/sam/dm-core.git
git clone git://github.com/sam/dm-more.git

Compile and install all gems

cd merb-core; sudo rake install; cd..
cd merb-more; sudo rake install; cd..
cd merb-plugins; sudo rake install; cd..
cd extlib; sudo rake install; cd..
cd do; sudo rake install; cd..
cd dm-core; sudo rake install; cd..
cd dm-more; sudo rake install; cd..

Now you should have Merb and DataMapper both installed, to check their existence, you can do the following:

gem list

You should see gems with names start with “merb-” and “dm-”

nginx for Your Front-End

grab a latest stable source from nginx

At the time of writing, I downloaded the latest stable
cd ~
wget http://sysoev.ru/nginx/nginx-0.6.31.tar.gz
h4. Untar it
tar -xvzf nginx-0.6.31.tar.gz
h4. Make a modules directory for upload progress module
cd nginx-0.6.31
mkdir modules

Download the nginx upload progress module

Download the latest source tar.gz file, and untar it. Finally, put it in your “modules” directory

cd modules
wget http://wiki.codemongers.com/NginxHttpUploadProgressModule?action=AttachFile&do=get&target=nginx_uploadprogress_module-0.2.tar.gz
tar -xvzf nginx_uploadprogress_module-0.2.tar.gz
rm nginx_uploadprogress_module-0.2.tar.gz
cd ..

Install dependencies for Nginx

apt-get install libpcre3-dev libgcrypt11-dev libssl-dev

Configure Nginx

./configure --with-openssl=/usr/lib/ssl/ --with-md5=/usr/lib --add-module=modules/nginx_uploadprogress_module

Make and Install

make
make install

Setup Init Script

cd /etc/init.d/
wget http://topfunky.net/svn/shovel/nginx/init.d/nginx
chmod +x nginx

Make Nginx start on boot

update-rc.d -f nginx defaults

Start Nginx

/etc/init.d/nginx start

link Nginx Configuration Files to ect

ln -s /usr/local/nginx/conf /etc/nginx

Setup Your Subversion Repository

Install subversion and tools

apt-get install subversion subversion-tools libsvn-dev libsvn1

Setup a repository

adduser deploy
sudo svnadmin create /var/svn/mycode
chown -R deploy:deploy /var/svn/mycode

Edit svnserve config file

Open the config file:

nano /var/svn/mycode/conf/svnserve.conf

Modify the following lines:

anon-access = none
auth-access = write
authz-db = /usr/local/nginx/conf/svn_access.rules
realm = My Code Repository

Permissions

Create an svnserve access file:

sudo nano /usr/local/nginx/conf/svn_access.rules

Paste in the following and save the file:

[groups]
developers = deploy
qc = deploy
pm = deploy
[/]

@developers = rw
@qc = r
@pm = r

Init Script for snvserve

Create a svnserve startup file:

sudo nano /etc/init.d/svnserve

Paste in the following:

#!/bin/sh
# Use the following variables to customize user, group, and paths.
SVNSERVE=`which svnserve`
SVN_USER=aaron
SVN_GROUP=aaron
SVN_ROOT_PATH=/var/svn/mycode/

if [ -f /etc/rc.d/init.d/functions ]; then
# RedHat style
. /etc/rc.d/init.d/functions
START="daemon $SVNSERVE -d --root $SVN_ROOT_PATH"
STOP="killproc $SVNSERVE"
else
# Ubuntu LSB style
. /lib/lsb/init-functions
START="start-stop-daemon --start --exec $SVNSERVE -- -d --root $SVN_ROOT_PATH"
STOP="start-stop-daemon --stop --exec $SVNSERVE"
fi

if [ ! -x $SVNSERVE ]; then
echo "Could not find ${SVNSERVE}. PATH is ${PATH}"
exit 0
fi

case "$1" in
start)
echo "Starting svnserve..."
umask 002
$START
if [ $? ]; then
echo "Started svnserve"
exit 0
else
exit $?
fi
;;

stop)
echo "Stopping svnserve..."
$STOP
exit $?
;;

restart|force-reload)
"$0" stop && "$0" start
;;

*)
echo "Usage: /etc/init.d/svnserve {start|stop|restart|force-reload}"
exit 1
;;
esac

echo "Unhandled case while trying to start svnserve."
echo "see $0"
exit 3

Make it executable:

sudo chmod +x /etc/init.d/svnserve

Make svnserve start on boot

Add it to the startup scripts:

sudo update-rc.d /etc/init.d/svnserve defaults

Start the server

sudo /etc/init.d/svnserve start

Import your merb app

Create a directories for your app:

svn mkdir -m "make my_app" svn+ssh://domain.tld/var/svn/mycode/my_app
svn mkdir -m "make trunk" svn+ssh://domain.tld/var/svn/mycode/my_app/trunk

Import your app:

cd my_app
svn import -m "initial import of my_app" . svn+ssh://domain.tld/var/svn/mycode/my_app/trunk

Checkout your app:

makedir ~/projects/my_app
cd ~/projects/my_app
svn co svn+ssh://domain.tld/var/svn/mycode/my_app/trunk

Capistrano

To be continued…

Note: This guide is from my own experience, if it didn’t work for you, or you caught mistakes in this site, please feel free to leave your comments/suggestion/corrections, and I’d be more than happy to update this article.

References:

Tags , , , , , , ,  | 5 comments | 6482 trackbacks

Comments

  1. Avatar http://www.silverrack.com said 4 days later:
    Great post!
  2. Avatar Sherry said about 1 month later:
    Yeah,Rails,merbs are really cool languages ^^
  3. Avatar Ardekantur said about 1 month later:
    I'm pretty sure you win the `Most Ruby Buzzwords in a Blog Post Title' Award. Congratulations!
  4. Avatar Aaron said about 1 month later:
    Yes, that was my intention all along, LOL. I was trying to research how SEO gonna work out with this title.
  5. Avatar Michael Johnston said 4 months later:
    How is it a great post? It tells "how" to install some gems, nginx & svnserver and then says "to be continued" and it's 6 months old. Change the title to "how to install some gems and nginx"

Trackbacks

Use the following link to trackback from your own site:
http://aaron.aaron033.com/articles/trackback/4

  1. From Political Signs
    Political Signs
    Need Yard Signs Remember us SIGN DEPOT
  2. From Roulette system tester www.zumma.com.
    Roulette www.zumma.com.
    Roulette system tester www.zumma.com. Roulette game www.zumma.com. Roulette gambling systems. Roulette systems www.zumma.com. Roulette www.zumma.com. How to play roulette.
  3. From Buy xanax without prescription in usa.
    Xanax with herbal medicines.
    Xanax effect.
  4. From Buy xanax.
    No prescription xanax.
    Xanax 2 mg 180 pills. Xanax. Xanax with klonopin. Buy cheap xanax without prescription.
  5. From Lights www.1stlamps.com.
    Home lighting www.1stlamps.com.
    Www forcedfuckers com.
  6. From Cvs pharmacy.
    Cvs pharmacy.
    Pharmacy. Target pharmacy. Sunset pharmacy. Compounding pharmacy. Cvs pharmacy online.
  7. From Xanax.
    Cheap xanax online buy cheap xanax buy cheap xanax.
    Generic xanax no prescription. Xanax. Xanax 180 pills.
  8. From Buy viagra online.
    Voyforums buy viagra online.
    Buy viagra online. Buy low price viagra. Buy viagra no prescription.
  9. From Remont.
    Remont investment and loan.
    Remont investment and loan. Remont.
  10. From Remont investment and loan.
    Remont investment and loan.
    Remont investment and loan. Remont.
  11. From Online casino news ladies game.
    Online casino game that requires no money.
    Search results casino game online. Online casino game. Play free casino game online. Online casino game that requires no money. Online casino news ladies game.
  12. From Remont investment and loan.
    Remont investment and loan.
    Remont investment and loan. Remont.
  13. From Adderall prescription.
    Adderall overnight no prescription.
    Buy adderall without a prescription. Adderall without a prescription. Buy adderall no prescription.
  14. From Viagra for order lamisil viagra.
    Viagra and cialis order online overnight.
    Order viagra. Viagra for order lamisil viagra.
  15. From Generic xanax.
    Buy xanax.
    Order xanax online. Buy xanax online. Xanax. Xanax withdrawal symptom.
  16. From Buy viagra.
    Buy viagra.
    Buy viagra online. Buy online viagra. Buy discount viagra online. Buy viagra. Buy viagra uk.
  17. From Xanax dosage.
    Xanax presciption.
    Xanax. Xanax cocktail.
  18. From Xanax.
    Xanax.
    Xanax xr crushed. Xanax. No prescription needed purchasing xanax. Xanax cocktail.
  19. From Xanax.
    Xanax.
    Xanax. Xanax 2mg.
  20. From Cheap viagra.
    Price comparison for xanax as well as viagra cheap.
    Viagra sale viagra uk cheap generic viagra. Cheap viagra. Generic viagra cheap no perscription. Buy cheap viagra and phentermine. Phorum baff parents discussion cheap viagra.
  21. From Buy viagra online.
    Buy viagra online.
    Viagra online. Viagra buy viagra online. Viagra online cheap. Online viagra sample. Purchase viagra online. Viagra sales online.
  22. From Buy cheap viagra online uk.
    Buy cheap viagra and phentermine.
    Buy cheap viagra online uk. Buy cheap viagra and phentermine. Buy cheap viagra. Viagra cialis levitra buy cheap cialis buy ciali.
  23. From Xanax.
    Xanax online.
    Xanax. Xanax with 5-htp.
  24. From Order viagra.
    Viagra uk buy viagra online order viagra.
    Order viagra canada. Order viagra. Viagra for order lamisil viagra.
  25. From Order viagra online.
    Viagra for order lamisil viagra.
    Order viagra. Viagra pharmacy order status. Viagra for order lamisil viagra.
  26. From Xanax 50mg.
    Xanax 50mg.
    Xanax 50mg.
  27. From Viagra and cialis order online overnight.
    Viagra for order lamisil viagra.
    Order viagra canada. Order viagra online.
  28. From Xanax.
    Xanax.
    Side effects of drug xanax. Buy xanax. Xanax. Xanax 2mg. No prescription xanax generic.
  29. From Beer and xanax.
    Xanax.
    Buy xanax.
  30. From Roulette online www.zumma.com.
    Free roulette.
    Roulette systems www.zumma.com. Roulette strategies.
  31. From Anal sex full video.
    Anal sex full video.
    Anal sex full video.
  32. From Buy cymbalta.
    Buy cymbalta.
    Buy cymbalta.
  33. From Buy sublingual levitra online.
    Buy viagra online uk cialis levitra.
    Buy levitra paypal.
  34. From Tramadol.
    Cheapest tramadol.
    Buy tramadol. Tramadol for dogs side effects. Drug encyclopedia cor 127 tramadol. Medlineplus drug information tramadol and. Tramadol.
  35. From everest pokerjhxa
    telecharger titan poker
    telecharger titan poker
  36. From JabberTags - Find New Sites and Explore the Internet
    Recent Links Tagged With Merb
    Bookmarked your site as merb at JabberTags!
  37. From gay kauai
    gay kauai
    gay kauai
  38. From Buy vicodin without script.
    What is vicodin.
    Vicodin. No prescription needed vicodin.
  39. From Tramadol.
    Tramadol.
    Tramadol soma zoloft prozac onlineprescription.md. Tramadol dog. Tramadol hcl. Tramadol. Snorting tramadol. Tramadol com.
  40. From Buy ultram from discount store.
    Ultram vs. tramadol.
    Ingredients in ultram.
  41. From gay oral sex
    gay rimming
    gay glory holes
  42. From gay boy porn
    gay gangbang
    gay oral sex
  43. From telecharger everest pokervwcj
    telecharger everest poker
    telecharger everest poker
  44. From titan pokerwwic
    titan poker
    titan poker
  45. From telecharger everest pokerhliq
    telecharger everest poker
    telecharger everest poker
  46. From everest pokertpli
    everest poker
    everest poker
  47. From titan pokerrtqx
    titan poker
    titan poker
  48. From telecharger everest pokerocku
    telecharger everest poker
    telecharger everest poker
  49. From titan pokerjgdq
    titan poker
    titan poker
  50. From telecharger everest pokerzfnx
    telecharger everest poker
    telecharger everest poker
  51. From everest pokerpdai
    everest poker
    everest poker
  52. From telecharger everest pokermnqs
    telecharger everest poker
    telecharger everest poker
  53. From everest pokergnzz
    everest poker
    everest poker
  54. From titan pokeriikq
    titan poker
    titan poker
  55. From everest pokersymb
    everest poker
    everest poker
  56. From titan pokerwvgs
    titan poker
    titan poker
  57. From telecharger everest pokernole
    telecharger everest poker
    telecharger everest poker
  58. From everest pokeroojz
    everest poker
    everest poker
  59. From telecharger everest pokerrisa
    telecharger everest poker
    telecharger everest poker
  60. From everest pokercprj
    everest poker
    everest poker
  61. From titan pokerxbtp
    titan poker
    titan poker
  62. From telecharger everest pokerjfhm
    telecharger everest poker
    telecharger everest poker
  63. From everest pokermfgt
    everest poker
    everest poker
  64. From everest pokeremgt
    everest poker
    everest poker
  65. From titan pokerumxi
    titan poker
    titan poker
  66. From everest pokerlxxq
    everest poker
    everest poker
  67. From telecharger everest pokermrmg
    telecharger everest poker
    telecharger everest poker
  68. From everest pokerhrkm
    everest poker
    everest poker
  69. From telecharger everest pokerbopo
    telecharger everest poker
    telecharger everest poker
  70. From everest pokermwpz
    everest poker
    everest poker
  71. From titan pokereouy
    titan poker
    titan poker
  72. From everest pokerxpte
    everest poker
    everest poker
  73. From Urlrecorder - URL sharing
    Merb Urls
    Your url was recorded with keywords merb!
  74. From Xxx rape.
    Rape.
    Boy rape. Rape. Rape fantasy. Japanese av faq rape.
  75. From Rape sex.
    Rape porno.
    Incest taboo rape photo.
  76. From Britney spears sex tape video.
    Free britney spears sex tape.
    Britney spears sex tape. Britney spears sex tape pornotube. Sex tape britney spears.
  77. From Rape porn.
    Free rape movies.
    Rape. Fantasy rape.
  78. From Incest.
    Incest.
    Incest.
  79. From Britney spears sex tape.
    Britney spears sex tape.
    Britney spears sex tape.
  80. From Asian rape.
    Gang rape.
    Schoolgirl rape. Incest taboo rape photo. Incest rape. Lesbian rape. Free rape pictures. Rape. Rape sex stories.
  81. From Free dog sex movies.
    Free dog sex videos.
    Dog sex stories. Dog sex. Women sex with dog info. How to have sex with a dog.
  82. From download europoker ffac
    download europoker
    download europoker
  83. From code bonus pokerstars boxv
    code bonus pokerstars
    code bonus pokerstars
  84. From telecharger europa casino qxkz
    telecharger europa casino
    telecharger europa casino
  85. From telecharger fulltilt poker maus
    telecharger fulltilt poker
    telecharger fulltilt poker
  86. From evrest poker hnqk
    evrest poker
    evrest poker
  87. From titan pocker uiho
    titan pocker
    titan pocker
  88. From betclick swki
    betclick
    betclick
  89. From code europoker inrn
    code europoker
    code europoker
  90. From pokerstars poker nzwa
    pokerstars poker
    pokerstars poker
  91. From telecharger europa casino yjzg
    telecharger casino tropez
    telecharger casino tropez
  92. From Incest taboo rape photo.
    Rape victims.
    Cartoon rape. Rape tgp. Lesbian rape. Free rape videos. Rape movies.
  93. From paris sportifs udkp
    paris sportifs
    paris sportifs
  94. From code europoker kczl
    code europoker
    code europoker
  95. From poker stras slwu
    poker stras
    poker stras
  96. From fulltiltpoker htfq
    fulltiltpoker
    fulltiltpoker
  97. From everestpoker bacu
    everestpoker
    everestpoker
  98. From titan poker ucpa
    titan poker
    titan poker
  99. From betclic qhzk
    betclic
    betclic
  100. From europoker ffun
    europoker
    europoker
  101. From bonus europoker pjmp
    bonus europoker
    bonus europoker
  102. From pocker stars slwu
    pocker stars
    pocker stars
  103. From titan poker bonus code fppy
    titan poker bonus code
    titan poker bonus code
  104. From europoker tmhg
    europoker
    europoker
  105. From pokerstars mpph
    pokerstars
    pokerstars
  106. From code pokerstars fkmm
    code pokerstars
    code pokerstars
  107. From download fulltilt lsgw
    download fulltilt
    download fulltilt
  108. From evereste poker oxhf
    evereste poker
    evereste poker
  109. From telecharger titan poker zxle
    telecharger titan poker
    telecharger titan poker
  110. From betclic casino lsgw
    betclic casino
    betclic casino
  111. From euro poker nkvj
    euro poker
    euro poker
  112. From telecharger pokerstars zubd
    telecharger pokerstars
    telecharger pokerstars
  113. From code bonus titan poker necx
    code bonus titan poker
    code bonus titan poker
  114. From betclic casino fytl
    betclic casino
    betclic casino
  115. From telecharger euro poker xunr
    telecharger euro poker
    telecharger euro poker
  116. From download pokerstars ppmy
    download pokerstars
    download pokerstars
  117. From codebonus poker770 xlua
    codebonus poker770
    codebonus poker770
  118. From fulltilt poker sneb
    fulltilt poker
    fulltilt poker
  119. From evereset poker fgax
    evereset poker
    evereset poker
  120. From telecharger betclic djpl
    telecharger betclic
    telecharger betclic
  121. From download titan poker dcpj
    download titan poker
    download titan poker
  122. From telecharger europoker wwpl
    telecharger europoker
    telecharger europoker