Because the company Ali server changes several times, manually deployed several times Fastdfs+nginx, so think of the automated deployment, the following is the script content, because just want to implement the function, has not completed the complete judgment logic;
The following is Ansible-playbook and shell and template Nginx-fastdfs and dynamic thumbnail configuration;
If there are errors, please advise;
----Hosts:apollo # VARs: # filedest:/usr/local/tasks:-name:prepare fastdfs-nginx-module Copy : src=/etc/ansible/fastdfs-nginx-module_v1.16.tar.gz dest=/usr/local/-name:prepare nginx-1.12.0.tar.gz Copy : src=/etc/ansible/nginx-1.12.0.tar.gz dest=/usr/local/-Name:prepare v5.05.tar.gz copy:src=/etc/ansible/v5 .05.tar.gz dest=/usr/local/-Name:gcc,git,openssl-devel,pcre-devel,gd-devel Yum:name=gcc,git,openssl-deve L,pcre-devel,gd-devel State=present-name:push Fastdfs-nginx-module-config Copy:src=/etc/ansible/fastdfs_ng inx.conf dest=/usr/local/-name:create user www user:name=www shell=/sbin/nologin-name:unzip packag ES and make install ... script:/etc/ansible/install_fastdfs.sh-name:delete fastdfs-nginx-module fil e:name=/usr/local/fastdfs-nginx-module_v1.16.tar.gz State=absent-name:delete nginx-1.12.0.tar.gz File:nam e=/usr/local/nginx-1.12.0.tar.gz state=absent-name:delete v5.05.tar.gz file:name=/usr/local/v5.05.tar.gz state=absent
The following is the Shell section
#!/usr/bin/env bashset-x set-e ifs=$ ' \ n ' dest=/usr/local/fastdfsgz= "v5.05.tar.gz" fastdfsmod= "Fastdfs-nginx-module_ V1.16.tar.gz "nginxgz=" nginx-1.12.0.tar.gz "ip=$ (IP a s eth0 | grep" Inet "| awk ' {print $} ' | Sed-r "s/\/24//g") for GZ in ${dest}${fastdfsgz} ${dest}${fastdfsmod} ${dest}${nginxgz}dotar XF $gz-C ${dest}done####### #安装libfastcd ${dest}git clone Https://github.com/happyfish100/libfastcommon.gitcd libfastcommon./make.sh && ./make.sh Install ########### #更改fastdfs-nginx-module/src/configsed-ri "4s/local\///g" ${dest}fastdfs-nginx-module/ src/config################# #安装fastdfscd ${dest}fastdfs-5.05/./make.sh &&/make.sh Install & wait CP conf/ HTTP.CONF/ETC/FDFS/CP conf/mime.types/etc/fdfs/cd/etc/fdfs/for filename in client.conf.sample storage.conf.sample TRACKER.CONF.SAMPLEDOCP ${filename} ${filename/.sample/}sed-ri "s/base_path=/#base_path =/g" ${filename/.sample} Donemkdir-p/HOME/FAST/CLIENT/HOME/FAST/TRACKER/HOME/FAST/STORAGE/DATACP ${dest}fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfssed-ri "/^connect_timeout/cconnect_timeout = ten"/etc/fdfs/mod_ Fastdfs.confsed-ri "/^tracker_server/ctracker_server=${ip}:22122"/etc/fdfs/mod_fastdfs.confsed-ri "/^url_have_ Group_name/curl_have_group_name=true "/etc/fdfs/mod_fastdfs.confsed-ri"/^store_path0=/cstore_path0=\/home\/fast \/storage\/data "/etc/fdfs/mod_fastdfs.conf## #tracker. Confsed-ri"/#base_path =/abase_path=\/home\/fast\/tracker " tracker.conf### #client. Confsed-ri "/#base_path =/abase_path=\/home\/fast\/client" Client.confsed-ri "S/tracker_ server=/#tracker_server =/g "Client.confsed-ri"/#tracker_server =/atracker_server=${ip}:22122 "client.conf#### Storage.confsed-ri "/#base_path =/abase_path=\/home\/fast\/storage" Storage.confsed-ri "s/tracker_server=/#tracker _server=/g "Storage.confsed-ri"/#tracker_server =/atracker_server=${ip}:22122 "Storage.confsed-ri"/store_path0=/ Cstore_path0=\/home\/fast\/storage\/data "storage.conf########### #编译nginx CD ${dest}nginx-1.12.0./COnfigure--user=www--group=www--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_sub_module-- With-http_ssl_module--with-pcre--add-module=/usr/local/fastdfs-nginx-module/src/--with-http_image_filter_ Module & #--add-module=/usr/local/nginx-rtmp-module & waitmake && make install & waitif [-D ${dest}/ NGINX/CONF.D];thenmv ${dest}fastdfs_nginx.conf ${dest}/nginx/conf.d/elsemkdir ${DEST}/NGINX/CONF.DMV ${dest} fastdfs_nginx.conf ${dest}/nginx/conf.d/ficd/usr/local/nginx/conf.d/for rows in $ (TAC./fastdfs_nginx.conf) Dosed-ri "40a$rows"/usr/local/nginx/conf/nginx.confdone ############/usr/local/nginx/sbin/nginx-t
The following is the Nginx dynamic scaling configuration and Web page
Location ~/group[0-9]/m00/(. +) _ ([0-9]+) x ([0-9]+) \. (jpg|gif|png) { ngx_fastdfs_module; Index index.html index.htm; Set $w $; Set $h $ A; if ($w! = "0") { rewrite group1/m00 (. +) _ (\d+) x (\d+) \. ( Jpg|gif|png) $ group1/m00$1.$4 break; if ($h! = "0") { rewrite group1/m00 (. +) _ (\d+) x (\d+) \. ( Jpg|gif|png) $ group1/m00$1.$4 break; Image_filter resize $w $h; Image_filter_buffer 5M;} Location ~/group[0-9] { ngx_fastdfs_module; Index index.html index.htm;} Location =/favicon.ico { log_not_found off; Access_log off;}
After the final installation is complete, Fastdfs is not started, please run command start fastdfs:fdfs_trackerd/etc/fdfs/tracker.conf && fdfs_storaged/etc/fdfs/ Storage.conf
After the boot is completed, if you do not have access to return 415, copy and paste the template contents into the Nginx configuration file;
Ansible + Shell Implementation Fastdfs+nginx implement picture Server and provide dynamic zoom function;