nginx安装源代码

centos7 下载nginx源码包的代码,有些地方可能会停下,重跑一次有可能解决问题
下文中的ip需要改成自己的。

#!/bin/bash
if test -e /etc/yum.repos.d/base.repo
then
	echo "base.repo is existed"
else
	wget -O /etc/yum.repos.d/base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
	echo "base.repo is installing..."
fi
 yum makecache &>/dev/null
if test $? -eq 0
then
	echo "yum is ok"
else
	echo "yum is not ready"
	exit
fi
if yum -y install pcre-devel openssl-devel elinks  gcc gcc-c++  make zlib-devel psmisc
then
	echo "soft is ok "
else
	echo "soft is bad"
	exit
fi

ip=10.0.112.148
address=http://nginx.org/download/nginx-1.14.2.tar.gz
add=`echo $address| awk -F"/" '{print $NF}'`
name=nginx
echo ##################################
if ! id $name &>/dev/null
then 
	useradd  $name
fi
mkdir -p /var/tmp/$name/{client,proxy,fastcgi,uwsgi,scgi}
chown nginx.nginx /var/tmp/$name/{client,proxy,fastcgi,uwsgi,scgi}
if test $? -eq 0 &>/dev/null
then
	echo “文件建好了”
else
	echo "文件创建出现问题" 
	exit
fi
echo #########################################
wget $address -P /usr/local/src/
cd /usr/local/src
tar xf $add 
if test -d $dir &>/dev/null
then 
	echo "$name 包已解压完成"
else
	echo "$name 包解压失败"
	exit
fi
dir=`ls -l /usr/local/src/ |grep nginx |head -1|awk  '{print $NF}'`
cd /usr/local/src/$dir
sh `cat <<EOF
configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_sub_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_realip_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi  --with-pcre --with-file-aio --with-http_secure_link_module 
EOF`
if test $? -eq 0 &> /dev/null
then
	echo "\./configure 完成"
else
	echo "\./configure 失败"
	exit
fi
echo #################################
make && make install
if test $? -eq 0 &> /dev/null
then
	echo "make is ok"
else
	echo "make is not"
	exit
fi
echo ####################################
/usr/local/nginx/sbin/nginx 
echo \/usr/local/nginx/sbin/nginx >> /etc/rc.d/rc.local
chmod a+x  /etc/rc.d/rc.local
killall $name
while test $? -eq 0 &> /dev/null
do
	killall $name
done
systemctl restart rc-local
systemctl enable rc-local
echo ############################333
ss -ant |grep :80 &>/dev/null
if test $? -eq 0 &> /dev/null
then
	echo "nginx is ok"
else
	echo "nginxis not"
	exit
fi
echo welcome to $name > /usr/local/nginx/html/index.html
elinks --dump $ip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值