linux --------fastDFS安装+配置Nginx

linux 下fastDFS安装+配置Nginx:

环境:fastDFS 5.05
nginx 1.8.0
fastdfs-nginx-module 1.16

千万要注意版本, 千万要注意版本, 千万要注意版本

直接上命令:

yum install -y gcc gcc-c++
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
tar -zxvf V1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
// 安装,命令:
./make.sh install
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
tar -zxvf V5.05.tar.gz
cd fastdfs-5.05
./make.sh
安装,命令:
./make.sh install

1. 配置Tracker 服务

cp tracker.conf.sample tracker.conf
vim tracker.conf

打开tracker.conf文件,只需要找到你只需要改这两个参数就可以了。

 base_path=/home/java/fastdfs
 http.server_port=80
 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start

使用ln -s 建立软链接:

 ln -s /usr/bin/fdfs_trackerd /usr/local/bin
 ln -s /usr/bin/stop.sh /usr/local/bin
 ln -s /usr/bin/restart.sh /usr/local/bin

启动服务,查看监听:

service fdfs_trackerd start
netstat -unltp|grep fdfs

2. 配置 Storage 服务:

cp storage.conf.sample storage.conf
vim storage.conf

修改:

base_path=/home/java/fastdfs
store_path0=/home/java/fastdfs
tracker_server=192.168.13.53:22122   //可以修改所需端口号

ln -s建立软链接:

ln -s /usr/bin/fdfs_storaged /usr/local/bin

启动服务

service fdfs_storaged start

配置client.conf

cd /etc/fdfs
cp client.conf.sample client.conf
vim client.conf

base_path=/home/java/fastdfs
tracker_server=192.168.13.53:22122

Fast配置Nginx模块

环境所需nginx:fastdfs-nginx-module_v1.16.tar.gz

注意版本 ,注意版本 ,注意版本

yum install -y gcc gcc-c++
yum -y install openssl openssl-devel
wget https://nginx.org/download/nginx-1.8.0.tar.gz
tar -zxvf nginx-1.8.0.tar.gz
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz

进入fastdfs-nginx-module,修改config

CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

修改完之后:

ngx_addon_name=ngx_http_fastdfs_module
HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/local/lib -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"

修改mod_fastdfs.conf

cd /software/fastdfs-nginx-module-master/src/
vim mod_fastdfs.conf

修改点:

tracker_server=192.168.13.53:22122
url_have_group_name = true
store_path0=/home/java/fastdfs
cp anti-steal.jpg http.conf mime.types /etc/fdfs/

nginx配置:

./configure --prefix=/usr/local/nginx  --add-module=/home/java/fastdfs-nginx-module/src/
make && make install
cd /usr/local/nginx/sbin

./nginx -V 查看fastdfs-nginx-module 是否加进去了
没有先删除 /usr/local/nginx 在到make目录 make clean
可能会产生错误:

1:make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1

解决办法:cd nginx安装目录objs/ 修改Makefile 删除-Werrori

/-Werrori  快捷定位

2:怎么也找不到fastdfs-nginx-module-master unknown directive "ngx_fastdfs_module"

由于版本问题无法解决这个问题,换fastdfs-nginx-module-master版本

nginx 配置文件中配置

server {
        listen       80;
        server_name  192.168.13.53; //改你自己服务器IP


        #charset koi8-r;


        #access_log  logs/host.access.log  main;


        location / {
            root   html;
            index  index.html index.htm;
        }
        location ~/group([0-9])/M00 {
                ngx_fastdfs_module;
            }

启动nginx

cd  /usr/localhost/nginx/sbin
./nginx -c /usr/localhost/nginx/conf/nginx.conf  //带配置启动
./nginx -s stop  //停止

上传测试fastDFS: 后面 /home/java/test.png 为要上传图片的地址
/usr/bin/fdfs_t
est /etc/fdfs/client.conf upload /home/java/test.png

服务器属于内网环境:直接使用下面地址是访问不通的
http://192.168.13.53/group1/M00/00/00/wKgNNV_I1xCAFStkAABzZSCzVUY582_big.png为浏览器测试地址

参考地址,但需排坑:https://blog.csdn.net/qq_32953079/article/details/83789461?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值