fastdfs-nginx安装配置和整合

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/LLnobug/article/details/82590249

Version 5.11对应的fastdfs-nginx-module的Version 1.20 
Version 5.10对应的fastdfs-nginx-module的Version 1.19

相关文件下载地址:https://download.csdn.net/download/llnobug/10657010

1.安装依赖库

yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel -y

2.上传解压libfastcommon
3.安装依赖并安装libfastcommon
yum -y install gcc-c++
cd libfastcommon
./make.sh
./make.sh install
4.安装fastdfs
上传解压fastdfs-5.11.zip
cd fastdfs-5.11
./make.sh
./make.sh install
5.复制配置文件
cd /etc/fdfs/
cp client.conf.sample client.conf
cp storage.conf.sample storage.conf
cp tracker.conf.sample tracker.conf
6.配置tracker
1.创建tracker工作目录
2.vim /etc/fdfs/tracker.conf
3.配置以下内容
    disabled=false #默认开启 
    port=22122 #默认端口号 
    base_path=/usr/yong.cao/dev/fastdfs/fastdfs_tracker #第一步创建的目录 
    http.server_port=6666 #默认端口是8080
4.命令
    启动:systemctl start fdfs_trackerd
    查看状态:systemctl status fdfs_trackerd
    停止:systemctl stop fdfs_trackerd
7.配置storage
1.创建storage工作目录和数据目录
2.修改配置文件 vim /etc/fdfs/storage.conf
    disabled=false 
    group_name=group1 #组名,根据实际情况修改 
    port=23000 #设置storage的端口号,默认是23000,同一个组的storage端口号必须一致 
    base_path=/usr/yong.cao/dev/fastdfs/fastdfs_storage #设置storage数据文件和日志目录 
    store_path_count=1 #存储路径个数,需要和store_path个数匹配 
    storage_path0=/usr/yong.cao/dev/fastdfs/fastdfs_storage_data #实际文件存储路径 ---
    tracker_server=192.168.128.131:22122 #我CentOS7的ip地址 
    http.server_port=8888 #设置 http 端口号
3.命令
    启动:systemctl start fdfs_storaged
    状态:systemctl status fdfs_storaged
    停止:systemctl stop fdfs_storaged
8.校验整合
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf
9.测试上传
1.修改配置文件 vim /etc/fdfs/client.conf
    base_path=/usr/yong.cao/dev/fastdfs/fastdfs_tracker #tracker服务器文件路径
    tracker_server=192.168.128.131:22122 #tracker服务器IP地址和端口号
    http.tracker_server_port=6666 # tracker 服务器的 http端口号,必须和tracker的设置对应起来
2.测试
    /usr/bin/fdfs_upload_file  /etc/fdfs/client.conf  /usr/yong.cao/ftp/593d8f1eN5b3b8133.jpg
10.安装nginx依赖
yum -y install pcre pcre-devel  
yum -y install zlib zlib-devel  
yum -y install openssl openssl-devel
11.解压nginx和nginx模块
12.进入nginx目录编译安装并配置模块
./configure --prefix=/usr/local/nginx --add-module=/usr/yong.cao/dev/nginx/fastdfs-nginx-module-master/src    #解压后fastdfs-nginx-module所在的位置
make
make install
nginx安装位置:/usr/local/nginx
13.配置nginx模块
修改nginx.conf
修改监听端口 listen 9999, 新增location
server {
        listen       9999;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        location ~/group1/M00 {
            root /usr/yong.cao/dev/fastdfs/fastdfs_storage_data/data;
            ngx_fastdfs_module;
        }
}
14.FastDFS安装时的解压过的目录,将http.conf和mime.types拷贝到/etc/fdfs目录下:
    把fastdfs-nginx-module安装目录中src目录下的mod_fastdfs.conf也拷贝到/etc/fdfs目录下
对刚刚拷贝的mod_fastdfs.conf文件进行修改:
base_path=/usr/yong.cao/dev/fastdfs/fastdfs_storage  #保存日志目录
 tracker_server=192.168.128.131:22122 #tracker服务器的IP地址以及端口号
 storage_server_port=23000 #storage服务器的端口号
 url_have_group_name = true #文件 url 中是否有 group 名
 store_path0=/usr/yong.cao/dev/fastdfs/fastdfs_storage_data   #存储路径
 group_count = 0 #设置组的个数,事实上这次只使用了group1

15.启动nginx  /usr/local/nginx/sbin/nginx

一些简单的Linux命令:

查看nginx是否启动  pa -C nginx -o pid

扫描二维码关注公众号,回复: 3622003 查看本文章

关闭防火墙  systemctl stop firewalld

测试 nnginx是否配置正确   ./nginx -t

重启nginx  ./nginx -s reload

猜你喜欢

转载自blog.csdn.net/LLnobug/article/details/82590249
今日推荐