背景:装好TFS,java client也调用成功了,现在需要访问tfs中的文件;访问有几种方式:一种是java client调用,把tfs文件Fetch到本地;还有一种就是通过nginx的tfs模块以rest方式访问tfs中的文件,比如html文件。我们项目中刚好是在tfs存储海量html小文件,而且是以iframe src="xxx.html"的方式,所以就用到了这后一种方式。
1下载nginx-tfs
我是用git clone了源码
2 安装yajl库
我是下载了yajl2.1.0
./configure
make
make install
比较顺利
3 安装nginx或Tengine,
我下载nginx1.6时configure报错,最后放弃了nginx,下载了Tengine2.0.1.反正编译安装方法差不多。
但是configure时报缺少pcre和openssl库,所以还得分别下载
最后是./configure --add-module=/root/git/nginx-tfs --with-pcre=/opt/pcre-8.35 --with-openssl=/opt/openssl-1.0.1g
还有个奇怪之处是我分别预先安装好pcre和openssl,再单独configure不行;非得--with参数加在configure后面......
4 配置nginx.conf
5启动Tengine
/usr/local/nginx/sbin/nginx
6 启动TFS
./scripts/tfs start_ns
./scripts/tfs start_ds 1
7最后,打开浏览器输入url验证
一次成功,呵呵
[img]http://dl.iteye.com/upload/picture/pic/130329/2bb081bf-5239-34a9-89ac-a66f72c248ed.jpg[/img]
1下载nginx-tfs
我是用git clone了源码
2 安装yajl库
我是下载了yajl2.1.0
./configure
make
make install
比较顺利
3 安装nginx或Tengine,
我下载nginx1.6时configure报错,最后放弃了nginx,下载了Tengine2.0.1.反正编译安装方法差不多。
但是configure时报缺少pcre和openssl库,所以还得分别下载
最后是./configure --add-module=/root/git/nginx-tfs --with-pcre=/opt/pcre-8.35 --with-openssl=/opt/openssl-1.0.1g
还有个奇怪之处是我分别预先安装好pcre和openssl,再单独configure不行;非得--with参数加在configure后面......
4 配置nginx.conf
#user nobody;
worker_processes 1;
#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;
}
# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
# load ngx_http_fastcgi_module.so;
# load ngx_http_rewrite_module.so;
#}
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;
tfs_upstream tfs_ns {
server 10.0.2.15:8100;
type ns;
}
tfs_body_buffer_size 2m;
tfs_send_timeout 3s;
tfs_connect_timeout 3s;
tfs_read_timeout 3s;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root html;
# index index.html index.htm;
#}
client_max_body_size 4096m;
tfs_keepalive max_cached=50 bucket_count=10;
tfs_log "pipe:/usr/sbin/cronolog -p 30min /usr/local/nginx/logs/cronolog/%Y/%m/%Y-%m-%d-%H-%M-tfs_access.log";
location / {
tfs_pass tfs://tfs_ns;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
5启动Tengine
/usr/local/nginx/sbin/nginx
6 启动TFS
./scripts/tfs start_ns
./scripts/tfs start_ds 1
7最后,打开浏览器输入url验证
一次成功,呵呵
[img]http://dl.iteye.com/upload/picture/pic/130329/2bb081bf-5239-34a9-89ac-a66f72c248ed.jpg[/img]