FastDFS整合Nginx环境搭建

Eliza ·
更新时间:2024-09-21
· 933 次阅读

[root@192 ~]# cd /usr/local/src [root@192 src]# rz [root@192 src]# ls fastdfs-nginx-module_v1.16.tar.gz FastDFS_v5.05.tar.gz libfastcommonV1.0.7.tar.gz nginx-1.8.1.tar.gz [root@192 src]# yum -y install gcc-c++ libevent pcre pcre-devel zlib zlib-devel [root@192 src]# tar -xzvf /usr/local/src/libfastcommonV1.0.7.tar.gz [root@192 src]# cd libfastcommon-1.0.7 [root@192 libfastcommon-1.0.7]# ./make.sh [root@192 libfastcommon-1.0.7]# ./make.sh install [root@192 libfastcommon-1.0.7]# cp /usr/lib64/libfastcommon.so /usr/lib [root@192 libfastcommon-1.0.7]# cd ../ [root@192 src]# tar -zxvf FastDFS_v5.05.tar.gz [root@192 src]# cd ./FastDFS [root@192 FastDFS]# ./make.sh [root@192 FastDFS]# ./make.sh install [root@192 FastDFS]# cp ./conf/* /etc/fdfs [root@192 FastDFS]# mkdir /usr/local/fastdfs [root@192 FastDFS]# vim /etc/fdfs/tracker.conf # base_path 修改为 base_path=/usr/local/fastdfs # http.server_port 修改为 http.server_port=80 [root@192 FastDFS]# cd ~ [root@192 ~]# vim ~/fastdfs.sh # 'fastdfs.sh' /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart [root@192 ~]# chmod 777 ./fastdfs.sh [root@192 ~]# ./fastdfs.sh [root@192 ~]# vim /etc/fdfs/storage.conf # 将 group_name 修改为 group_name=group1 # 将 base_path 修改为 base_path=/usr/local/fastdfs # 将 store_path0 修改为store_path0=/usr/local/fastdfs/fdfs_storage # 将 tracker_server 修改为 tracker_server=192.168.17.128:22122 # 将 http.server_port 修改为 http.server_port=80 [root@192 ~]# mkdir -p /usr/local/fastdfs/fdfs_storage/data [root@192 ~]# vim ~/fastdfs.sh # 'fastdfs.sh' /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart [root@192 ~]# ./fastdfs.sh [root@192 ~]# vim /etc/fdfs/client.conf # 将 base_path 修改为 base_path=/usr/local/fastdfs # 将 tracker_server 修改为 tracker_server=192.168.17.128:22122 [root@192 ~]# ./fastdfs.sh waiting for pid [2206] exit ... starting ... waiting for pid [2214] exit ... starting ... [root@192 ~]# rz [root@192 ~]# ls 00000.jpg anaconda-ks.cfg fastdfs.sh [root@192 ~]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload ~/00000.jpg This is FastDFS client test program v5.05 Copyright (C) 2008, Happy Fish / YuQing FastDFS may be copied only under the terms of the GNU General Public License V3, which may be found in the FastDFS source kit. Please visit the FastDFS Home Page http://www.csource.org/ for more detail. [2020-05-01 03:50:59] DEBUG - base_path=/usr/local/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0 tracker_query_storage_store_list_without_group: server 1. group_name=, ip_addr=192.168.17.128, port=23000 group_name=group1, ip_addr=192.168.17.128, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKgRgF6r1OOAE7rxAAQWNwcIiuo489.jpg source ip address: 192.168.17.128 file timestamp=2020-05-01 03:50:59 file size=267831 file crc32=118000362 example file url: http://192.168.17.128/group1/M00/00/00/wKgRgF6r1OOAE7rxAAQWNwcIiuo489.jpg storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKgRgF6r1OOAE7rxAAQWNwcIiuo489_big.jpg source ip address: 192.168.17.128 file timestamp=2020-05-01 03:50:59 file size=267831 file crc32=118000362 example file url: http://192.168.17.128/group1/M00/00/00/wKgRgF6r1OOAE7rxAAQWNwcIiuo489_big.jpg [root@192 ~]# cd /usr/local/src [root@192 src]# tar -zxvf fastdfs-nginx-module_v1.16.tar.gz [root@192 src]# vim /usr/local/src/fastdfs-nginx-module/src/config # 将所有的 /usr/local/ 修改为 /usr/ CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/" CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient" [root@192 src]# tar -xzvf nginx-1.8.1.tar.gz [root@192 src]# vim /etc/fdfs/mod_fastdfs.conf # 将 base_path 修改为 base_path=/usr/local/fastdfs # 将 tracker_server 修改为 tracker_server=192.168.17.128:22122 # url_have_group_name 修改为 url_have_group_name = true # 将 store_path0 修改为 store_path0=/usr/local/fastdfs/fdfs_storage [root@192 src]# cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ [root@192 src]# cp /usr/lib64/libfdfsclient.so /usr/lib/ [root@192 src]# cd nginx-1.8.1 [root@192 nginx-1.8.1]# ./configure --prefix=/usr/local/nginx --with-http_gzip_static_module --add-module=/usr/local/src/fastdfs-nginx-module/src [root@192 nginx-1.8.1]# make [root@192 nginx-1.8.1]# make install [root@192 nginx-1.8.1]# cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx‐fdfs.conf [root@192 nginx-1.8.1]# vim /usr/local/nginx/conf/nginx‐fdfs.conf upstream storage_server_group1{ server 192.168.17.128:80 weight=10; # server 192.168.101.6:80 weight=10; } server { listen 80; server_name 192.168.17.128; location / { root html; index index.html index.htm; } location /group1/M00/{ root /usr/local/fastdfs/fdfs_storage/data; ngx_http_fastdfs_module; } location /group1{ proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://storage_server_group1; } } # 宿主机 浏览器输入http://192.168.17.128/group1/M00/00/00/wKgRgF6r1OOAE7rxAAQWNwcIiuo489_big.jpg

我要、发光_233 原创文章 40获赞 6访问量 1万+ 关注 私信 展开阅读全文
作者:我要、发光_233



fastdfs Nginx

需要 登录 后方可回复, 如果你还没有账号请 注册新账号