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
本文轉自 蝦米的春天 51CTO部落格,原文連結:http://blog.51cto.com/lsxme/2057256,如需轉載請自行聯系原作者