Nginx安装-让文件服务器fastdfs提供有web方式的上传下载功能
2017-10-09 18:29
585 查看
所需文件下载地址:http://download.csdn.net/download/zhangbest2009/10012707
FastDFS安装部分请参考链接:http://blog.csdn.net/home_zhang/article/details/68491301
Nginx安装(让文件服务器提供有web方式的上传下载功能)
1. 安装Nginx的先决条件
[root@fastdfs2 fdfs]#yum -y install openssl openssl-devel
1)安装PCRE #PCRE - Perl Compatible Regular Expressions#
目的:为了使Nginx支持HTTP Rewrite模块
[root@localhost soft]# tar zxvf pcre-8.35.tar.gz
[root@localhost soft]# cd pcre-8.35
[root@localhost pcre-8.35]# ./configure
[root@localhost pcre-8.35]#make
[root@localhost pcre-8.35]# make install
2. 安装Nginx
[root@localhost soft]#tar zxvf fastdfs-nginx-module_v1.15.tar.gz
[root@localhost soft]#tar zxvf nginx-1.5.9.tar.gz
[root@localhost soft]#cd nginx-1.5.9
[root@localhost soft]#yum -y install pcre pcre-devel
[root@localhostsoft]# ./configure \
--with-http_stub_status_module \
--with-http_ssl_module \
--add-module=/opt/soft/fastdfs-nginx-module/src \
--add-module=/opt/soft/nginx_upstream_hash-master
---------------------------------------------注意-------------------------------------------------------------
---编译Nginx提示gzip module requires the zlib library-----,如出现此编译错误,可以使用如下命令,解决这个问题:
[root@localhost soft]#yum install -y zlib-devel
如果出现如下错误,请先安装 pcre 和 pcre-devel
[root@localhost soft]#yum -y install pcre pcre-devel
---------------------------------------------------------------------------------------------------------
[root@localhost soft]#make && make install
[root@localhost soft]#cp /opt/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
3. 编辑mod_fastdfs.conf和nginx.conf文件
1) 编辑mod_fastdfs.conf文件
[root@localhost soft]# vi /etc/fdfs/mod_fastdfs.conf
connect_timeout=20 //默认 2 秒,可以修改为20秒
把40,41行修改如下: tracker_server=192.168.0.22:22122
tracker_server=192.168.0.22:22122
把48行修改如下: group_name=appendix
把54行修改如下: url_have_group_name = true
把63行修改如下: store_path0=/opt/data/fastdfs
2) 编辑nginx.conf文件
[root@localhost soft]# vi /usr/local/nginx/conf/nginx.conf
在48行,server段中添加如下内容:
location /appendix/M00/ {
root www;
ngx_fastdfs_module;
}
3)建立文件目录软链接
[root@localhost nginx-1.5.9]# cd /usr/local/nginx/
[root@localhost nginx]# mkdir -p www/appendix
[root@localhost nginx]#ln -s /opt/data/fastdfs/data/ /usr/local/nginx/www/appendix/M00
4)验证Nginx的语法
[root@localhost data]# /usr/local/nginx/sbin/nginx –t
---------------------------------------------注意-------------------------------------------------------------
错误提示:/opt/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object
解决方法:
[root@localhost lib]# ln -s /usr/local/lib/libpcre.so.1 /lib64
---------------------------------------------注意-------------------------------------------------------------
5)启动Nginx
[root@localhost data]#/usr/local/nginx/sbin/nginx //启动 nginx 进程
4. 验证 nginx 扩展模块是否能正常提供 web 服务
1)上传一个测试文件
[root@localhost data]# /usr/local/bin/fdfs_upload_file /etc/fdfs/client.conf /tmp/test2.txt
appendix/M00/00/00/rBECFFnbOImAf_l5AAAAFdsxlu4202.txt
http页面验证fastdfs技术.
在浏览器中,输入下列网址:
http://192.168.0.22/appendix/M00/00/00/rBECFFnbOImAf_l5AAAAFdsxlu4202.txt
FastDFS安装部分请参考链接:http://blog.csdn.net/home_zhang/article/details/68491301
Nginx安装(让文件服务器提供有web方式的上传下载功能)
1. 安装Nginx的先决条件
[root@fastdfs2 fdfs]#yum -y install openssl openssl-devel
1)安装PCRE #PCRE - Perl Compatible Regular Expressions#
目的:为了使Nginx支持HTTP Rewrite模块
[root@localhost soft]# tar zxvf pcre-8.35.tar.gz
[root@localhost soft]# cd pcre-8.35
[root@localhost pcre-8.35]# ./configure
[root@localhost pcre-8.35]#make
[root@localhost pcre-8.35]# make install
2. 安装Nginx
[root@localhost soft]#tar zxvf fastdfs-nginx-module_v1.15.tar.gz
[root@localhost soft]#tar zxvf nginx-1.5.9.tar.gz
[root@localhost soft]#cd nginx-1.5.9
[root@localhost soft]#yum -y install pcre pcre-devel
[root@localhostsoft]# ./configure \
--with-http_stub_status_module \
--with-http_ssl_module \
--add-module=/opt/soft/fastdfs-nginx-module/src \
--add-module=/opt/soft/nginx_upstream_hash-master
---------------------------------------------注意-------------------------------------------------------------
---编译Nginx提示gzip module requires the zlib library-----,如出现此编译错误,可以使用如下命令,解决这个问题:
[root@localhost soft]#yum install -y zlib-devel
如果出现如下错误,请先安装 pcre 和 pcre-devel
[root@localhost soft]#yum -y install pcre pcre-devel
---------------------------------------------------------------------------------------------------------
[root@localhost soft]#make && make install
[root@localhost soft]#cp /opt/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
3. 编辑mod_fastdfs.conf和nginx.conf文件
1) 编辑mod_fastdfs.conf文件
[root@localhost soft]# vi /etc/fdfs/mod_fastdfs.conf
connect_timeout=20 //默认 2 秒,可以修改为20秒
把40,41行修改如下: tracker_server=192.168.0.22:22122
tracker_server=192.168.0.22:22122
把48行修改如下: group_name=appendix
把54行修改如下: url_have_group_name = true
把63行修改如下: store_path0=/opt/data/fastdfs
2) 编辑nginx.conf文件
[root@localhost soft]# vi /usr/local/nginx/conf/nginx.conf
在48行,server段中添加如下内容:
location /appendix/M00/ {
root www;
ngx_fastdfs_module;
}
3)建立文件目录软链接
[root@localhost nginx-1.5.9]# cd /usr/local/nginx/
[root@localhost nginx]# mkdir -p www/appendix
[root@localhost nginx]#ln -s /opt/data/fastdfs/data/ /usr/local/nginx/www/appendix/M00
4)验证Nginx的语法
[root@localhost data]# /usr/local/nginx/sbin/nginx –t
---------------------------------------------注意-------------------------------------------------------------
错误提示:/opt/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object
解决方法:
[root@localhost lib]# ln -s /usr/local/lib/libpcre.so.1 /lib64
---------------------------------------------注意-------------------------------------------------------------
5)启动Nginx
[root@localhost data]#/usr/local/nginx/sbin/nginx //启动 nginx 进程
4. 验证 nginx 扩展模块是否能正常提供 web 服务
1)上传一个测试文件
[root@localhost data]# /usr/local/bin/fdfs_upload_file /etc/fdfs/client.conf /tmp/test2.txt
appendix/M00/00/00/rBECFFnbOImAf_l5AAAAFdsxlu4202.txt
http页面验证fastdfs技术.
在浏览器中,输入下列网址:
http://192.168.0.22/appendix/M00/00/00/rBECFFnbOImAf_l5AAAAFdsxlu4202.txt
相关文章推荐
- FastDFS详细安装步骤,测试;Nginx中配置FastDFS,并提供优化,下载方法,楼主已测
- FastDFS详细安装步骤,测试;Nginx中配置FastDFS,并提供优化,下载方法,楼主已测
- Nginx的安装并实现web功能
- 【TaoTao】Nginx+FastDFS实现图片上传功能
- SVN 安装 文件服务器 上传 下载 同步
- JavaWeb文件上传与下载功能解析
- 上传下载分布式部署FASTDFS安装与配置
- 稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据
- .NET快速信息化系统开发框架 V3.2->Web版本新增“文件管理中心”集上传、下载、文件共享等一身,非常实用的功能
- Nginx的web功能安装
- C# MVC webuploader同步上传前后台详解教程(提供同步、异步上传源码下载链接地址)
- 稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据
- ModalDialog页面同时提供上传下载功能
- web程序中上传和下载功能的详解
- SpringMVC整合fastdfs-client-java实现web文件上传下载
- 稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据
- CentOS 6.3安装Nginx开启目录浏览、下载功能
- JavaWeb中struts2实现文件上传下载功能实例解析
- FTP方式实现上传下载功能
- 由 TIdTCPServer 提供客户端安装程序 WEB 下载的实现方法