#安装libevent#解压
$ tar zxvf libevent-2.1.8-stable.tar.gz
$ cd libevent-2.1.8-stable/
#检查
$ ./configure
#编译
$ make#安装
$ sudomakeinstall#检查安装是否成功
$ ls -al /usr/local/lib/ |grep libevent
#防止在系统默认路径下 找不到库文件
$ sudoln -s /usr/local/lib/libevent-2.1.so.6 /usr/lib/libevent-2.1.so.6
#安装libfastcommon
$ unzip libfastcommon-1.36.zip
$ cd libfastcommon-master/
$ ./make.sh
$ sudo ./make.sh install#安装fastdfs#解压
$ tar -zxvf fastdfs-5.10.tar.gz
$ cd fastdfs-5.10/
#编译
$ ./make.sh
#安装
$ sudo ./make.sh install#验证
$ ls -al /usr/bin/fdfs*
$ fdfs_test
配置 fastdfs
#默认的配置文件地址在/etc/fdfs下#因为我们的项目需要#所以我们需要将配置文件拷贝到我们的conf文件夹下进配置
$ cd /etc/fdfs
$ cp client.conf.sample storage.conf.sample tracker.conf.sample $GOPATH/src/sss/Ihomeweb/conf
#将配置文件的名字进行下修改#客户端
$ mv client.conf.sample client.conf
#存储文件
$ mv storage.conf.sample storage.conf
#跟踪器
$ mv tracker.conf.sample tracker.conf
#准备文件夹在项目下创建文件夹
$ cd /home/itcast/go/src/sss
$ mkdir fastdfs
#在fastdfs下创建四个文件夹
$ cd fastdfs
$ mkdir tracker client storage storage_data
##配置tracker.conf#6行的ip地址设置# bind an address of this host# empty for bind all addresses of this host
bind_addr=192.168.110.123(需要配置的ip)
#21行的的log日志设置# the base path to store data and log files
base_path=/home/itcast/go/src/sss/fastdfs/tracker(log目录)
##配置storage.conf#13行配置ip# bind an address of this host# empty for bind all addresses of this host
bind_addr=192.168.110.123
#40行的log日志设置# the base path to store data and log files
base_path=/home/itcast/go/src/sss/fastdfs/storage(log目录)
#107行的文件存放设置# store_path#, based 0, if store_path0 not exists, it's value is base_path# the paths must be exist
store_path0=/home/itcast/go/src/sss/fastdfs/storage_data(文件存放路径)
#store_path1=/home/yuqing/fastdfs2#116行tracker的ip地址# 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.110.7:22122
##配置client.conf日志#9行的log日志地址# the base path to store log files
base_path=/home/itcast/go/src/sss/fastdfs/client(log目录)
#12行追踪器的ip# 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.110.123:22122
更新项目目录下的的setup_server.sh文件
#启动redis服务
redis-server ./conf/redis.conf
#启动trackerd
fdfs_trackerd /home/itcast/go/src/sss/homeweb/conf/tracker.conf restart
#启动storaged
fdfs_storaged /home/itcast/go/src/sss/homeweb/conf/storage.conf restart
我们先测试下
Fdfs_upload_file ./conf/client.conf cj.jpg
安装步骤nginx操作fast步骤
关于nginx操作fastdfs的插件
#将事先准备好的fastdfs的插件拷贝到ubuntu中#解压nginx关于fastdfs的插件
$ tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
#查看当前目录下存在两个解压好的文件
$ ls
fastdfs-nginx-module nginx-1.10.1
#进入fastdfs-nginx-module
$ cd fastdfs-nginx-module
#查看当前文件夹下文件
$ tree
.
├── HISTORY
├── INSTALL
└── src
├── common.c
├── common.h
├── config
├── mod_fastdfs.conf
└── ngx_http_fastdfs_module.c
#查看INSTALL文件
$ vim INSTALL
#在nginx 下执行 ./configure后最近结果显示会出现如下问题
sha1 library is not found
#找不到sha1的库
#configure的时候增加参数 --with-http_ssl_module
注意2:编译异常
#在 make时出现如下问题
src/core/ngx_murmurhash.c: In function ‘ngx_murmur_hash2’:
src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
h ^= data[2]<< 16;
~~^~~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:38:5: note: here
case 2:
^~~~
src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
h ^= data[1]<< 8;
~~^~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:40:5: note: here
case 1:
^~~~
cc1: all warnings being treated as errors
objs/Makefile:485: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1
make[1]: 离开目录“/home/itcast/ffdfs/nginx-1.10.1”
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2
#主要原因是 Makefile 里面 gcc 的参数多了一个"-Werror"#进入到/home/itcast/ffdfs/nginx-1.10.1/objs中修改Makefile
vim Makefile
#删除"-Werror"得到如下内容
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused -g -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='"/etc/fdfs/mod_fastdfs.conf"'
#修改fastdfs插件的配置文件进行修改,参数当前存储节点的storage.conf进行修改#进入到/etc/fdfs/目录
$ cd /etc/fdfs/
#编辑 mod_fastdfs.conf 文件
$ sudo vim mod_fastdfs.conf
# 存储log日志的目录
9 # the base path to store log files
10 base_path=/home/itcast/go/src/sss/fastdfs/storage
# 追踪器的地址信息
37 # FastDFS tracker_server can ocur more than once, and tracker_server format is
38 # "host:port", host can be hostname or ip address
39 # valid only when load_fdfs_parameters_from_tracker is true
40 tracker_server=192.168.110.20:22122
# 当前存储节点监听的端口
42 # the port of the local storage server
43 # the default value is 23000
44 storage_server_port=23000
# 当前存储节点所属的组
46 # the group name of the local storage server
47 group_name=group1
# 客户端访问的url中是不是出现组名
49 # if the url / uri including the group name
50 # set to false when uri like /M00/00/00/xxx
51 # set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
52 # default value is false
53 url_have_group_name =true# 当前存储节点存储路径的个数 参照 storage.conf
55 # path(disk or mount point) count, default value is 1
56 # must same as storage.conf
57 store_path_count=1
# 详细的存储路径
59 # store_path#, based 0, if store_path0 not exists, it's value is base_path
60 # the paths must be exist
61 # must same as storage.conf
62 store_path0=/home/itcast/go/src/sss/fastdfs/storage_data
#完成修改后再次启动nginx 依然是1个nginx进程
$ sudo nginx
$ ps aux |grep nginx
root 106838 0.0 0.0 31384 764 ? Ss 22:09 0:00 nginx: master process nginx
itcast 106841 0.0 0.0 21536 1048 pts/15 S+ 22:09 0:00 grep --color=auto nginx
#查看日志
$ cat /usr/local/nginx/logs/error.log
#发现新的错误
ERROR - file: ini_file_reader.c, line: 631, include file"http.conf" not exists, line: "#include http.conf"#那么说明我们的配置文件就改好了