可以在一台机器上放置多个网站,若是静态网站的话,理论上可以放置无限多个。
本操作基于Ubuntu
我的nginx访问的根目录 
创建一个”vhost”目录
sudo mkdir /usr/local/nginx/conf/vhost
   | 
 
创建siteA的配置文件
sudo vi /usr/local/nginx/conf/vhost/vhost_siteA.conf
   | 
 
server {     listen       80;                        # 监听端口     server_name www.siteA.com siteA.com;    # 站点域名     root  /home/wwwroot/default;              # 站点根目录     index index.html index.htm index.php;   # 默认导航页
      location / {         # WordPress固定链接URL重写         if (!-e $request_filename) {             rewrite (.*) /index.php;         }     }
      # PHP配置     location ~ \.php$ {         fastcgi_pass unix:/var/run/php5-fpm.sock;         fastcgi_index index.php;         include fastcgi_params;     } }
  | 
 
创建siteB的配置文件
sudo vi /etc/nginx/vhost/vhost_siteB.conf
   | 
 
server {     listen       80;                        # 监听端口     server_name www.siteA.com siteA.com;    # 站点域名     root  /home/wwwroot/old;              # 站点根目录     index index.html index.htm index.php;   # 默认导航页
      location / {         # WordPress固定链接URL重写         if (!-e $request_filename) {             rewrite (.*) /index.php;         }     }
      # PHP配置     location ~ \.php$ {         fastcgi_pass unix:/var/run/php5-fpm.sock;         fastcgi_index index.php;         include fastcgi_params;     } }
  | 
 
修改nginx.conf
sudo vi /usr/local/nginx/conf/nginx.conf
   | 
 
在http里加入这段
include /usr/local/nginx/conf/vhost/*.conf;
   | 
 
重启 nginx 即可。