搭建网站
搭建单网站
搭建www.etiantian.org 网站流程 1.修改nginx.conf文件 worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name www.etiantian.org ; location / { root html/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } 2.创建环境 mkdir -p /application/nginx-1.12.2/html/{www,bbs,blog} for name in www bbs blog;do echo $name.etiantian.org > /application/nginx-1.12.2/html/$name/index.html ;done for name in www bbs blog;do cat /application/nginx-1.12.2/html/$name/index.html ;done 3.检查语法并重启 [root@oldboyedu-s6 nginx-1.12.2]# /application/nginx-1.12.2/sbin/nginx -t nginx: the configuration file /application/nginx-1.12.2/conf/nginx.conf syntax is ok nginx: configuration file /application/nginx-1.12.2/conf/nginx.conf test is successful [root@oldboyedu-s6 nginx-1.12.2]# /application/nginx-1.12.2/sbin/nginx -s reload 4.windows测试 浏览器(注意缓存) 1)修改 \etc\hosts 10.0.0.200 www.etiantian.org bbs.etiantian.org blog.etiantian.org 2)浏览器测试 5.Linux命令行测试 curl -vH Host: www.etiantian.org 10.0.0.200
搭建多网站
搭建多个网站: [root@oldboyedu-s6 nginx-1.12.2]# cat conf/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name www.etiantian.org ; location / { root html/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name bbs.etiantian.org ; location / { root html/bbs; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name blog.etiantian.org ; location / { root html/blog; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }