Nginx安装-让文件服务器fastdfs提供有web方式的上传下载功能,nginxfastdfs


所需文件下载地址: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

相关内容

    暂无相关文章