標籤:tfs linux nginx
1.安裝yajl
yajl是一個開源的JSON庫
請到這裡下載: http://lloyd.github.io/yajl/(官網)
:http://download.csdn.net/detail/wei_xiaox126/8304485
解壓檔案
unzip yajl-master.zip
./configure
make && make install
提示沒有安裝cmake, apt-get install cmake
提示有一些test的錯誤,可以直接忽略
2.安裝nginx/tengine
1)安裝pcre
:http://download.csdn.net/detail/wei_xiaox126/8304511
tar xvf pcre-8.35.tar.gz
cd pcre-8.35
./configure --prefix=/usr/local/pcre
make
make install
2)安裝nginx
官網下載nginx-1.3.0以下的版本。(官網連結可直接百度),以下連結本人下載,已測試可用
本地串連:http://download.csdn.net/detail/wei_xiaox126/8304537
3)
下載nginx-tfs模組:https://github.com/alibaba/nginx-tfs (官網連結)
本地連結:http://download.csdn.net/detail/wei_xiaox126/8304561
unzip nginx-tfs-master.zip
tar xvf nginx-1.2.9.tar.gz
cd nginx-1.2.9
./configure --prefix=/usr/local/nginx --add-module=/‘you tfs path‘/
make
make install
c)配置nginx
具體配置細節參看這裡:https://github.com/alibaba/nginx-tfs/blob/master/ReadMe.markdown
vim /usr/local/tengine/conf/nginx.conf
添加以下內容:(設定檔一定要對)
http {
tfs_upstream tfs_ns {
server 10.0.0.62:8108;
type ns;
#rcs_zone name=tfs1 size=128M;
#rcs_interface eth0;
#rcs_heartbeat lock_file=/logs/lk.file interval=10s;
}
tfs_body_buffer_size 2m;
tfs_send_timeout 3s;
tfs_connect_timeout 3s;
tfs_read_timeout 3s;
server {
listen 80;
server_name xxx.xxx.xxx.xxx;
client_max_body_size 4096m;
tfs_keepalive max_cached=50 bucket_count=10;
#tfs_log可以無
tfs_log "pipe:/usr/sbin/cronolog -p 30min /usr/local/tengine/logs/cronolog/%Y/%m/%Y-%m-%d-%H-%M-tfs_access.log";
location / {
tfs_pass tfs://tfs_ns;
}
}
3.啟動nginx
e) API介面測試
用tfs-tools 上傳一個檔案,獲得檔案名稱
開啟瀏覽器瀏覽:
xxx.xxx.xxx.xxx:80/v1/tfs/‘filename‘
成功!
註:歡迎大家提出建議,支出錯誤
歡迎轉載,註明出處,謝謝!
TFS - nginx-tfs模組