#user nobody; 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 localhost; location / { root /home/gs/guos/www/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } # 视频虚拟主机【vhost】 server { listen 7007; server_name localhost; location / { root /home/gs/guos/www/vod; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
命令如下:
第二种方式配置 利用我们在阿里云上申请注册的域名来实现【前提是做好解析并添加记录】【不同域名 + 同一个端口号】#user nobody; 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.jngoodnews.com; location / { root /home/gs/guos/www/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } # 视频虚拟主机【vhost】 server { listen 80; server_name vod.jngoodnews.com; location / { root /home/gs/guos/www/vod; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
重新加载并检查命令如下:
效果如下: