虚拟化容器,大数据,DBA,中间件,监控。

Shell 配置Nginx虚拟主机脚本

20 12月
作者:admin|分类:脚本编程
#!/bin/bash
nginx_src="/usr/src"
nginx_dir="/usr/local/nginx"
nginx_url="http://nginx.org/download"
nginx_ver="1.16.0"
nginx_soft="nginx-${nginx_ver}.tar.gz"
nginx_args="--prefix=${nginx_dir} --user=nginx --group=nginx --with-http_stub_status_module"
 
 
yum install gcc pcre pcre-devel zlib zlib-devel wget make openssl-devel net-tools -y
sed -i 's/enforcing/disabled/g' /etc/selinux/config
systemctl stop firewalld.service
 
cd $nginx_src
wget -c $nginx_url/$nginx_soft
tar xf $nginx_soft
cd nginx-${nginx_ver}
 
useradd -s /sbin/nologin nginx
./configure $nginx_args
 
make&&make install
$nginx_dir/sbin/nginx
ps -ef | grep nginx | grep -v grep
echo -e "\033[32m-----------------config Nginx vhost now------------------------------\033[0m"

#config Nginx vhost 

cd $nginx_dir/conf
\cp nginx.conf nginx.conf.bak
\cp $nginx_src/nginx-${nginx_ver}/conf/nginx.conf $nginx_dir/conf

sed -i -e '/#/d' -e '/^$/d' -e '/server/,$d'  nginx.conf
echo -e "include /usr/local/nginx/conf/vhosts/*.conf; \n}" >>nginx.conf

mkdir -p vhosts
cd vhosts

cat >v1.test.conf<<EOF
server {
        listen       80;
        server_name  v1.test.net;
        location / {
            root   html/v1.test.net;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}
EOF

mkdir -p $nginx_dir/html/v1.test.net
cat >$nginx_dir/html/v1.test.net/index.html<<EOF
<html>
<h1>v1.www.net Test Pages.</h1>
<hr color=red>
</html>
EOF

$nginx_dir/sbin/nginx -t
$nginx_dir/sbin/nginx -s reload
curl 127.0.0.1

 

浏览415 评论0
返回
目录
返回
首页
Shell nginx配置wordpress站点 RAC 11GR2 集群启动脚本