一分钟安装fastDFS(脚本自动自动化安装)

2020-12-31 16:20:27 浏览数 (3)

以下脚本是我自己亲自编写,亲自测试过的,请尊重别让的劳动成果。

目前脚本只对centos安装 如果是ubuntu系统可以自己把yum下载依赖改成apt-get即可,很简单。

1.从码云拉去安装脚本和安装文件下载到服务器

代码语言:javascript复制
git clone https://gitee.com/xinoso/fast-dfs.git

2.执行脚本开始安装

代码语言:javascript复制
sh fastdfs.sh
代码语言:javascript复制
#!/bin/sh
a=`uname  -a`
tracker_server_ip="10.206.0.17"
b="Darwin"
c="centos"
d="ubuntu"

function init() {
     mkdir sudo mkdir -p /data/fdfs/tracker
     mkdir sudo mkdir -p /data/fdfs/stroage
     tar -zxvf fastDFS-all.tar.gz
     unzip libfastcommon-master.zip
     cd libfastcommon-master/
     sudo ./make.sh && ./make.sh install
     cd ..
     tar -zxvf FastDFS_v5.08.tar.gz
     cd FastDFS
     sudo ./make.sh && ./make.sh install
     cd ..
     ll /etc/init.d/ | grep fdfs
     cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
     cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
     cp FastDFS/conf/client.conf /etc/fdfs/
     sed -i '22c base_path=/data/fdfs/tracker' /etc/fdfs/tracker.conf
     sed -i '41c base_path=/data/fdfs/stroage' /etc/fdfs/storage.conf
     sed -i '109c store_path0=/data/fdfs/stroage' /etc/fdfs/storage.conf
     sed -i '118c tracker_server='$tracker_server_ip':22122' /etc/fdfs/storage.conf
     sudo service fdfs_trackerd start
     sudo chkconfig fdfs_trackerd on
     sudo service fdfs_storaged start
     sudo chkconfig fdfs_storaged on
     tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
     sed -i 's/usr/local/usr/g' fastdfs-nginx-module/src/config
     cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
     sed -i '10c base_path=/data/fdfs/stroage' /etc/fdfs/client.conf
     sed -i '14c tracker_server='$tracker_server_ip':22122' /etc/fdfs/client.conf
     sed -i '40c tracker_server='$tracker_server_ip':22122' /etc/fdfs/mod_fastdfs.conf
     sed -i '53c url_have_group_name=true' /etc/fdfs/mod_fastdfs.conf
     sed -i '41c store_path0=/data/fdfs/stroage' /etc/fdfs/mod_fastdfs.conf
     sed -i '62c store_path0=/data/fdfs/stroage' /etc/fdfs/mod_fastdfs.conf
     cp FastDFS/conf/mime.types  /etc/fdfs/
     cp FastDFS/conf/http.conf  /etc/fdfs/

     tar -zxvf nginx-1.10.0.tar.gz
     cd nginx-1.10.0/
     sudo ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx --add-module=../fastdfs-nginx-module/src
     sudo make && sudo make install
     sed -i '40a location ~/group([0-9])/ { n ngx_fastdfs_module; n }' /opt/nginx/conf/nginx.conf
     nginx
}
#centos系统
function centOs() {
     sudo yum -y install gcc
     sudo yum install -y unzip zip
     sudo yum -y install libevent
     sudo yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
}

if [[ $a =~ $b ]];then
    echo "mac"
elif [[ $a =~ $c ]];then
  echo "centos系统";
  centOs;
elif [[ $a =~ $d ]];then
    sudo apt-get install –y git
else
    echo $a
fi
init;

3.执行完脚本查看是否安装成功

代码语言:javascript复制
ps -ef |grep fdfs

用脚本安装是不是非常简单,如果安装时候遇到任何错误欢迎大家留言提问,一般不会出现错误的。

0 人点赞