先删掉配置文件中的server部分,在http最后一行加上,
include vhost/*.conf; #这个目录本身没有,需要在conf下创建一个。
• mkdir /usr/local/nginx/conf/vhost
创建一个xxx.conf的文件
server
{
listen 80 default_server; // 有这个标记的就是默认虚拟主机
server_name aaa.com; #域名
index index.html index.htm index.php; #指定索引页,
root /data/wwwroot/default; #指定根目录所在路径
}
• 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
转载于:https://blog.51cto.com/13451715/2322352