/ Published in: Bash
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
sudo aptitude update
sudo aptitude install build-essential mysql-server mysql-client libmysqlclient15-dev libsqlite3-dev libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
mkdir /tmp/sources && cd /tmp/sources
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
cd ruby-1.9.2-rc2 && ./configure --prefix=/opt/ruby-1.9.2-rc2 --enable-pthread --enable-shared
make
sudo make install
nano ~/.profile
# at the end paste
export PATH=/opt/ruby/bin:$PATH
alias sudo="sudo env PATH=$PATH"
source ~/.profile
sudo nano /usr/local/bin/select_ruby
# ** begin select_ruby contents **
#!/bin/sh
while : # Loop forever
do
cat << !
current = $(/opt/ruby/bin/ruby --version)
Select Option
1. ruby-1.9.2-rc2
2. exit
!
echo -n " Your choice? : "
read choice
case $choice in
1) rm -rf /opt/ruby; ln -s /opt/ruby-1.9.2-rc2 /opt/ruby;;
2) exit;;
*) echo "\"$choice\" is not valid "; sleep 2 ;;
esac
exit
done
# ** end select_ruby contents **
sudo chmod +x /usr/local/bin/select_ruby
sudo select_ruby # select option 1
sudo gem update
sudo gem update --system
sudo gem install rails --pre --no-rdoc --no-ri
# MySQL
mkdir /tmp/sources && cd /tmp/sources
wget http://tmtm.org/downloads/mysql/ruby/mysql-ruby-2.8.2.tar.gz
tar -zxvf mysql-ruby-2.8.2.tar.gz && cd mysql-ruby-2.8.2
ruby extconf.rb
make
sudo make install
# SQLite3 (issues compiling sqlite3-ruby-1.3.1)
sudo gem install -v=1.2.5 sqlite3-ruby --no-rdoc --no-ri
# Rails project
mkdir /opt/rails && mkdir /opt/rails/releases && mkdir /opt/rails/releases && cd /opt/rails/releases
sudo rails new app071110
sudo ln -s /opt/evogi/rails/releases/app071110 /opt/evogi/rails/current
cd /opt/evogi/rails/current
# THIN
sudo gem install thin --no-rdoc --no-ri
sudo thin install
sudo /usr/sbin/update-rc.d -f thin defaults
sudo thin config -C /etc/thin/evogi.yml -c /opt/evogi/rails/current/ --servers 3 -e production
# Nginx
cd /tmp/sources
wget http://sysoev.ru/nginx/nginx-0.8.44.tar.gz
tar -zxvf nginx-0.8.44.tar.gz
cd nginx-0.8.44
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --with-http_gzip_static_module
make
sudo make install
sudo nano /etc/init.d/nginx
# ** begin nginx contents **
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
# ** end nginx contents **
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults
sudo mkdir /usr/local/nginx/sites-available && sudo mkdir /usr/local/nginx/sites-enabled
sudo nano /usr/local/nginx/conf/nginx.conf
# ** begin nginx.conf contents **
user evogi7;
worker_processes 6;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log /opt/evogi/rails/current/log/nginx_access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_static on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_http_version 1.1;
gzip_min_length 10;
gzip_comp_level 9; # default is 2
gzip_proxied any;
gzip_vary on;
gzip_types text/plain application/xhtml+xml text/css application/x-javascript text/xml application/xml
application/xml+rss text/javascript;
upstream mongrel {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
server {
listen 80;
server_name www.gateway.evogi.com gateway.evogi.com;
root /opt/evogi/rails/current/public;
#charset koi8-r;
#access_log logs/host.access.log main;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
# needed for HTTPS
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_max_temp_file_size 0;
if (-f $request_filename) {
break;
}
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://mongrel;
break;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /500.html;
location = /500.html {
root /opt/evogi/rails/current/public;
}
}
}
# ** end nginx.conf contents **
sudo nano /usr/local/nginx/sites-available/gateway.evogi.com
# ** end gateway.evogi.com contents **
upstream domain1 {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
server {
listen 80;
server_name gateway.evogi.com;
rewrite ^/(.*) http://gateway.evogi.com permanent;
}
server {
listen 80;
server_name gateway.evogi.com;
#access_log /opt/evogi/rails/current/log/nginx_access.log;
#error_log /opt/evogi/rails/current/log/nginx_error.log;
root /opt/evogi/rails/current/public/;
index index.html;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://domain1;
break;
}
}
}
# ** end gateway.evogi.com contents **
sudo ln -s /usr/local/nginx/sites-available/gateway.evogi.com /usr/local/nginx/sites-enabled/gateway.evogi.com
# Start server
sudo /etc/init.d/thin start
sudo /etc/init.d/nginx start
Comments
 Subscribe to comments
                    Subscribe to comments
                
                