ubuntu18.04自动安装nginx脚本

#!/bin/bash
nginxTargz="/home/nginx/software/nginx/nginx-1.12.1.tar.gz"
checkExist(){
        if [ -e "/usr/local/nginx" ];then
                echo "Nginx已安装..."
		exit
        fi
}
checkExist
# 查询是否有
if [ -e $nginxTargz ];
then
	cd /home/nginx/software/nginx
	if [ -e "/home/nginx/software/nginx/pcre-8.38" ];then
                echo "存在该文件夹,删除..."
                rm -rf /home/nginx/software/nginx/pcre-8.38
        fi
        echo "1.安装pcre..."
	tar -xvf pcre-8.38.tar
	cd pcre-8.38
	./configure  
	make  
	make install

	echo "2.安装zlib..."
	cd /home/nginx/software/nginx	
	if [ -e "/home/nginx/software/nginx/zlib-1.2.11" ];then
                echo "存在该文件夹,删除..."
                rm -rf /home/nginx/software/nginx/zlib-1.2.11
        fi
	tar -xvf zlib-1.2.11.tar
	cd zlib-1.2.11
	./configure  
	make  
	make install
        echo "3.安装openssl-1.0.2n..."
	cd /home/nginx/software/nginx  
        if [ -e "/home/nginx/software/nginx/openssl-1.0.2n" ];then
                echo "存在该文件夹,删除..."
                rm -rf /home/nginx/software/nginx/openssl-1.0.2n
        fi
	tar -xvf openssl-1.0.2n.tar
	cd openssl-1.0.2n
	./config 
	make  
	make install	

	echo "4.FastDFS的nginx模块安装..."
	cd /home/nginx/software/fastdfs
	if [ -e "/home/nginx/software/fastdfs/fastdfs-nginx-module-master" ];then
                echo "存在该文件夹,删除..."
                rm -rf /home/nginx/software/fastdfs/fastdfs-nginx-module-master
        fi
	unzip fastdfs-nginx-module-master.zip
	cd fastdfs-nginx-module-master/src
	sed -i 's#ngx_module_incs="/usr/local/include"#ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"#' /home/nginx/software/fastdfs/fastdfs-nginx-module-master/src/config
	sed -i 's#CORE_INCS="$CORE_INCS /usr/local/include"#CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"#' /home/nginx/software/fastdfs/fastdfs-nginx-module-master/src/config
	echo "5.nginx安装..."
	cd /home/nginx/software/nginx
	if [ -e "/home/nginx/software/nginx/nginx-1.12.1" ];then
                echo "存在该文件夹,删除..."
		rm -fr   /home/nginx/software/nginx/nginx-1.12.1
	fi
	tar -zxvf nginx-1.12.1.tar.gz
	cd nginx-1.12.1
	./configure --prefix=/usr/local/nginx --add-module=/home/nginx/software/fastdfs/fastdfs-nginx-module-master/src
	sed -i 's# -Wno-unused-parameter -Werror -g# -Wno-unused-parameter -g#' /home/nginx/software/nginx/nginx-1.12.1/objs/Makefile
	make
	make install
	if [ -e "/usr/local/nginx/conf/" ];then
		echo "存在该文件夹,不创建"
        else 
		mkdir -p /usr/local/nginx/conf/
	fi
	cp /home/nginx/conf/nginx.conf /usr/local/nginx/conf/
	/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 

fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值