FastDFS之nginx-module安装-yellowcong
2017-10-21 09:04
507 查看
FastDFS的Nginx模块安装,1、需要解压nginx-module 模块,2、配置模块config文件,3、安装nginx,4、配置nginx ,安装后,可能出现下载不到文件的情况,出现这个问题的原因可能是nginx的
解压后的目录结构
修改后,去掉loacl,而第三个CORE_LIBS配置中,没有修改,是因为做了软链接
配置完成后,可以看到,默认安装到了
修改nobody改为root,不然老会出现404错误
修改了监听的端口和设定访问组的策略
在server中增加配置:
访问路径不带group名(storage只有一个group的情况),如/M00/00/00/xxx:
访问路径带group名(storage对应有多个group的情况),如/group1/M00/00/00/xxx:
2)mod_fastdfs.conf
将fastdfs-nginx-module_v1.15解压目录fastdfs-nginx-module/src下的mod_fastdfs.conf复制到-DFDFS_MOD_CONF_FILENAME配置的目录下,如/etc/fdfs/。
修改配置:
tracker_server=192.168.1.241:22122 – tracker server的ip和端口,此处可以写多个tracker server,每行一个
url_have_group_name = true –访问路径带group时为true否则为false,多个group的情况下,必须为true,为false时,group_count必须为0
/usr/local/nginx/conf/nginx.conf和
/etc/fdfs/mod_fastdfs.conf配置有问题
1、nginx-module模块安装
1.1解压nginx-module
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
解压后的目录结构
1.2修改配置文件
默认配置文件中,CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"的目录和实际的对不上,需要修改成本机的配置,这个模块需要配置好了,nginx才可以正常编译
修改后,去掉loacl,而第三个CORE_LIBS配置中,没有修改,是因为做了软链接
#修改config文件 vim /usr/local/fsdfs/fastdfs-nginx-module/src/config #去掉local CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/
1.3拷贝模块配置文件
拷贝nginx模块的配置文件到/etc/fdfs/ 目录中,这个配置文件需要手动拷贝到fdfs目录中,cp /usr/local/fsdfs/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ #编辑配置 vim /etc/fdfs/mod_fastdfs.conf #连接时间修改, connect_timeout=10 #配置跟踪器,如果是集群,就拷贝多行 tracker_server=192.168.66.110:22122 storage_server_port=23000 #组名称 group_name=group1 #修改为true url_have_group_name = true #存储地址 store_path0=/fastdfs/storage
1.4拷贝FastFDS安装包目录的配置
拷贝了http.conf,/mime.types两个配置文件到/etc/fdfs目录,然后建立一个软连接,建立软连接的目的,是为了Nginx能通过url的方式下载文件#将安装包目录下的http.cfg 和 mime.types文件拷贝到 /etc/fdfs目录 cp /usr/local/fsdfs/FastDFS/conf/http.conf /etc/fdfs/ cp /usr/local/fsdfs/FastDFS/conf/mime.types /etc/fdfs/ #建立软链接,这样nginx就饿可以访问到我们的模块了 ln -s /fastdfs/storage/data/ /fastdfs/storage/data/M00
2、Nginx安装
2.1安装依赖
yum -y install gcc gcc-c++ autoconf automake make yum -y install zlib zlib-devel openssl openssl--devel pcre*
2.2获取安装包
#获取1.6.2版本的安装包 wget http://nginx.org/download/nginx-1.6.2.tar.gz #解压 tar -zxvf nginx-1.6.2.tar.gz #添加nginx模块 ./configure --add-module=/usr/local/fsdfs/fastdfs-nginx-module/src/ #编译并安装 make && make install
配置完成后,可以看到,默认安装到了
/usr/local/nginx目录
3、配置nginx
3.1配置
#配置nginx vim /usr/local/nginx/conf/nginx.conf #修改用户 #user root; #修改监听端口,和tracker 配置文件的http.server_port 一致 listen 8888; location ~ /group([0-9])/M00 { #设置模块 ngx_fastdfs_module; }
修改nobody改为root,不然老会出现404错误
修改了监听的端口和设定访问组的策略
3.2参数说明
1)nginx.conf在server中增加配置:
访问路径不带group名(storage只有一个group的情况),如/M00/00/00/xxx:
location /M00 { ngx_fastdfs_module; }
访问路径带group名(storage对应有多个group的情况),如/group1/M00/00/00/xxx:
location ~ /group([0-9])/M00 { ngx_fastdfs_module; }
2)mod_fastdfs.conf
将fastdfs-nginx-module_v1.15解压目录fastdfs-nginx-module/src下的mod_fastdfs.conf复制到-DFDFS_MOD_CONF_FILENAME配置的目录下,如/etc/fdfs/。
修改配置:
tracker_server=192.168.1.241:22122 – tracker server的ip和端口,此处可以写多个tracker server,每行一个
url_have_group_name = true –访问路径带group时为true否则为false,多个group的情况下,必须为true,为false时,group_count必须为0
4、启动nginx
#启动成功后,会返回ngx_http_fastdfs_set pid=xx ,表示成功了 /usr/local/nginx/sbin/nginx #重启 /usr/local/nginx/sbin/nginx -s reload
5、测试配置
#上传一个文件,会返回 一个id fdfs_upload_file /etc/fdfs/client.conf /usr/local/fsdfs/ngx_cache_purge-2.3.tar.gz http://192.168.66.110:8888/group1/M00/00/00/wKhCblnqqNeARUz-AAAv2C5hQU8.tar.gz[/code]
返回界面 ,说明有地方配置错了,我看了一下,是我的/etc/fdfs/mod_fastdfs.conf配置中,url_have_group_name 这个参数配置错了,应该设定 为true,不然url不对
配置成功结果
相关文章推荐
- 7. ubuntu 16.04 LTS 安装模块儿fastdfs-nginx-module
- FastDFS(1):Centos7 安装FastDFS+nginx module
- 编译安装 Nginx(添加 fastdfs-nginx-module 模块)异常
- fastdfs-nginx-module安装
- cool-2018-02-08-FastDFS图片服务器,安装nginx+fastdfs-nginx-module
- centos 系统下安装FastDFS+nginx+fastdfs-nginx-module安装配置
- fastdfs-安装fastdfs-nginx-module和配置使用(二)
- CentOS6环境单服务器FastDFS+Nginx+fastdfs-nginx-module 安装配置
- linux上安装fastdfs+nginx+ngin-module实践并解决多个异常篇
- CentOS6环境单服务器FastDFS+Nginx+fastdfs-nginx-module 安装配置
- Nginx编译安装第三方模块http_substitutions_filter_module
- FastDFS安装配置(整合fastDFs和nginx)
- nginx安装报错:configure: error: the HTTP rewrite module requires the PCRE library
- Centos安装FastDFS+Nginx(一天时间搞定)
- Mac OS安装nginx with nginx-stick-module-ng
- Fastdfs安装_nginx进行图片动态压缩
- FastDFS安装和配置整合Nginx-1.13.3的方法
- FastDFS+nginx---(二)安装配置测试
- nginx 编译安装支持 upload progress module, upload module
- nginx上传模块nginx_upload_module原理、安装及使用教程