ruby 环境
worker_processes 2
working_directory "/opt/myrpm/htdocs/web" # available in 0.94.0+
listen "/opt/myrpm/var/unicorn.sock", :backlog => 64
#listen 8080, :tcp_nopush => false
listen "127.0.0.1:8080",:tcp_nopush => false
timeout 600
pid "/tmp/unicorn.pid"
stderr_path "/logs/unicorn/err.log"
stdout_path "/logs/unicorn/out.log"
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
check_client_connection false
before_exec do |server|
ENV["BUNDLE_GEMFILE"] = "/opt/myrpm/htdocs/web/Gemfile"
end
before_fork do |server, worker|
old_pid = "/tmp/unicorn.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
puts "Send 'QUIT' signal to unicorn error!"
end
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
user nobody;
worker_processes 2;
error_log /opt/myrpm/logs/nginx/error.log;
pid /opt/myrpm/var/run/nginx.pid;
events {
use epoll;
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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
index index.html;
}
}
}
独立安装需要yum install gcc/gcc-c++/libxml2/libxml2-devel/libxslt/libxslt-devel/zlib/zlib-devel
1 install yaml
tar xzf yaml-0.1.5.tar.gz
cd yaml-0.1.5
./configure --prefix=/opt/myrpm
make && make install
2 install ruby
tar xzf ruby-1.9.3-p545.tar.gz
cd ruby-1.9.3-p545
./configure --prefix=/opt/myrpm --disable-install-doc --with-opt-dir=/opt/myrpm
make && make install
3 install rubygems
tar xzf rubygems-2.4.1.tgz
cd rubygems-2.4.1
/opt/myrpm/bin/ruby setup.rb --prefix=/opt/myrpm
/opt/myrpm/bin/gem source
/opt/myrpm/bin/gem sources --remove https://rubygems.org/
/opt/myrpm/bin/gem sources -a https://ruby.taobao.org/
## /opt/myrpm/bin/gem env
## /opt/myrpm/bin/gem env path (source 保存位置路径)
/opt/myrpm/bin/gem install rails
/opt/myrpm/bin/gem install unicorn