2013-04-28 68 views
0

我从一个指针的网站,使能/对的Qooxdoo其中/var/www/qooxdoo/nginx.conf我有以下几点:nginx配置。如何给不同的网站不同的名字?

server { 
    listen 80; ## listen for ipv4; this line is default and implied 


    root /var/www/qooxdoo; 
    index index.html index.htm; 

    # Make site accessible from http://localhost/ 
    server_name localhost; 
} 

访问该网站,我需要做的:本地主机/ 这它。但我如何给该网站命名?

例如,本地主机/站点1的排序。

在此先感谢您的帮助 jenia Ivlev型

+0

你想给什么样的名字? – 2013-04-29 13:28:03

回答

1

取决于你究竟想达到。考虑到文件系统中的以下目录。

/var/www 
    - site-1 
    - site-2 
    - ... 
    - site-n 

现在你可以在URL中使用简单的目录,如果你像你所做的那样配置nginx。

server { 
    listen 80; 
    root /var/www; 
    index index.html index.htm; 
    server_name localhost; 
} 

请求http://localhost/site-1将返回文件/var/www/site-1/index.html(与同为site-2高达site-n)的内容。

如果您想使用子域,您可以执行以下操作。

server { 
    listen 80; 
    root /var/www/site-1; 
    index index.html index.htm; 
    server_name site-1.localhost; 
} 

server { 
    listen 80; 
    root /var/www/site-2; 
    index index.html index.htm; 
    server_name site-2.localhost; 
} 

server { 
    listen 80; 
    root /var/www/site-n; 
    index index.html index.htm; 
    server_name site-n.localhost; 
} 

请求http://site-1.localhost/将返回文件/var/www/site-1/index.html(与同为site-2高达site-n)的内容。