nginx安装fastdfs模块

一、下载安装

 wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip
unzip master.zip

二、重新编译nginx

cd nginx-1.9.15
 ./configure --prefix=/home/nginx --with-http_ssl_module  --add-module=/home/package/fastdfs-nginx-module-master/src/
make && make install

三、配置

cp /home/package/fastdfs-nginx-module-master/src/mod_fastdfs.conf  /etc/fdfs/

vim mod_fastdfs.conf
base_path=/home/FastDFS/data/storage
tracker_server=192.168.198.129:22122
storage_server_port=23000(默认配置为23000)
url_have_group_name = true
store_path0=/data/fastdfs/storage(storage配置的目录)
group_name=group1(默认配置为group1)

cd /home/FastDFS/conf/
cp anti-steal.jpg http.conf mime.types /etc/fdfs/

四、nginx配置

server {
    listen      18888;
    server_name img.com;
    root        /home/work;
    index       index.html index.htm index.php;



    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }
//增加一下代码:
    location ~/group[0-9]/M00{
        root /home/work/data/fastdfs;
        ngx_fastdfs_module;
    }
    location ~ \.php$ {
        include        fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass  localhost:9000;
    }
}

18888端口号与/etc/fdfs/storage.conf中的http.server_port=18888相对应

storage对应有多个group的情况下,访问路径带group名称,例如:/group1/M00/00/00/**,对应nginx配置:
location ~/group[0-9]/ {
ngx_fastdfs_module;
}

重启nginx

你可能感兴趣的:(nginx安装fastdfs模块)