ansible安装nginx脚本
2020-07-23 00:54
281 查看
要求:ansible结合shell自动部署nginx
[root@master ~]# cat auto_install_nginx.sh #!/bin/bash NGINX_P="/opt/nginx/" NGINX_T="/usr/local/nginx/" function nginx_evn(){ yum install gcc gcc-c++ pcre pcre-devel zlib zlib-devel mysql-devel curl-devle wget openssl openssl-devel -y rm -rf ${NGINX_P} mkdir -p ${NGINX_P} wget -O ${NGINX_P}nginx-1.14.2.tar.gz http://nginx.org/download/nginx-1.14.2.tar.gz sed -i '7s/enforcing/disabled/g' /etc/selinux/config timedatectl set-timezone Asia/Shanghai >/dev/null systemctl stop firewalld.service >/dev/null systemctl disable firewalld.service >/dev/null chmod 755 -R ${NGINX_P} } function install_nginx(){ rm -rf ${NGINX_T} >/dev/null mkdir -p ${NGINX_T} tar -zxvf ${NGINX_P}`ls ${NGINX_P}|grep nginx` -C ${NGINX_T} cd ${NGINX_T}`ls ${NGINX_T}` ./configure \ --prefix=${NGINX_T} \ --with-http_dav_module \ --with-http_stub_status_module \ --with-http_addition_module \ --with-http_sub_module \ --with-http_flv_module \ --with-http_mp4_module declare -i n=`cat /proc/cpuinfo| grep "physical id"|sort|wc -l` make -j ${n} make install } function startup(){ cd ${NGINX_T} cd sbin ./nginx -t ./nginx echo "NGINX首页访问" curl localhost } function auto_install(){ NUM="`ps -ef|grep "nginx"|grep -v grep|grep -v ${0}|wc -l`" #特别注意grep -v ${0}将脚本过滤,不然脚本名称包含NGINX会被统计进来 if [ $NUM -gt 0 ]; then echo "nginx existed and seccessful to start" exit else nginx_evn install_nginx startup fi } function main(){ case $1 in start) auto_install ;; *) echo "Usage:$0 [start]" esac } main $1 [root@master ~]#
相关文章推荐
- Ansible自动化安装nginx
- 【转】linux 编译安装nginx,配置自启动脚本
- RHEL6编译安装nginx、开机启动脚本
- nginx在windows下的安装,以及编写启动关闭nginx等操作的脚本
- nginx快速执行安装脚本
- Debian 8.2 64位 Nginx PHP MySQL Java Tomcat安装脚本
- nginx编译安装脚本
- Ansible 一键配置安装Keepalived+Nginx作为前端,httpd+php作为后端
- nginx安装脚本
- php+nginx自动编译安装脚本
- 使用 ansible 安装 NGINX 和 NGINX Plus
- RHEL6编译安装nginx、开机启动脚本、重新编译、安装配置naxsi waf防火墙
- linux编写最基本.sh脚本(脚本安装swk-nginx)
- CentOS下nginx一键安装shell脚本
- 一键安装nginx和fsfs分布式文件存储shell脚本
- centos7 lamp+nginx搭建(附自动安装脚本)
- nginx用lua脚本读取redis(安装篇)
- 运维自动化之ansible playbook安装nginx
- nginx编译安装脚本
- nginx安装脚本