Fastdfs之fastdfs-nginx-module安装部署

本文档详细介绍了在Linux环境下安装部署Fastdfs、libfastcommon、PCRE、Nginx以及fastdfs-nginx-module的步骤,并提供了配置Nginx服务器以支持Fastdfs的说明,包括创建软连接和设置nginx.conf文件。最后提到了添加nginx用户以确保正确运行。
摘要由CSDN通过智能技术生成

Fastdfs之fastdfs-nginx-module安装部署

安装必要组件:
libfastcommon-master.zip
fastdfs-5.11.tar.gz
fastdfs-nginx-module-1.20.tar.gz
pcre-8.35.tar.gz
nginx-1.16.1.tar.gz

以上组件百度网盘下载地址:
链接:https://pan.baidu.com/s/113Uop6rNzSQK4iEbveZwnQ
提取码:umie

1、安装必要依赖包

yum -y install deltarpm gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel vim wget 

2、libfastcommon install

unzip /usr/local/libfastcommon-master.zip 
./libfastcommon-master      /usr/local/libfastcommon-master
chmod -R 775 /usr/local/libfastcommon-master
cd /usr/local/libfastcommon-master && ./make.sh && ./make.sh install
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so && \
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so && \  
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so && \ 
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so

3、安装PCRE

pcre服务器可能已安装,通过ps -ef|grep pcre查看

4、Fastdfs安装

ADD ./fastdfs-5.11.tar.gz /usr/local/
cd /usr/local/fastdfs-5.11 && ./make.sh && ./make.sh install

5、安装nginx

cd /usr/local/nginx-1.16.1 && ./configure --prefix=/usr/local/ --with-http_stub_status_module
cd /usr/local/nginx-1.16.1 && make && make install

6、安装fast-nginx-module

mkdir -p /etc/fdfs/
mv /usr/local/fastdfs-nginx-module-1.20  /usr/local/fastdfs-nginx-module
chmod -R 775 /usr/local/fastdfs-nginx-module
sed -i "s/ngx_module_incs=\"\/usr\/local\/include\"/ngx_module_incs=\"\/usr\/include\/fastdfs \/usr\/include\/fastcommon\/\"/g"  /usr/local/fastdfs-nginx-module/src/config
sed -i "s/CORE_INCS=\"\$CORE_INCS \/usr\/local\/include\"/CORE_INCS=\"\$CORE_INCS \/usr\/include\/fastdfs \/usr\/include\/fastcommon\/\"/g"  /usr/local/fastdfs-nginx-module/src/config
cd /usr/local/nginx-1.16.1  && ./configure --add-module=/usr/local/fastdfs-nginx-module/src/
cd /usr/local/nginx-1.16.1 &&  make  && make install
cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

7、创建nginx 连接

这里特别注意的是,#user nobody未指定用户,可能会导致出现多个进程(worker_processes 1;),此时需要使用root用户,或者指定用户。

chmod -R 775 /usr/local/nginx/*
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
7.1 nginx.conf配置如下
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  188.188.188.130;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /root/dist/;
            try_files  $uri $uri/  /index.html;
            index  index.html index.htm;
        }

 
        location /prod-api/{
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass http://localhost:8080/;
	}


        location /boom {
			proxy_redirect off;
			proxy_pass http://localhost:8080/;
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        
        location ~/group([0-9])/M00 {
                        add_header Access-Control-Allow-Origin *;
                        add_header Access-Control-Allow-Methods 'GET,POST';
                        add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';            
                        root  /fastdfs/storage/data;
                        ngx_fastdfs_module;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
       

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


 
}

7.2、创建M00软连接
ln -s  /etc/fdfs/data  /etc/fdfs/data/M00

8、添加nginx用户

RUN useradd -s /sbin/nologin nginx
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值