Configuration nginx配置。如何给不同的网站起不同的名字?

Configuration nginx配置。如何给不同的网站起不同的名字?,configuration,nginx,webserver,Configuration,Nginx,Webserver,我有一个从/qooxdoo到/var/www/qooxdoo/nginx.conf的指针,其中我有以下内容: 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/

我有一个从/qooxdoo到/var/www/qooxdoo/nginx.conf的指针,其中我有以下内容:

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;
}
要访问该网站,我需要执行以下操作:localhost/ 就这样。但是我如何给那个网站命名呢

例如,localhost/site1

提前谢谢你的帮助
jenia ivlev取决于你到底想要实现什么。考虑文件系统中的以下目录

/var/www
  - site-1
  - site-2
  - ...
  - site-n
现在,如果您像以前一样配置nginx,就可以使用URL中的简单目录

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
),您希望给出什么样的名称?