Maple City Prodigal Original, reproduced please indicate the source!
For more technical blog posts, see Personal blog: https://fengchenglangzi.000webhostapp.com
bh19890922
QQ445718526, 490425557
650) this.width=650; "Src=" https://fengchenglangzi.000webhostapp.com/wp-content/uploads/2017/08/083017_0600_ Shellnginx1.png "style=" Padding:0px;margin:0px;border:0px;height:auto; "/>
#!/bin/bash#2017-8-29 16:07:07#by fengchenglangzi#auto install nginx and vhost## ################# #定义变量SOFT_DIR = "/usr/local/src" nginx_dir= "/usr/local/nginx" nginx_soft= "nginx-1.12.0.tar.gz" nginx_soft_name=$ (echo $NGINX _soft|awk -f ". Tar" ' {print $1} ') yum= "yum install -y "Pcre_gcc=" Gcc gcc-c++ pcre pcre-devel openssl-devel "################### #安装Nginxfunction Install_Nginx () { if [ ! -d $NGINX _dir ];then $YUM $PCRE _gcc cd $SOFT _dir if [ ! -d $SOFT _dir/$NGINX _soft_name ];then &nbSp; wget -c http://nginx.org/download/$NGINX _soft tar -zxf $ Nginx_soft fi cd $NGINX _soft_name sed -i -e ' s/1.12.0//g ' -e ' s/nginx\//jws/g ' -e ' s/' nginx '/' JWS '/g ' src/ core/nginx.h useradd nginx;usermod -s /sbin/nologin nginx &nBsp; ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module && make -j8 && make install -j8 if [ $? -eq 0 ];then echo "Nginx installation is complete!!! " /usr/local/nginx/sbin/nginx fi else echo "Nginx is installed!!! " fi}#################### #创建虚拟主机function create_vhost () { if [ ! -d $NGINX _dir ] ; Then echo "The current system is not installed Nginx, please first install nginx!!! " else read -p "Please enter a new virtual host domain name:" input domain_name= ($ (echo $input)) i=0 while [[ $ i < ${#DOMAIN_NAME [@]} ]] do if [ ! -d $NGINX _dir/conf/vhost/${domain_name[i]} ];then mkdir -p $ nginx_dir/conf/vhost/${domain_name[i]}/{logs,html} touch $NGINX _dir/conf/vhost/${domain_name[i]}/nginx.conf sed -i "/include * mime.types/a\include $NGINX _dir\/conf\/vhost\/${domain_name[i]}/nginx.conf; " $NGINX _dir/conf/nginx.confcat >> $NGINX _dir/conf/vhost/${domain_name[i]}/nginx.conf << EOFserver { listen 80; server_name ${DOMAIN_NAME[i]}; access_log $NGINX _dir/conf/vhost/${domain_name[i]}/logs/access.log; location / { root $NGINX _dir/conf/vhost/${domain_name[i]}/html/; index index.html index.htm; }}EOFcat >> $NGINX _dir/conf/vhost/${domain_name[i]}/html/ index.html << eof<! Doctype html>
This article is from the "Maple City Prodigal" blog, please be sure to keep this source http://fengchenglangzi.blog.51cto.com/1322043/1961308
SHELL automatically deploys nginx and sets up a virtual host