网站建设资讯

NEWS

网站建设资讯

nginx域名配置虚拟主机-创新互联

一个域名,对应一个IP地址
通过DNS域名解析服务器,可以将域名解析为IP地址

超过十年行业经验,技术领先,服务至上的经营模式,全靠网络和口碑获得客户,为自己降低成本,也就是为客户降低成本。到目前业务范围包括了:做网站、网站建设,成都网站推广,成都网站优化,整体网络托管,微信平台小程序开发,微信开发,重庆App定制开发,同时也可以让客户的网站和网络营销和我们一样获得订单和生意!

这里
通过修改host文件,指定域名的IP地址

host劫持
是指在host文件中,配置域名和IP地址,当访问域名的时候
因为,host文件中已经有了域名所对应的IP地址
所以,不再需要访问DNS服务器进行解析,直接访问对应的IP地址

host文件的位置
C:\Windows\System32\drivers\etc

Nginx配置文件注释:

 [root@localhost conf]# vim nginx.conf

worker_processes  1;    #worker进程的数量
events {                #事件块的开始
worker_connections  1024;            #每个worker进程支持的大连接数
}                       #事件块的结束
http {                  #HTTP区块的开始
include       mime.types;                #Nginx支持媒体类型库文件
default_type  application/octet-stream;    #默认的媒体类型
sendfile        on;                        #开启高速传输模式
keepalive_timeout  65;                     #连接超时
server {                                    #第一个server区块的开始
    listen       80;                        #提供服务的端口,默认为80
    server_name   www.nautilus.org ;                 #提供服务的域名主机
    location / {                            #第一个location区块的开始
        root   html/www;                        #站点的根目录,相当于Nginx的安装目录
        index  index.html index.htm;        #默认的首页文件,多个使用空格隔开
    }                                        #第一个location区块的结束
    error_page   500 502 503 504  /50x.html;    #出现对应的http状态码是,使用50x.html回应客户
    location = /50x.html {                    #location区块的开始,访问50x.html
        root   html;                            #指定对应的站点目录为html
    }
}
}                                                   #HTTP区块的结束

操作步骤

[root@localhost nginx]# ls
client_body_temp  fastcgi_temp  logs        sbin       uwsgi_temp
conf              html          proxy_temp  scgi_temp
[root@localhost nginx]# cd html
[root@localhost html]#
[root@localhost html]# mkdir www    
[root@localhost html]#      
[root@localhost html]# cd www
[root@localhost www]# ls
index.html
[root@localhost www]# vim index.html
   hello  localhost

[root@localhost nginx]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.31.1.32     www.nautilus.org

访问网站:

        www.nautilus.org

Nginx配置基于多域名

    server {
    listen       80;
    server_name  www.nautilus.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.nautilus.org;
    location / {
        root   html/bss;
        index  index.html index.htm;
    }
}

server {
    listen       80;
    server_name  blog.nautilus.org;
    location / {
        root   html/blog;
        index  index.html index.html;
    }

}

[root@localhost nginx]# cd html
[root@localhost html]#
[root@localhost html]# mkdir bbs    
[root@localhost html]#      
[root@localhost html]# cd bbs
[root@localhost bbs]# ls
index.html
[root@localhost bbs]# vim index.html
   hello  bbs
[root@localhost html]# mkdir blog   
[root@localhost html]#      
[root@localhost html]# cd blog
[root@localhost blog]# ls
index.html
[root@localhost blog]# vim index.html
   hello  blog

  [root@localhost html]# ls
50x.html  bbs  blog  index.html  www

[root@localhost nginx]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.31.1.32     www.nautilus.org
172.31.1.32     bbs.nautilus.org
172.31.1.32     blog.nautilus.org

访问网站:

    www.nautilus.org
    bbs.nautilus.org
    blog.nautilus.org

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页题目:nginx域名配置虚拟主机-创新互联
文章分享:http://cdweb.net/article/ijsch.html