vim /usr/local/nginx/conf/nginx.conf //删除server部分 增加 include vhost/*.conf //在conf下面创建一个vhost子目录

[root@localhost conf]# pwd /usr/local/nginx/conf mkdir vhost cd vhost/ vim default.conf //加入如下内容 server { listen 80 default_server; // default_server有这个标记的就是默认虚拟主机 server_name aaa.com; //域名 index index.html index.htm index.php; root /data/wwwroot/default; //网站根目录。Apache的是Document } mkdir -p /data/wwwroot/default/ echo “This is a default site.”>/data/wwwroot/default/index.html /usr/local/nginx/sbin/nginx -t //检测语法 /usr/local/nginx/sbin/nginx -s reload //#重新加载 curl localhost curl -x127.0.0.1:80 123.com