centos8安装fastdfs和nginx
创始人
2024-03-30 00:40:51

1.下载所需依赖库

[root@caochenlei ~]# yum install -y gcc gcc-c++ perl perl-devel openssl openssl-devel pcre pcre-devel zlib zlib-devel libevent libevent-devel


2.下载fastdfs-storage,并解压安装

wget
https://github.com/happyfish100/libfastcommon/archive/V1.0.43.tar.gztar -zxvf V1.0.43.tar.gz
cd ibfastcommon-1.0.43/
./make.sh 
./make.sh install
cd ..


3.下载fastdfs-tracker,并解压安装

wget https://github.com/happyfish100/fastdfs/archive/V6.06.tar.gztar -zxvf V6.06.tar.gz 
cd fastdfs-6.06/
./make.sh
./make.sh install
cd ..



4.创建fastdfs存储文件夹目录

cd /home/pro/work/fdfs
mkdir client
mkdir storage
mkdir tracker



5.创建fastdfs配置文件

cd /etc/fdfs/
cp  tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf



6.修改fastdfs配置文件

vim     tracker.conf
base_path=/home/pro/work/fdfs/trackervim storage.conf
base_path=/home/pro/work/fdfs/storage
store_path0 =/home/pro/work/fdfs/storage
tracker_server=192.168.1.106:22122vim client.conf
base_path = /home/pro/work/fdfs/tracker
tracker_server = 192.168.1.106:22122


7.开启fastdfs服务

fdfs_trackerd  /etc/fdfs/tracker.conf
fdfs_storaged  /etc/fdfs/storage.conf



8.上传一个文件测试

fdfs_upload_file /etc/fdfs/client.conf tets.jpg



得到返回的特征码表示上传成功,且对应编组文件夹中找到对应上传的文件。
group1/M00/00/00/wKgBamLYOMWAOjv5ACBtqBt3eeY961.jpg


1.安装nginx依赖

yum install -y gcc gcc-c++ make libtool wget pcre pcre-devel zlib zlib-devel openssl openssl-devel


2.下载nginx和fastdfs-nginx-module,并解压。注意module只能在安装nginx时加载!

wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.g
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz
tar -zxvf V1.22.tar.gzcd fastdfs-nginx-module-1.22/src/
pwd
/root/fastdfs-nginx-module-1.22/src



3.为nginx安装module

cd nginx-1.18.0
./configure  --add-module=/home/pro/fastdfs-nginx-module-1.22/src
make && make install



若安装失败,可能是缺少nginx运行依赖库,将缺少的库安装后再安装nginx、

4.将module包src里的配置文件拷贝并修改

cd /home/pro/fastdfs-nginx-module-1.22/src
cp mod_fastdfs.conf /etc/fdfs/
cd /etc/fdfs/vim mod_fastdfs.conf
connect_timeout=10    //连接超时时间默认为2秒,修改为10秒
base_path=/home/pro/work/fdfs/tracker    //设为fdfs-tracker的工作文件夹
tracker_server=192.168.1.106:22122        //设为fdfs-tracker的ip
store_path0=/home/pro/work/fdfs/storage        //设为fdfs-storage的工作文件夹
url_have_group_name=true    //启用组名



5.把fastdfs-server中的配置文件拷贝,做nginx网络层作用

cd fastdfs-6.06/conf
cp http.conf  /etc/fdfs/
cp mime.types /etc/fdfs/



6.配置nginx配置文件,添加服务器配置信息

cd /usr/local/nginx/confvim nginx.conf#gzip  on;server{listen      8888;        //ngxin端口号server_name 192.168.1.106;    //nginxip地址location ~ /group[1-9]/M0[0-9] {    //组名ngx_fastdfs_module;    //模组}error_page   500 502 503 504  /50x.html;    //错误页面location /50x.html {root   html;} }


7.启动nginx服务

cd /usr/local/nginx/sbin
./nginx



8.测试nginx服务
在浏览器输入 192.168.1.106:8888,会显示nginx默认页面。
再次输入 192.168.1.106:8888/group1/M00/00/00/wKgBamLYOMWAOjv5ACBtqBt3eeY961.jpg 会显示刚刚上传的图片
 

相关内容

热门资讯

稳固百亿基本盘!全棉时代筑牢消... 2025年,在国际贸易摩擦加剧、关税壁垒抬升,行业整体压力不减的背景下,稳健医疗(300888.SZ...
伊朗称在霍尔木兹海峡上空击落美... 人民财讯5月7日电,伊朗方面消息称,伊朗防空部队当地时间5日晚在霍尔木兹海峡上空击落了一架美军无人机...
CPO 概念行情火热 产业扩容... 5 月 7 日全球宏观盘面重磅洗牌,美元持续弱势震荡、美股全线冲高刷新历史新高,有色金属迎来强势拉升...
媒体视点 | 从“赚了多少钱”... 当新质生产力积厚成势,成为引领中国经济高质量发展的强大新引擎,中国资本市场的科技叙事逻辑更加清晰和具...
告别传统赏花!在黄浦,这十二座... (来源:上观新闻)2026年的春天,上海的城市公共空间里绽放出一片与众不同的春日胜景。新天地绿地里造...