[root@server100 桌面]# vmset.sh 100
[root@server100 桌面]# dnf install nginx.x86_64 -y
[root@server100 nginx]# vim nginx.conf
root /var/www/html;
[root@server100 nginx]# mkdir -p /var/www/html
[root@server100 nginx]# echo /var/www/html > /var/www/html/index.html
[root@server100 nginx]# vim /var/www/html/test.html
default‘s page
[root@server100 nginx]# vim nginx.conf
index test.html;
[root@server100 nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@server100 nginx]# systemctl restart nginx.service
[root@server100 nginx]# curl 172.25.254.100
default‘s page
[root@server100 ~]# vim /etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;
server{
listen 80;
server_name news.timinglee.org;
root /var/www/virtual/timinglee.org/news;
index index.html;
}
server{
listen 80;
server_name login.timinglee.org;
root /var/www/virtual/timinglee.org/login;
index index.html;
}
[root@server100 conf.d]# systemctl restart nginx.service
[root@server100 conf.d]# mkdir -p /var/www/virtual/timinglee.org/{news,login}
[root@server100 conf.d]# echo news.timinglee.org > /var/www/virtual/timinglee.org/news/index.html
[root@server100 conf.d]# echo login.timinglee.org > /var/www/virtual/timinglee.org/login/index.html
[root@server100 conf.d]# vim /etc/hosts
172.25.254.100 server100.shaohua.org news.timinglee.org login.timinglee.org
[root@server100 conf.d]# vim /var/www/virtual/timinglee.org/news/index.html
[root@server100 conf.d]# vim /var/www/virtual/timinglee.org/login/index.html
[root@server100 ~]# mkdir /etc/nginx/verts
[root@server100 ~]# openssl req -newkey rsa:2048 -nodes -sha256 -keyout /etc/nginx/verts/timinglee.org.key -x509 -days 365 -out /etc/nginx/certs/timinglee.org.crt
[root@server100 ~]# vim /etc/nginx/conf.d/vhosts.conf
server{
listen 80;
server_name login.timinglee.org;
ssl_certificate "/etc/nginx/certs/timinglee.org.crt";
ssl_certificate_key "/etc/nginx/certs/timinglee.org.key"
root /usr/share/nginx/virtual/login;
index index.html;
}
[root@server100 ~]# mkdir -p /usr/share/nginx/virtual/login
[root@server100 ~]# echo login.timinglee.org > /usr/share/nginx/virtual/loginindex.html