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

相关内容

热门资讯

中科飞测股价涨5.06%,天弘... 2月3日,中科飞测涨5.06%,截至发稿,报187.00元/股,成交8.01亿元,换手率1.76%,...
中科飞测股价涨5.06%,申万... 2月3日,中科飞测涨5.06%,截至发稿,报187.00元/股,成交8.01亿元,换手率1.76%,...
中科飞测股价涨5.06%,银华... 2月3日,中科飞测涨5.06%,截至发稿,报187.00元/股,成交8.02亿元,换手率1.76%,...
中科飞测股价涨5.06%,信达... 2月3日,中科飞测涨5.06%,截至发稿,报187.00元/股,成交8.04亿元,换手率1.76%,...
旗滨集团股价涨5.25%,华夏... 2月3日,旗滨集团涨5.25%,截至发稿,报7.02元/股,成交3.37亿元,换手率1.66%,总市...