iT邦幫忙

4

在CentOS 5 上面跑 Node.js

本篇將實做在centos安裝node.js並使用nginx 作為 Web Server。
安裝之前,請先將 Dependencies 的 package 安裝起來,我們使用 yum 進行安裝,請執行下列指令:

yum install nginx unzip gcc-c++  git-core

nginx
這是因為我們要使用 nginx 作為 Web Server,所以將它安裝起來。
git-core
Git是一個由林納斯·托瓦茲為了更好地管理linux核心開發而創立的分布式版本控制/軟體配置管理軟體。

使用 Git 取得 NodeJS

git clone git://github.com/joyent/node.git
cd node
git checkout v0.6.15

進行安裝

/configure
make
make install

接下來我們將 Web Server進行設定:
先對virtual host 的組態檔進行編輯

vi /etc/nginx/conf.d/virtual.conf

加入以下內容:

upstream app_cluster_1 {
        server 127.0.0.1:8000;
}
 
server {
        listen 0.0.0.0:80;
        server_name nodetest.local nodetest;
        access_log /var/log/nginx/nodetest.log;
 
        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_set_header X-NginX-Proxy true;
 
          proxy_pass http://app_cluster_1/;
          proxy_redirect off;
        }
}

將Web Server reload

service nginx reload

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言