Ubuntu 에 ROR 환경 및 passenger + nginx 설정 설치

다음 설정 을 편리 하 게 하기 위해 서 - 기록 하 세 요.
\ # 자원 업데이트
1. $ sudo apt-get update

\ # 설치 에 필요 한 환경
2. $ sudo apt-get install -y wget vim build-essential openssl libreadline6 libreadline6-dev libmysqlclient-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev libcurl4-openssl-dev autoconf automake libtool imagemagick libmagickwand-dev libpcre3-dev nodejs libpq-dev

\ # rvm 설치
3. $ sudo su -
   $ \curl -L https://get.rvm.io | bash -s stable

\ # 환경 변수 쓰기
4. $ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
   $ source ~/.bashrc
   $ rvm -v #  rvm  (                       )

\ # 국내 서버 라면 RVM 의 설치 원 을 Taobao 의 미 러 서버 로 교체 하 는 것 을 추천 합 니 다. 이렇게 설치 하면 더욱 빠 를 수 있 습 니 다!
5. $ sed -i -e 's/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g' /usr/local/rvm/config/db

\ # RVM 으로 Ruby 설치
6. $ rvm pkg install readline openssl  (      ,          )

\ # 루비 설치
7. $ rvm install 2.0.0 (     2.0.0    )

\ # 기본 루비 버 전 지정
8. $ rvm use 2.0.0 --default

\ # ruby 버 전 보기
9. $ ruby -v

\ # 미 러 교체
10. $ gem sources --remove https://rubygems.org/
    $ gem sources -a http://ruby.taobao.org/
    $ gem sources -l

결과 보기:
*** CURRENT SOURCES ***
http://ruby.taobao.org
\ # 레일 설치
11. $ gem install rails (        4.0        gem install rails -v 3.2.13)

\ # 승객 설치
12. $ gem install passenger
      $ passenger -v (    )

\ # nginx 설치
Passenger 는 Nginx 를 다시 컴 파일 해 야 하기 때문에 Nginx 가 설치 되 어 있 으 면 마 운 트 해제 해 야 합 니 다!
nginx - v, 있 으 면 $sudo apt - get remove nginx - common nginx - full nginx
13. $ sudo passenger-install-nginx-module

마지막 으로 볼 수 있 습 니 다: Nginx with Passenger support was successfully installed.
\ # nginx 자체 페이지 삭제
14. $ sudo rm -rf /opt/nginx/html/index.html

\ # Nginx 와 사이트 설정
15. $ sudo vim /opt/nginx/conf/nginx.conf

\ # 내 가 설정 한 demo
user shengshihui; #           ,       /home/shengshihui/www       
#user  nobody;
worker_processes  4;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    passenger_root /usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.20;
    passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p195/ruby;
    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;
    client_max_body_size 500m;
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    #gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";
    server {
        listen       80;
        server_name  localhost;
        root /home/shengshihui/www/ror/dotshouji_server/public;
        passenger_enabled on;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

\ # 다음은 Nginx 의 시작 스 크 립 트 를 설치 하고 자동 시작 설정 이 필요 합 니 다.
$ cd ~/
$ git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
$ sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
$ sudo chmod +x /etc/init.d/nginx

\ # Nginx 자동 시작 설정
$ sudo update-rc.d nginx defaults

좋은 웹페이지 즐겨찾기