#!/bin/bash# lty 20180116# fastdfs install scriptif [ ' Id -u ' -ne 0 ];then echo "Non-root user, script exit" exit 0fiif [ ! -f "/root/soft/fastdfs_install.sh" ];then echo " Reinstall the installation script side after the/root/soft directory. "Fiinstall_fdfs () {cd /root/softwget https://codeload.github.com/happyfish100/libfastcommon/zip/ master -o libfastcommon-master.zipif [ ! -f "Libfastcommon-master.zip" ]; then echo "Download Libfastcommon-master.zip error" && exit 1 fiunzip libfastcommon-master.zipcd libfastcommon-master/sh ./make.shsh ./make.sh INSTALLCD&NBSP, .... wget http://jaist.dl.sourceforge.net/project/fastdfs/fastdfs%20server%20source%20code/fastdfs%20server% 20with%20php%20extension%20source%20code%20v5.08/fastdfs_v5.08.tar.gzif [ ! -f "fastdfs_v5.08.tar.gz" ];then echo "Download fastdfs_v5.08.tar.gz error" && exit 1fitar xf fastdfs_v5.08.tar.gzcd fastdfssh ./make.shsh ./make.sh installcd /etc/fdfs/cp storage.conf.sample storage.confcp tracker.conf.sample tracker.confcp client.conf.sample client.confmkdir -p /data/fastdfssed -i "[ Email protected]/home/yuqing/@/data/@g " ./*f}install_nginx () {cd /root/softwget http:// Nchc.dl.sourceforge.net/project/fastdfs/fastdfs%20nginx%20module%20source%20code/fastdfs-nginx-module_ v1.16.tar.gzif [ ! -f "Fastdfs-nginx-module_v1.16.tar.gz" ];then echo "Download fastdfs-nginx-module_v1.16.tar.gz error" Fi tar xf fastdfs-nginx-module_ v1.16.tar.gz cd fastdfs-nginx-module/src/sed -i "[Email protected]/usr/local/@/usr/@g config# or manually edit the Vim config,/usR/local to/usr, execute:%s+/usr/local/+/usr/+g command to bulk replace and save exit \cp mod_fastdfs.conf /etc/fdfs/# Start configuring fastdfsipline= ' ip addr | grep -e ' inet 172|inet 192|inet 10 ' | awk -f ' [/] ' ' {print$1} ' | awk ' {print$2} ' |wc -l ' if [ $ ipline -gt 1 ];thenecho "This machine has multiple intranet IPs, please manually configure the/etc/fdfs/mod_fastdfs.conf tracker_server items" elif [ $IPLINE -eq 1 ];thenip= ' ip addr | grep -e ' inet 172| Inet 192|inet 10 ' | awk -f ' [/] ' ' {print$1} ' | awk ' {print$2} ' sed -i "[email protected]:[email protected] $IP: [email protected]" /etc/fdfs/mod_ fastdfs.confsed -i "[email protected]@[email protected]" /etc/fdfs/*confsed -i "[email protected]@[email protected]" /etc/fdfs/*confelseecho "native intranet IP not detected, please manually configure/etc/ Fdfs/mod_fastdfs.conf's tracker_sErver item "fised -i " [email protected]_have_group_name = [email protected]_have_ Group_name = [email protected] " /etc/fdfs/mod_fastdfs.confsed -i " [email Protected]/[email protected]@g " /etc/fdfs/*conf# need to check for system installed nginxnginx_proc= ' ps -ef | grep nginx | grep -v grep ' if [ $NGINX _proc ];thenecho " The nginx process is present and the Nginx installation will be skipped. Please manually configure the nginx.conf "returnficd /root/softyum install -y pcre-devel zlib-develwget http://nginx.org/download/nginx-1.12.2.tar.gzif [ ! -f "Nginx-1.12.2.tar.gz" ];then echo "Download nginx-1.12.2.tar.gz error" && exit 1fitar xf nginx-1.12.2.tar.gzcd nginx-1.12.2./configure --prefix=/apps/nginx/ --add-module=. /fastdfs-nginx-module/src/makemake installcd /apps/nginx/confcat > /apps/nginx/conf/ Nginx.conf <&lT Eof user root; worker_ Processes 1; events { worker_ connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; client_max_body_size 300m; keepalive_ timeout 65; server { listen 80; server_name localhost; location ~/group[0-9]/ { ngx_fastdfs_module; } error_ page 500 502 503 504 /50x.html; location = /50x.html { #root html; } } }eof\ cp /apps/nginx/conf/mime.types /etc/fdfs/\cp /root/soft/fastdfs/conf/http.conf /etc/fdfs/} # Start Start_service() {fdfs_storaged /etc/fdfs/storage.conffdfs_trackerd /etc/fdfs/tracker.confln -s /data/ fastdfs/data/ /data/fastdfs/data/m00/apps/nginx/sbin/nginxecho "Fdfs, Nginx installation completed, start success" Ps -ef | grep -E "Nginx|fdfs" | grep -v grep}install_fdfs | | exit 1install_nginx| | exit 1start_service| | exit 1exit 0
One-click installation of Nginx and FSFS Distributed file storage shell scripts