【CentOS7】安装部署【FastDFS】
操作系统:CentOS Linux release 7.3.1611 (Core)
一:准备工作
1、关闭CentOS 7的防火墙
参见:http://www.xxf-home.net/archives/826
2、准备安装介质
1 2 3 4 5 6 7 |
[root@fileserver soft]# ll -rw-r--r--. 1 root root 42656 Jan 14 2021 fastdfs_client_java._v1.25.tar.gz -rw-r--r--. 1 root root 17510 Jan 14 2021 fastdfs-nginx-module_v1.16.tar.gz -rw-r--r--. 1 root root 345400 Jan 14 2021 FastDFS_v5.05.tar.gz -rw-r--r--. 1 root root 1037747 Jan 16 2020 nginx-1.17.7.tar.gz -rw-r--r--. 1 root root 444656 Apr 23 09:38 V1.0.38.tar.gz [root@fileserver soft]# |
其中,V1.0.38.tar.gz为libfastcommon,libfastcommon包含了FastDFS运行所需要的一些基础库。
因为下载地址及版本的不同,安装包的文件名也有所不同
3、安装必须的依赖软件包
1 |
[root@fileserver ~]# yum install -y gcc gcc-c++ libevent |
二:安装部署
1、安装libfastcommon
libfastcommon为FastDFS官方提供,libfastcommon中包含了FastDFS运行所需要的一些动态链接库。
1) 将libfastcommon解压至/usr/local/下:
1 |
[root@fileserver soft]# tar -xzvf V1.0.38.tar.gz -C /usr/local/ |
2) 编译、安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@fileserver soft]# cd /usr/local/libfastcommon-1.0.38/ [root@fileserver libfastcommon-1.0.38]# ls doc HISTORY INSTALL libfastcommon.spec make.sh php-fastcommon README src [root@fileserver libfastcommon-1.0.38]# [root@fileserver libfastcommon-1.0.38]# ./make.sh cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o hash.o hash.c ……略…… cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -o libfastcommon.so -shared hash.lo chain.lo shared_func.lo ini_file_reader.lo logger.lo sockopt.lo base64.lo sched_thread.lo http_func.lo md5.lo pthread_func.lo local_ip_func.lo avl_tree.lo ioevent.lo ioevent_loop.lo fast_task_queue.lo fast_timer.lo process_ctrl.lo fast_mblock.lo connection_pool.lo fast_mpool.lo fast_allocator.lo fast_buffer.lo multi_skiplist.lo flat_skiplist.lo system_info.lo fast_blocked_queue.lo id_generator.lo char_converter.lo char_convert_loader.lo common_blocked_queue.lo multi_socket_client.lo skiplist_set.lo -lm -lpthread ar rcs libfastcommon.a hash.o chain.o shared_func.o ini_file_reader.o logger.o sockopt.o base64.o sched_thread.o http_func.o md5.o pthread_func.o local_ip_func.o avl_tree.o ioevent.o ioevent_loop.o fast_task_queue.o fast_timer.o process_ctrl.o fast_mblock.o connection_pool.o fast_mpool.o fast_allocator.o fast_buffer.o multi_skiplist.o flat_skiplist.o system_info.o fast_blocked_queue.o id_generator.o char_converter.o char_convert_loader.o common_blocked_queue.o multi_socket_client.o skiplist_set.o [root@fileserver libfastcommon-1.0.38]# [root@fileserver libfastcommon-1.0.38]# [root@fileserver libfastcommon-1.0.38]# ./make.sh install mkdir -p /usr/lib64 mkdir -p /usr/lib mkdir -p /usr/include/fastcommon install -m 755 libfastcommon.so /usr/lib64 install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h common_blocked_queue.h multi_socket_client.h skiplist_set.h /usr/include/fastcommon if [ ! -e /usr/lib/libfastcommon.so ]; then ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so; fi [root@fileserver libfastcommon-1.0.38]# |
3) 如果一切正常,会在/usr/lib64目录下看到这个动态链接库(必须要有)
1 2 3 |
[root@fileserver libfastcommon-1.0.38]# ll /usr/lib64/libfastcommon.so -rwxr-xr-x. 1 root root 941584 Jan 15 14:11 /usr/lib64/libfastcommon.so [root@fileserver libfastcommon-1.0.38]# |
4) 如果一切正常,会在/usr/lib目录下看到这个动态链接库的软连接(必须要有)
1 2 3 |
[root@fileserver libfastcommon-1.0.38]# ll /usr/lib/libfastcommon.so lrwxrwxrwx. 1 root root 27 Jan 15 14:11 /usr/lib/libfastcommon.so -> /usr/lib64/libfastcommon.so [root@fileserver libfastcommon-1.0.38]# |
2、安装FastDFS
2.1、安装tracker
1) 将FastDFS_v5.05.tar.gz解压至/usr/local目录下
1 2 3 4 5 6 7 8 9 |
[root@fileserver soft]# ll total 1856 drwxr-xr-x. 4 root root 181 Apr 23 2009 backup -rw-r--r--. 1 root root 42656 Jan 14 19:43 fastdfs_client_java._v1.25.tar.gz -rw-r--r--. 1 root root 17510 Jan 14 19:43 fastdfs-nginx-module_v1.16.tar.gz -rw-r--r--. 1 root root 345400 Jan 14 19:42 FastDFS_v5.05.tar.gz -rw-r--r--. 1 root root 1037747 Jan 16 2020 nginx-1.17.7.tar.gz -rw-r--r--. 1 root root 444656 Apr 23 2009 V1.0.38.tar.gz [root@fileserver soft]# tar -xzvf FastDFS_v5.05.tar.gz -C /usr/local/ |
2) 解压完成后,切换至FastDFS目录,进行编译和安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
[root@fileserver soft]# cd /usr/local/FastDFS/ [root@fileserver FastDFS]# ls client common conf COPYING-3_0.txt fastdfs.spec HISTORY init.d INSTALL make.sh php_client README.md restart.sh stop.sh storage test tracker [root@fileserver FastDFS]# ## 编译 [root@fileserver FastDFS]# ./make.sh ## 在编译的过程中,出现了2个警告,可能是编译函数出现了问题,我的实验中是忽略了,没有管它,目前看不影响测试 ## 安装 [root@fileserver FastDFS]# ./make.sh install mkdir -p /usr/bin mkdir -p /etc/fdfs cp -f fdfs_trackerd /usr/bin if [ ! -f /etc/fdfs/tracker.conf.sample ]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi mkdir -p /usr/bin mkdir -p /etc/fdfs cp -f fdfs_storaged /usr/bin if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi mkdir -p /usr/bin mkdir -p /etc/fdfs mkdir -p /usr/lib64 cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender /usr/bin if [ 0 -eq 1 ]; then cp -f libfdfsclient.a /usr/lib64; fi if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; fi mkdir -p /usr/include/fastdfs cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f ../conf/client.conf /etc/fdfs/client.conf.sample; fi [root@fileserver FastDFS]# |
3) tracker启动时的默认配置文件在/etc/fdfs目录下,修改配置文件的默认参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@fileserver conf]# cd /etc/fdfs [root@fileserver fdfs]# ll total 20 -rw-r--r--. 1 root root 1461 Jan 15 14:21 client.conf.sample -rw-r--r--. 1 root root 7829 Jan 15 14:21 storage.conf.sample -rw-r--r--. 1 root root 7102 Jan 15 14:21 tracker.conf.sample [root@fileserver fdfs]# [root@fileserver fdfs]# cp tracker.conf.sample tracker.conf [root@fileserver fdfs]# ll total 28 -rw-r--r--. 1 root root 1461 Jan 15 14:21 client.conf.sample -rw-r--r--. 1 root root 7829 Jan 15 14:21 storage.conf.sample -rw-r--r--. 1 root root 7102 Jan 15 14:27 tracker.conf -rw-r--r--. 1 root root 7102 Jan 15 14:21 tracker.conf.sample [root@fileserver fdfs]# |
4) 修改tracker.conf中如下参数
1 2 3 4 |
[root@fileserver fdfs]# vi tracker.conf ## 找到以下两个参数,并改之 base_path=/home/yuqing/fastdfs 改为 base_path=/Data/fastdfs http.server_port=8080 改为 http.server_port=80 |
5) 按照上面参数修改的情况创建目录
1 2 3 4 5 |
[root@fileserver fdfs]# mkdir -p /Data/fastdfs [root@fileserver fdfs]# cd /Data/fastdfs/ [root@fileserver fastdfs]# pwd /Data/fastdfs [root@fileserver fastdfs]# |
6) 启动
1 |
[root@fileserver ~]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start |
7) 验证,已存在该进程,同时我们还看到/home/fastdfs/目录下多了两个文件,一个是相关数据,一个是日志
1 2 3 4 5 6 7 8 |
[root@fileserver ~]# ps -ef|grep track root 18340 1 0 14:38 ? 00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start root 18351 17485 0 14:39 pts/1 00:00:00 grep --color=auto track [root@fileserver ~]# [root@fileserver ~]# cd /Data/fastdfs/ [root@fileserver fastdfs]# ls data logs [root@fileserver fastdfs]# |
2.2、配置和启动storage
1) 切换至/etc/fdfs/目录下,配置storage参数文件
1 2 3 4 5 6 7 8 9 10 |
[root@fileserver fastdfs]# cd /etc/fdfs/ [root@fileserver fdfs]# ll s* -rw-r--r--. 1 root root 7829 Jan 15 14:21 storage.conf.sample [root@fileserver fdfs]# [root@fileserver fdfs]# cp storage.conf.sample storage.conf [root@fileserver fdfs]# [root@fileserver fdfs]# ll s* -rw-r--r--. 1 root root 7829 Jan 15 14:42 storage.conf -rw-r--r--. 1 root root 7829 Jan 15 14:21 storage.conf.sample [root@fileserver fdfs]# |
2) 修改storage.conf配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@fileserver fdfs]# vi storage.conf # 修改storage.conf配置文件 group_name=group1 #配置组名 base_path=/home/yuqing/fastdfs 改为: base_path=/Data/fastdfs #store存放文件的位置(store_path) store_path0=/home/yuqing/fastdfs 改为: store_path0=/Data/fdfs_storage # 如果有多个挂载磁盘则定义多个store_path,如下 #store_path1=..... #store_path2=...... # 配置tracker服务器:IP tracker_server=192.168.31.2:22122 # 如果有多个则配置多个tracker #tracker_server=192.168.31.4:22122 # 配置http端口 http.server_port=88 |
3) 安装参数修改,创建 /Data/fdfs_storage 目录
1 2 3 4 5 |
[root@fileserver fdfs]# mkdir -p /Data/fdfs_storage [root@fileserver fdfs]# cd /Data/fdfs_storage [root@fileserver fdfs_storage]# pwd /Data/fdfs_storage [root@fileserver fdfs_storage]# |
4) 启动storage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@fileserver fdfs_storage]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start [root@fileserver fdfs_storage]# # 启动后,我们会看到fdfs_storage目录下会有非常多的目录 [root@fileserver fdfs_storage]# cd /Data/fdfs_storage/ [root@fileserver fdfs_storage]# ls data [root@fileserver fdfs_storage]# cd data/ [root@fileserver data]# ls 00 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B 50 55 5A 5F 64 69 6E 73 78 7D 82 87 8C 91 96 9B A0 A5 AA AF B4 B9 BE C3 C8 CD D2 D7 DC E1 E6 EB F0 F5 FA FF 01 06 0B 10 15 1A 1F 24 29 2E 33 38 3D 42 47 4C 51 56 5B 60 65 6A 6F 74 79 7E 83 88 8D 92 97 9C A1 A6 AB B0 B5 BA BF C4 C9 CE D3 D8 DD E2 E7 EC F1 F6 FB 02 07 0C 11 16 1B 20 25 2A 2F 34 39 3E 43 48 4D 52 57 5C 61 66 6B 70 75 7A 7F 84 89 8E 93 98 9D A2 A7 AC B1 B6 BB C0 C5 CA CF D4 D9 DE E3 E8 ED F2 F7 FC 03 08 0D 12 17 1C 21 26 2B 30 35 3A 3F 44 49 4E 53 58 5D 62 67 6C 71 76 7B 80 85 8A 8F 94 99 9E A3 A8 AD B2 B7 BC C1 C6 CB D0 D5 DA DF E4 E9 EE F3 F8 FD 04 09 0E 13 18 1D 22 27 2C 31 36 3B 40 45 4A 4F 54 59 5E 63 68 6D 72 77 7C 81 86 8B 90 95 9A 9F A4 A9 AE B3 B8 BD C2 C7 CC D1 D6 DB E0 E5 EA EF F4 F9 FE [root@fileserver data]# |
2.3、自带客户端配置及测试上传文件
1) 拷贝配置文件
1 2 3 4 5 6 7 8 9 10 11 |
[root@fileserver data]# cd /etc/fdfs [root@fileserver fdfs]# [root@fileserver fdfs]# ll c* -rw-r--r--. 1 root root 1461 Jan 15 14:21 client.conf.sample [root@fileserver fdfs]# [root@fileserver fdfs]# cp client.conf.sample client.conf [root@fileserver fdfs]# [root@fileserver fdfs]# ll c* -rw-r--r--. 1 root root 1461 Jan 15 15:32 client.conf -rw-r--r--. 1 root root 1461 Jan 15 14:21 client.conf.sample [root@fileserver fdfs]# |
2) 修改配置文件
1 2 3 4 5 6 7 8 |
[root@fileserver fdfs]# vi client.conf # 修改以下两个参数 # the base path to store log files base_path=/Data/fastdfs # tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address tracker_server=192.168.31.2:22122 |
3) 测试上传文件 /usr/bin/fdfs_test /etc/fdfs/client.conf upload /soft/20210115153751.jpg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
[root@fileserver soft]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /soft/20210115153751.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. [2021-01-15 15:39:52] DEBUG - base_path=/Data/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.31.2, port=23000 group_name=group1, ip_addr=192.168.31.2, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKgfAmABRsiAOBucAAIqDy2jThI323.jpg source ip address: 192.168.31.2 file timestamp=2021-01-15 15:39:52 file size=141839 file crc32=765677074 example file url: http://192.168.31.2/group1/M00/00/00/wKgfAmABRsiAOBucAAIqDy2jThI323.jpg storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKgfAmABRsiAOBucAAIqDy2jThI323_big.jpg source ip address: 192.168.31.2 file timestamp=2021-01-15 15:39:52 file size=141839 file crc32=765677074 example file url: http://192.168.31.2/group1/M00/00/00/wKgfAmABRsiAOBucAAIqDy2jThI323_big.jpg [root@fileserver soft]# |
上面已经上传成功,文中http://192.168.31.2/group1/M00/00/00/wKgfAmABRsiAOBucAAIqDy2jThI323_big.jpg即为http下载地址,由于还没有安装nginx,所以暂时还无法下载。
2.4、安装:fastdfs-nginx-module 模块
1) 解压 fastdfs-nginx-module_v1.16.tar.gz 到 /usr/local目录下
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@fileserver soft]# ll fastdfs-nginx* -rw-r--r--. 1 root root 17510 Jan 14 19:43 fastdfs-nginx-module_v1.16.tar.gz [root@fileserver soft]# tar -xzvf fastdfs-nginx-module_v1.16.tar.gz -C /usr/local/ fastdfs-nginx-module/ fastdfs-nginx-module/src/ fastdfs-nginx-module/src/ngx_http_fastdfs_module.c fastdfs-nginx-module/src/mod_fastdfs.conf fastdfs-nginx-module/src/config fastdfs-nginx-module/src/common.h fastdfs-nginx-module/src/common.c fastdfs-nginx-module/INSTALL fastdfs-nginx-module/HISTORY [root@fileserver soft]# |
1) 修改nginx模块的配置文件,修改时一定不要修改错误,否则,在编译nginx的时候会出现问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 切换目录到:/usr/local/fastdfs-nginx-module/src/目录下 [root@fileserver soft]# cd /usr/local/fastdfs-nginx-module/src [root@fileserver src]# pwd /usr/local/fastdfs-nginx-module/src [root@fileserver src]# ls common.c common.h config mod_fastdfs.conf ngx_http_fastdfs_module.c [root@fileserver src]# # 修改配置文件 [root@fileserver src]# vi config # 修改路径,将/usr/local/include/ 改为 /usr/include/ 去掉local,一共改三处,改后效果如下: 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/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\"'" [root@WebServer src]# |
2) 修改配置文件mod_fastdfs.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# 将文件mod_fastdfs.conf拷贝到/etc/fdfs/ 目录 [root@WebServer src]# cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ [root@fileserver ~]# cd /etc/fdfs [root@fileserver fdfs]# ll -rw-r--r--. 1 root root 1453 Jan 15 15:37 client.conf -rw-r--r--. 1 root root 3679 Jan 15 15:58 mod_fastdfs.conf -rw-r--r--. 1 root root 7815 Jan 15 14:53 storage.conf -rw-r--r--. 1 root root 7093 Jan 15 14:45 tracker.conf [root@fileserver fdfs]# [root@fileserver fdfs]# vi mod_fastdfs.conf # 修改如下内容 # the base path to store log files base_path=/Data/fastdfs # must same as storage.conf store_path0=/Data/fdfs_storage # 这个必须要改为true,否则http访问时会报错400 bad request的错误,重要!重要!重要! # default value is false url_have_group_name = true # FastDFS tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address # valid only when load_fdfs_parameters_from_tracker is true tracker_server=tracker:22122 改为 tracker_server=192.168.31.2:22122 |
3) 将libfdfsclient.so库文件拷贝或者软连接到/usr/lib/目录,本测试采用的是拷贝
1 2 3 4 5 6 7 |
[root@fileserver fdfs]# ll /usr/lib/libfdfsclient.so ls: cannot access /usr/lib/libfdfsclient.so: No such file or directory [root@fileserver fdfs]# [root@fileserver fdfs]# cp /usr/lib64/libfdfsclient.so /usr/lib/ [root@fileserver fdfs]# ll /usr/lib/libfdfsclient.so -rwxr-xr-x. 1 root root 308608 Jan 15 16:13 /usr/lib/libfdfsclient.so [root@fileserver fdfs]# |
4) 拷贝配置文件到 /etc/fdfs 下
1 2 3 4 5 6 7 8 9 10 11 |
[root@fileserver ~]# cp /usr/local/FastDFS/conf/http.conf /usr/local/FastDFS/conf/mime.types /etc/fdfs/ [root@fileserver ~]# [root@fileserver ~]# cd /etc/fdfs/ [root@fileserver fdfs]# ll -rw-r--r--. 1 root root 1453 Jan 15 15:37 client.conf -rw-r--r--. 1 root root 858 Jan 15 17:47 http.conf -rw-r--r--. 1 root root 31172 Jan 15 17:47 mime.types -rw-r--r--. 1 root root 3690 Jan 15 16:11 mod_fastdfs.conf -rw-r--r--. 1 root root 7815 Jan 15 14:53 storage.conf -rw-r--r--. 1 root root 7093 Jan 15 14:45 tracker.conf [root@fileserver fdfs]# |
2.5、安装nginx
安装nginx需要先安装 pcore、zlib、perl5、OpenSSL这几个依赖包,然后再安装nginx,本实验,这几个软件包的安装略
1) 解压nginx-1.17.7.tar.gz至/usr/local
1 2 3 4 |
[root@fileserver soft]# ll nginx-1.17.7.tar.gz -rw-r--r--. 1 root root 1037747 Jan 16 2020 nginx-1.17.7.tar.gz [root@fileserver soft]# [root@fileserver soft]# tar -xzvf nginx-1.17.7.tar.gz -C /usr/local/ |
2) 生成配置文件,加入fastdfs-nginx-module/src模块,在执行的过程中,是不应该出现错误的,如果出现错误,有可能就是 {安装:fastdfs-nginx-module 模块}配置文件修改的有问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 生成配置文件时,指定了http-client-body-temp-path的路径,所以先创建一下这个路径 [root@fileserver soft]# mkdir -p /var/temp/nginx/client [root@fileserver soft]# cd /usr/local/nginx-1.17.7/ [root@fileserver nginx-1.17.7]# ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src [root@fileserver nginx-1.17.7]# ./configure \ --prefix=/usr/local/nginx \ --pid-path=/usr/local/nginx/nginx.pid \ --lock-path=/usr/local/nginx/nginx.lock \ --error-log-path=/usr/local/nginx/error.log \ --http-log-path=/usr/local/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi \ --add-module=/usr/local/fastdfs-nginx-module/src |
3) 编译并安装
1 2 3 4 5 6 7 8 |
[root@fileserver nginx-1.17.7]# make && make install # 编译完成后,效果如下: [root@fileserver nginx-1.17.7]# cd /usr/local/nginx [root@fileserver nginx]# pwd /usr/local/nginx [root@fileserver nginx]# ls conf html sbin [root@fileserver nginx]# |
4) 修改nginx配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[root@fileserver ~]# vi /usr/local/nginx/conf/nginx.conf # 进程ID的文件,指向明确的路径 pid /usr/local/nginx/nginx.pid; # server中修改几个地方 # 1) server_name 改为服务器IP地址 # 2) location 后面加上存储文件的目录 /group1/M00 # 3) 指定root的目录及fastdfs的nginx模块 # group1为nginx 服务FastDFS的分组名称,M00是FastDFS自动生成编号 server { listen 80; #server_name localhost; server_name 192.168.31.2; #charset koi8-r; #access_log logs/host.access.log main; location /group1/M00 { #root html; #index index.html index.htm; root /Data/fdfs_storage/data; ngx_fastdfs_module; } |
5) 启动nginx
1 2 3 4 5 6 7 8 9 10 11 |
[root@fileserver ~]# cd /usr/local/nginx/sbin [root@fileserver sbin]# [root@fileserver sbin]# ./nginx ngx_http_fastdfs_set pid=29277 [root@fileserver sbin]# [root@fileserver sbin]# [root@fileserver sbin]# ps -ef|grep nginx root 29278 1 0 18:00 ? 00:00:00 nginx: master process ./nginx nobody 29279 29278 0 18:00 ? 00:00:00 nginx: worker process root 29281 17485 0 18:00 pts/1 00:00:00 grep --color=auto nginx [root@fileserver sbin]# |
6) 此时可通过http下载图片
http://192.168.31.2/group1/M00/00/00/wKgfAmABRsiAOBucAAIqDy2jThI323_big.jpg