shell初学之nginx(域名)

创建两个以域名区分的虚拟网站:

 1 #!/bin/bash
 2 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
 3 sed -i 's/80/8080/g' /etc/httpd/conf/httpd.conf
 4 systemctl restart httpd
 5 yum -y install epel-*
 6 yum -y install nginx
 7 mkdir /work/html_a /work/html_b -p
 8 echo " server {
 9     listen 80;
10     server_name a.com;
11     location / {
12     root /work/html_a;
13     }
14 }
15  server {
16     listen 80;
17     server_name b.com;
18     location / {
19     root /work/html_b;
20     }
21 } " > /etc/nginx/conf.d/ab.conf
22 systemctl restart nginx
23 systemctl enable nginx
24 firewall-cmd --add-port=80/tcp
25 firewall-cmd --add-port=80/tcp --permanent
26 echo "aaaaaaaaaaaaaa" > /work/html_a/index.html
27 echo "bbbbbbbbbbbbbbb" > /work/html_b/index.html
28 echo "192.168.11.5 a.com" >> /etc/hosts
29 echo "192.168.11.5 b.com" >> /etc/hosts

 

posted @ 2019-08-03 15:17  Wolf_Coder  阅读(256)  评论(0编辑  收藏  举报