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 会显示刚刚上传的图片
 

相关内容

热门资讯

大雪和火锅更配,年轻人爱上吃清... 转自:贝壳财经 【#大雪和火锅更配#,#年轻人爱上吃清淡...
伦敦希思罗机场多人遭喷雾袭击受... 【#伦敦希思罗机场多人遭喷雾袭击受伤#】#通往希思罗机场铁路线已重新开放#伦敦警方称,多名男子用类似...
首批北证50成份指数基金面市三... Wind数据显示,截至12月5日,于2022年12月成立的首批8只北证50成份指数型基金,成立以来的...
奇点资本副总裁王苒:财务投资和... 奇点资本副总裁王苒表示,历经萌芽起步、高速发展后的创投行业,近年来正处于结构调整期,一个比较明显的变...
成交活跃度走高,创业板指估值领... (来源:一观大势)作者:方奕/李健核心观点:上周(2025/12/1-2025/12/5)成交活跃度...