做一个简单的配置记录,没在公司电脑上 自己用的centos又重新配置了一遍
1、准备安装包上传到/usr/local/src
FastDFS_v5.11.tar.gz (FastDFS安装包)
libfastcommon-1.0.39.tar.gz (FastDFS依赖程序)
nginx-1.16.1.tar.gz (nginx安装包,用于做文件请求http代理服务器)
fastdfs-nginx-module-1.20.tar.gz (nginx和fastdfs的桥梁插件模块)
2、安装C/C++ 编译环境
yum -y install gcc gcc-c++
3、安装 libfastcommon
cd /usr/local/src
tar -zxf libfastcommonV1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install
cp /usr/lib64/libfastcommon.so /usr/lib
4、创建数据存储目录
mkdir -p /usr/local/FastDFS/tracker /usr/local/FastDFS/storage /usr/local/FastDFS/client
5、安装FastDFS
cd /usr/local/src
tar -zxf FastDFS_v5.05.tar.gz
cd FastDFS
./make.sh
./make.sh install
cd conf
cp * /etc/fdfs
6、编辑/etc/fdfs/tracker.conf
vi /etc/fdfs/tracker.conf
base_path=/usr/local/FastDFS/tracker
7、启动tracker
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
8、配置storage节点
vi /etc/fdfs/storage.conf
base_path=/usr/local/FastDFS/storage
store_path0=/usr/local/FastDFS/storage
tracker_server = 192.168.100.151:22122
9、启动storage节点
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
10、配置测试
从编译完的FastDFS目录复制libfastclient.so 到/usr/lib目录
cd /usr/local/src/FastDFS/client
cp libfastclient.so /usr/lib
11、修改测试配置文件
vi /etc/fdfs/client.conf
base_path=/usr/local/FastDFS/client
tracker_server=192.168.100.151:22122
12、测试上传
/usr/bin/fdfs_test /etc/fdfs/client.conf upload xxx.png
13、安装nginx
yum install -y gcc-c++ (已安装)
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
14、解压fastdfs-nginx-module_v1.16.tar.gz
cd /usr/local/src
tar -zxf fastdfs-nginx-module_v1.16.tar.gz
15、修改fastdfs-nginx-module/src/config配置文件
把CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/include/fastcommon/"
修改为:CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
把CORE_LIBS="$CORE_LIBS -L/usr/local/lib -lfastcommon -lfdfsclient"
修改为:CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
实际就是把路径中的local这一层删除掉
16、复制fastdfs-nginx-module/src/mod_fastdfs.conf 到/etc/fdfs目录下
并编辑
tracker_server=192.168.100.151:22122
url_have_group_name = true
storage_server_port=23000
group_name=group1
store_path0=/usr/local/FastDFS/storage
17、安装nginx
cd /usr/local/src
tar -zxf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/
make
make install
18、配置nginx
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /group1/M00{
ngx_fastdfs_module;
}
location / {
root html;
index index.html index.htm;
}
重启nginx
/usr/local/nginx/sbin/nginx
2.这是我的fastdfs-nginx-module/src/config配置
ngx_addon_name=ngx_http_fastdfs_module
if test -n "${ngx_module_link}"; then
ngx_module_type=HTTP
ngx_module_name=$ngx_addon_name
ngx_module_incs="/usr/include /usr/include/fastcommon/"
ngx_module_libs="-lfastcommon -lfdfsclient"
ngx_module_srcs="$ngx_addon_dir/ngx_http_fastdfs_module.c"
ngx_module_deps=
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
. auto/module
else
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 /usr/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
fi
3.最后我感觉都配置好了可是自己的浏览器还是无法访问上传的测试文件,绕了一大圈发现是防火墙端口没开放(我本来用的是firewall后来自己下载了个iptables)
[root@localhost src]# cd /etc/sysconfig/
[root@localhost sysconfig]# vim iptables
//使用下面的命令去添加未开放的端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
大功告成
想要安装的插件什么的小伙伴可以留言 有问题可以一起交流