Installing Rails 3.0 beta4 & Ruby 1.9.2 RC2 on a fresh Ubuntu box


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. sudo aptitude update
  2.  
  3. sudo aptitude install build-essential mysql-server mysql-client libmysqlclient15-dev libsqlite3-dev libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
  4.  
  5. mkdir /tmp/sources && cd /tmp/sources
  6.  
  7. wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-rc2.tar.gz && tar -xvzf ruby-1.9.2-rc2.tar.gz
  8.  
  9. cd ruby-1.9.2-rc2 && ./configure --prefix=/opt/ruby-1.9.2-rc2 --enable-pthread --enable-shared
  10.  
  11. make
  12.  
  13. sudo make install
  14.  
  15. nano ~/.profile
  16. # at the end paste
  17. export PATH=/opt/ruby/bin:$PATH
  18. alias sudo="sudo env PATH=$PATH"
  19.  
  20. source ~/.profile
  21.  
  22. sudo nano /usr/local/bin/select_ruby
  23. # ** begin select_ruby contents **
  24. #!/bin/sh
  25.  
  26. while : # Loop forever
  27. do
  28. cat << !
  29.  
  30. current = $(/opt/ruby/bin/ruby --version)
  31.  
  32. Select Option
  33.  
  34. 1. ruby-1.9.2-rc2
  35. 2. exit
  36.  
  37. !
  38.  
  39. echo -n " Your choice? : "
  40. read choice
  41.  
  42. case $choice in
  43. 1) rm -rf /opt/ruby; ln -s /opt/ruby-1.9.2-rc2 /opt/ruby;;
  44. 2) exit;;
  45. *) echo "\"$choice\" is not valid "; sleep 2 ;;
  46. esac
  47. exit
  48. done
  49. # ** end select_ruby contents **
  50.  
  51. sudo chmod +x /usr/local/bin/select_ruby
  52.  
  53. sudo select_ruby # select option 1
  54.  
  55. sudo gem update
  56.  
  57. sudo gem update --system
  58.  
  59. sudo gem install rails --pre --no-rdoc --no-ri
  60.  
  61. # MySQL
  62. mkdir /tmp/sources && cd /tmp/sources
  63.  
  64. wget http://tmtm.org/downloads/mysql/ruby/mysql-ruby-2.8.2.tar.gz
  65.  
  66. tar -zxvf mysql-ruby-2.8.2.tar.gz && cd mysql-ruby-2.8.2
  67.  
  68. ruby extconf.rb
  69.  
  70. make
  71.  
  72. sudo make install
  73.  
  74. # SQLite3 (issues compiling sqlite3-ruby-1.3.1)
  75. sudo gem install -v=1.2.5 sqlite3-ruby --no-rdoc --no-ri
  76.  
  77. # Rails project
  78. mkdir /opt/rails && mkdir /opt/rails/releases && mkdir /opt/rails/releases && cd /opt/rails/releases
  79.  
  80. sudo rails new app071110
  81.  
  82. sudo ln -s /opt/evogi/rails/releases/app071110 /opt/evogi/rails/current
  83.  
  84. cd /opt/evogi/rails/current
  85.  
  86. # THIN
  87. sudo gem install thin --no-rdoc --no-ri
  88.  
  89. sudo thin install
  90.  
  91. sudo /usr/sbin/update-rc.d -f thin defaults
  92.  
  93. sudo thin config -C /etc/thin/evogi.yml -c /opt/evogi/rails/current/ --servers 3 -e production
  94.  
  95. # Nginx
  96. cd /tmp/sources
  97.  
  98. wget http://sysoev.ru/nginx/nginx-0.8.44.tar.gz
  99.  
  100. tar -zxvf nginx-0.8.44.tar.gz
  101.  
  102. cd nginx-0.8.44
  103.  
  104. ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --with-http_gzip_static_module
  105.  
  106. make
  107.  
  108. sudo make install
  109.  
  110. sudo nano /etc/init.d/nginx
  111. # ** begin nginx contents **
  112. #! /bin/sh
  113.  
  114. ### BEGIN INIT INFO
  115. # Provides: nginx
  116. # Required-Start: $all
  117. # Required-Stop: $all
  118. # Default-Start: 2 3 4 5
  119. # Default-Stop: 0 1 6
  120. # Short-Description: starts the nginx web server
  121. # Description: starts nginx using start-stop-daemon
  122. ### END INIT INFO
  123.  
  124. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  125. DAEMON=/usr/local/sbin/nginx
  126. NAME=nginx
  127. DESC=nginx
  128.  
  129. test -x $DAEMON || exit 0
  130.  
  131. # Include nginx defaults if available
  132. if [ -f /etc/default/nginx ] ; then
  133. . /etc/default/nginx
  134. fi
  135.  
  136. set -e
  137.  
  138. case "$1" in
  139. start)
  140. echo -n "Starting $DESC: "
  141. start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
  142. --exec $DAEMON -- $DAEMON_OPTS
  143. echo "$NAME."
  144. ;;
  145. stop)
  146. echo -n "Stopping $DESC: "
  147. start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
  148. --exec $DAEMON
  149. echo "$NAME."
  150. ;;
  151.  
  152. restart|force-reload)
  153. echo -n "Restarting $DESC: "
  154. start-stop-daemon --stop --quiet --pidfile \
  155. /usr/local/nginx/logs/$NAME.pid --exec $DAEMON
  156. sleep 1
  157. start-stop-daemon --start --quiet --pidfile \
  158. /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
  159. echo "$NAME."
  160. ;;
  161. reload)
  162. echo -n "Reloading $DESC configuration: "
  163. start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
  164. --exec $DAEMON
  165. echo "$NAME."
  166. ;;
  167. *)
  168. N=/etc/init.d/$NAME
  169. echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
  170. exit 1
  171. ;;
  172. esac
  173.  
  174. exit 0
  175. # ** end nginx contents **
  176.  
  177. sudo chmod +x /etc/init.d/nginx
  178.  
  179. sudo /usr/sbin/update-rc.d -f nginx defaults
  180.  
  181. sudo mkdir /usr/local/nginx/sites-available && sudo mkdir /usr/local/nginx/sites-enabled
  182.  
  183. sudo nano /usr/local/nginx/conf/nginx.conf
  184. # ** begin nginx.conf contents **
  185. user evogi7;
  186. worker_processes 6;
  187.  
  188. #error_log logs/error.log;
  189. #error_log logs/error.log notice;
  190. #error_log logs/error.log info;
  191.  
  192. pid /var/run/nginx.pid;
  193.  
  194.  
  195. events {
  196. worker_connections 1024;
  197. }
  198.  
  199.  
  200. http {
  201. include mime.types;
  202. default_type application/octet-stream;
  203.  
  204. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  205. '$status $body_bytes_sent "$http_referer" '
  206. '"$http_user_agent" "$http_x_forwarded_for"';
  207.  
  208. #access_log /opt/evogi/rails/current/log/nginx_access.log main;
  209.  
  210. sendfile on;
  211. tcp_nopush on;
  212. tcp_nodelay off;
  213.  
  214. #keepalive_timeout 0;
  215. keepalive_timeout 65;
  216.  
  217. gzip on;
  218. gzip_static on;
  219. gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  220. gzip_http_version 1.1;
  221. gzip_min_length 10;
  222. gzip_comp_level 9; # default is 2
  223. gzip_proxied any;
  224. gzip_vary on;
  225. gzip_types text/plain application/xhtml+xml text/css application/x-javascript text/xml application/xml
  226. application/xml+rss text/javascript;
  227.  
  228. upstream mongrel {
  229. server 127.0.0.1:3000;
  230. server 127.0.0.1:3001;
  231. server 127.0.0.1:3002;
  232. }
  233.  
  234. server {
  235. listen 80;
  236. server_name www.gateway.evogi.com gateway.evogi.com;
  237.  
  238. root /opt/evogi/rails/current/public;
  239.  
  240. #charset koi8-r;
  241.  
  242. #access_log logs/host.access.log main;
  243.  
  244. if (-f $document_root/system/maintenance.html) {
  245. rewrite ^(.*)$ /system/maintenance.html last;
  246. break;
  247. }
  248.  
  249. location / {
  250. proxy_set_header X-Real-IP $remote_addr;
  251.  
  252. # needed for HTTPS
  253. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  254. proxy_set_header Host $http_host;
  255. proxy_redirect off;
  256. proxy_max_temp_file_size 0;
  257.  
  258. if (-f $request_filename) {
  259. break;
  260. }
  261.  
  262. if (-f $request_filename/index.html) {
  263. rewrite (.*) $1/index.html break;
  264. }
  265.  
  266. if (-f $request_filename.html) {
  267. rewrite (.*) $1.html break;
  268. }
  269.  
  270. if (!-f $request_filename) {
  271. proxy_pass http://mongrel;
  272. break;
  273. }
  274. }
  275.  
  276. #error_page 404 /404.html;
  277.  
  278. # redirect server error pages to the static page /50x.html
  279. #
  280. error_page 500 502 503 504 /500.html;
  281. location = /500.html {
  282. root /opt/evogi/rails/current/public;
  283. }
  284. }
  285. }
  286. # ** end nginx.conf contents **
  287.  
  288.  
  289. sudo nano /usr/local/nginx/sites-available/gateway.evogi.com
  290. # ** end gateway.evogi.com contents **
  291. upstream domain1 {
  292. server 127.0.0.1:3000;
  293. server 127.0.0.1:3001;
  294. server 127.0.0.1:3002;
  295. }
  296.  
  297. server {
  298. listen 80;
  299. server_name gateway.evogi.com;
  300. rewrite ^/(.*) http://gateway.evogi.com permanent;
  301. }
  302.  
  303.  
  304. server {
  305. listen 80;
  306. server_name gateway.evogi.com;
  307.  
  308. #access_log /opt/evogi/rails/current/log/nginx_access.log;
  309. #error_log /opt/evogi/rails/current/log/nginx_error.log;
  310.  
  311. root /opt/evogi/rails/current/public/;
  312. index index.html;
  313.  
  314. location / {
  315. proxy_set_header X-Real-IP $remote_addr;
  316. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  317. proxy_set_header Host $http_host;
  318. proxy_redirect false;
  319.  
  320. if (-f $request_filename/index.html) {
  321. rewrite (.*) $1/index.html break;
  322. }
  323.  
  324. if (-f $request_filename.html) {
  325. rewrite (.*) $1.html break;
  326. }
  327.  
  328. if (!-f $request_filename) {
  329. proxy_pass http://domain1;
  330. break;
  331. }
  332. }
  333.  
  334. }
  335. # ** end gateway.evogi.com contents **
  336.  
  337. sudo ln -s /usr/local/nginx/sites-available/gateway.evogi.com /usr/local/nginx/sites-enabled/gateway.evogi.com
  338.  
  339. # Start server
  340. sudo /etc/init.d/thin start
  341.  
  342. sudo /etc/init.d/nginx start
  343.  
  344.  
  345.  
  346.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.