FAQ

Page Discussion Edit History

ChsRubyonRailsMongrel

浣跨敤Nginx+mongrel閮ㄧ讲Rails搴旂敤

瀹夎nginx

涓嬭浇鍦板潃 http://nginx.org/en/download.html

鎴戜笅杞界殑鐗堟湰鏄 nginx-0.8.40.tar.gz

瑙e帇瀹夎

tar -zxvf nginx-0.8.40.tar.gz
cd nginx-0.8.40/
.configure
make
sudo make install

榛樿鎯呭喌涓嬪畨瑁呯洰褰曟槸 /usr/local/nginx

瀹夎mongrel鍜宮ongrel_cluster

sudo gem install mongrel mongrel_cluster

鐢变簬鐢╣em瀹夎鍚巑ongrel_rails鍛戒护琚斁鍦 /var/lib/gems/1.8/bin/mongrel_rails锛屼娇鐢ㄤ笉鏂逛究锛屾墍浠ュ缓璁缓绔嬬鍙烽摼鎺

sudo ln -s /var/lib/gems/1.8/bin/mongrel_rails /usr/bin/mongrel_rails

閮ㄧ讲Rails搴旂敤

鎴戠殑搴旂敤绀轰緥鏄痳edmine锛屼竴涓敤Rails鍋氱殑椤圭洰绠$悊宸ュ叿銆俽edmine瀹夎璺緞鏄 /opt/redmine

閰嶇疆nginx锛屾坊鍔犱竴涓猻erver鍧楋紝鐢ㄤ簬鏈嶅姟redmine

缂栬緫 vi /usr/local/nginx/conf/nginx.conf锛屼互涓嬫槸娣诲姞鐨勫唴瀹

upstream mongrel {
  server 127.0.0.1:8000;
  server 127.0.0.1:8001;
}

# rails server
server {
  listen 80;
  server_name redmine.moon.ossxp.com;
  root /opt/redmine/public; #娉ㄦ剰杩欓噷涓瀹氳鎸囧悜Rails搴旂敤鐨刾ublic鐩綍
  index index.html index.htm;

  location / {
    proxy_pass http://mongrel;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

閰嶇疆mongrel_cluster

鍦≧ails椤圭洰鐨勬牴鐩綍涓嬫墽琛屼互涓嬪懡浠わ紝鐢熸垚config/mongrel_cluster.yml 鏂囦欢锛屼緵鍚敤mongrel闆嗙兢浣跨敤

sudo mongrel_rails cluster::configure -e production -p 8000 -a 127.0.0.1 -N 2

鏈夊叧cluster::configure 鏇村鍙傛暟浣跨敤鍙熷姪甯姪鍛戒护鏌ョ湅

mongrel_rails cluster::configure -h

鐢熸垚鐨勬枃浠跺唴瀹瑰涓嬶細

---
address: 127.0.0.1
log_file: log/mongrel.log
port: "8000"
environment: production
pid_file: tmp/pids/mongrel.pid
servers: 2

鍚敤mongrel_cluster

wangsheng@pc01:/opt/redmine$ sudo mongrel_rails cluster::start
starting port 8000
starting port 8001

鍚敤nginx

sudo /usr/local/nginx/sbin/nginx

娴嬭瘯鏄惁閮ㄧ讲鎴愬姛

鍦ㄦ祻瑙堝櫒杈撳叆server_name锛岋紙鎴戣繖閲岀敤鐨勬槸redmine.moon.ossxp.com锛夛紝鎸夊洖杞﹂敭锛屽鏋滄樉绀簉edmine涓婚〉锛屽垯璇佹槑閮ㄧ讲鎴愬姛銆