centos7.7(7.9)部署fastdfs(亲测有效)

#关闭防火墙

systemctl enable firewalld.service

systemctl stop firewalld.service

setenforce 0

#更新yum资源

yum update -y

#依赖安装

yum install  gcc-c++ pcre pcre-devel openssl ssl-devel perl-devel libevent libevent-devel -y

#下载和安装FastDFS依赖包libfastcommon

cd /usr/local/src

wget https://github.com/happyfish100/libfastcommon/archive/V1.0.38.tar.gz

tar xf V1.0.38.tar.gz

cd libfastcommon-1.0.38/

./make.sh

./make.sh install

#下载和安装FastDFS

cd /usr/local/src

wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz

tar -zxvf V5.11.tar.gz

cd fastdfs-5.11/

./make.sh

.make.sh install

#将配置文件复制到系统为fdfs预设的目录

cd /usr/local/src/fastdfs-5.11/conf

cp mime.types http.conf /etc/fdfs/

#查看安装FastDFS过程中产生的可执行文件。

ls -la /usr/bin/fdfs*

#创建目录

mkdir /home/fastdfs/tracker -p

mkdir /home/fastdfs/storage -p

#配置tracker

cd /etc/fdfs/

cp tracker.conf.sample tracker.conf

sed -i "s/base_path\=\/home\/yuqing\/fastdfs/base_path\=\/home\/fastdfs\/tracker/g" /etc/fdfs/tracker.conf

sed -i "s/http.server_port\=8080/http.server_port\=80/g" /etc/fdfs/tracker.conf

sed -i "s/thread_stack_size \= 64KB/thread_stack_size \= 128KB/g" /etc/fdfs/tracker.conf

#启动tracker

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start

#开机启动tracker

echo '/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart' >> /etc/rc.d/rc.local

#配置storage,ip addr 改为服务器ip(局域网ip)

cd /etc/fdfs/

cp storage.conf.sample storage.conf

sed -i "s/base_path\=\/home\/yuqing\/fastdfs/base_path\=\/home\/fastdfs\/storage/g" /etc/fdfs/storage.conf

sed -i "s/store_path0\=\/home\/yuqing\/fastdfs/store_path0\=\/home\/fastdfs\/storage/g" /etc/fdfs/storage.conf

sed -i "s/http.server_port\=8888/http.server_port\=80/g" /etc/fdfs/storage.conf

sed -i "s/tracker_server\=192.168.209.121:22122/tracker_server\=ip addr:22122/g" /etc/fdfs/storage.conf

#启动storage

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

#开机启动storage

echo '/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart' >> /etc/rc.d/rc.local

#查看storage启动日志。

#tail -f /home/fastdfs/storage/logs/storaged.log

#配置client,ip addr 改为服务器ip(局域网ip)

cd /etc/fdfs/

cp client.conf.sample client.conf

sed -i "s/base_path\=\/home\/yuqing\/fastdfs/base_path\=\/home\/fastdfs\/tracker/g" /etc/fdfs/client.conf

sed -i "s/tracker_server\=192.168.0.197:22122/tracker_server\=ip addr:22122/g" /etc/fdfs/client.conf

#下载、安装和配置fastdfs-nginx-module

cd /usr/local/src

wget  https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz

tar -zxvf V1.20.tar.gz

cd /usr/local/src/fastdfs-nginx-module-1.20/src/

echo -e 'ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"' >>config

echo -e 'CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"' >>config

#配置fastdfs-nginx-module的“mod_fastdfs.conf”文件

cp /usr/local/src/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf /etc/fdfs/

sed -i "s/base_path\=\/tmp/base_path\=\/home\/fastdfs/g" /etc/fdfs/mod_fastdfs.conf

sed -i "s/store_path0\=\/home\/yuqing\/fastdfs/store_path0\=\/home\/fastdfs\/storage/g" /etc/fdfs/mod_fastdfs.conf

sed -i "s/tracker_server\=tracker:22122/tracker_server\=localhost:22122/g" /etc/fdfs/mod_fastdfs.conf

sed -i "s/url_have_group_name \= false/url_have_group_name \= true/g" /etc/fdfs/mod_fastdfs.conf

#下载和安装Nginx

cd /usr/local/src/

wget http://nginx.org/download/nginx-1.15.2.tar.gz

tar -zxvf nginx-1.15.2.tar.gz

cd nginx-1.15.2

./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/fastdfs-nginx-module-1.20/src/

make &&make install

#设置nginx文件读取权限

chown -R root.root /home/fastdfs/storage/data

chmod -R 655 /home/fastdfs/storage/data/

#配置Nginx

cd /usr/local/nginx/conf/

sed -i "56a location ~/M00 {" nginx.conf

sed -i "57a root  /home/fastdfs/storage/data;" nginx.conf

sed -i "58a ngx_fastdfs_module;" nginx.conf

sed -i "59a }" nginx.conf

#启动nginx

/usr/local/nginx/sbin/nginx &

#开机启动nginx

cd /lib/systemd/system

#mv nginx.service nginx.service.bak

cp -r /usr/local/src/nginx.service .

systemctl enable nginx.service

#生成测试文件

cd /usr/local/src

touch aa.txt

echo -e "ezhoueryuan test fastdfs ok" >>aa.txt

#生成文件链接

/usr/bin/fdfs_upload_file  /etc/fdfs/client.conf aa.txt

你可能感兴趣的:(centos7.7(7.9)部署fastdfs(亲测有效))