Welcome everyone

nginx 配置虚拟主机

分布式 汪明鑫 603浏览 0评论

nginx 的配置文件删掉一些注释的部分

#user nobody;        
worker_processes  1;   #表示一个工作线程    或者配置成cpu线程数或2倍
events {
    worker_connections  1024; #允许连接数
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    
    server {
        listen       81;            #监听端口
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }  

}

 

多配一个server,就是配一个虚拟主机

可以用隔离的概念去理解

一个在网上的服务器可以搭很多虚拟主机

 

多配一个server

 

server_name

在主机配置host文件,   域名到ip的映射

在nginx/html 下创建xinye目录,在该目录下创建index.html

转载请注明:汪明鑫的个人博客 » nginx 配置虚拟主机

喜欢 (0)

说点什么

您将是第一位评论人!

提醒
avatar
wpDiscuz