下面由centos教學專欄為大家介紹關於centos7 fastdfs部署,希望對需要的朋友有幫助!
centos7 fastdfs部署
### start from here ## 前置准备依赖c++ : yum -y install libevent libevent-devel perl make gcc zlib zlib-devel pcre pcre-devel gcc-c++ openssl-devel
1.安裝libfastcommon
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.43.tar.gz mv V1.0.43.tar.gz libfastcommon-1.0.43.tar.gz && tar -xvf libfastcommon-1.0.43.tar.gz cd libfastcommon-1.0.43 && ./make.sh && ./make.sh install
2.安裝fastdfs # 注意conf 的mine.types和http.conf 一定要複製過去,其次下載本版本建議6.x不然安裝會有相容問題
wget https://github.com/happyfish100/fastdfs/archive/V6.06.tar.gz mv V6.06.tar.gz fdfs6.06.tar.gz && tar -xvf fdfs6.06.tar.gz cd cd fastdfs-6.06 && ./make.sh && ./make.sh install cp -r conf/* /etc/fdfs && rm -f *.sample . 在$base_path 下新建data 和logs目录(存储trackerd.log 和storaged.log) cd $base_path && mkdir -p data && mkdir logs
3.修改設定
## 1 .修改vi tracker.confport=22122 # tracker服务器端口(默认22122,一般不修改) base_path=/etc/fdfs # 存储日志和数据的根目录
port=23000 # storage服务端口(默认23000,一般不修改) base_path=/etc/fdfs # 数据和日志文件存储根目录 store_path0=/etc/fdfs # 第一个存储目录 tracker_server=192.168.110.151:22122 # tracker也就是fdfs服务器IP和端口 http.server_port=8888 # http访问文件的端口(默认8888,看情况修改,和nginx中保持一致)
base_path=/etc/fdfs tracker_server=192.168.110.151:22122 #tracker服务器IP和端口
sh fastfdfs_services.sh
/etc/init.d/fdfs_trackerd start/stop/restart /etc/init.d/fdfs_storaged start/stop/restart
/usr/bin/fdfs_test /etc/fdfs/client.conf upload $filename
example file url: http://192.168.110.151/group1/M00/00/00/wKhul1-qhhKAO3ywAAABcxvxSxw5288_big.jpg
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
vim /etc/fdfs/mod_fastdfs.conf tracker_server=192.168.0.104:22122 #tracker服务器IP和端口 url_have_group_name=true store_path0=/home/dfs
## 安裝nginx:
wget http://nginx.org/download/nginx-1.15.4.tar.gz #下载nginx压缩包 tar -zxvf nginx-1.15.4.tar.gz cd nginx-1.15.4/ ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ # 添加fastdfs-nginx-module模块 make && make install
#
7.2#設定nginx.config
touch /usr/local/nginx/logs/nginx.pid && chmod a+w /usr/local/nginx/logs/nginx.pid vim /usr/local/nginx/conf/nginx.conf #添加如下配置 pid /usr/local/nginx/logs/nginx.pid; server { listen 8888; ## 该端口为storage.conf中的http.server_port相同 server_name 192.168.110.151; location ~/group[0-9]/ { ngx_fastdfs_module; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
8.關閉防火牆:systemctl stop firewalld.service 9.nginx 啟動停止
./nginx -c /usr/local/nginx/conf/nginx.conf # 根据配置启动 /usr/local/nginx/sbin/nginx #启动nginx /usr/local/nginx/sbin/nginx -s reload #重启nginx /usr/local/nginx/sbin/nginx -s stop #停止nginx
nginx访问 访问:http://192.168.0.104:8888/group1/M00/00/00/wKgAaFyMoNKAUNcVAAWjVxW4v70993.jpg
以上是關於centos7 fastdfs部署的詳細內容。更多資訊請關注PHP中文網其他相關文章!