修改 nginx 主配置文件
[root@dl-001 nginx-1.12.2]
include vhost/*.conf;
创建并修改虚拟主机配置文件(默认虚拟主机)
[root@dl-001 nginx-1.12.2]
[root@dl-001 conf]
[root@dl-001 conf]
[root@dl-001 vhost]
server
{
// 指定监听80端口,并将该虚拟主机设置为默认虚拟主机
listen 80 default_server;
// 设置服务器的名称
server_name aaa.com;
// 设置服务器默认网页
index index.html index.htm index.php;
// 设置服务器的根目录
root /data/www/default;
}
创建默认虚拟主机的根目录及默认页面
[root@dl-001 vhost]
[root@dl-001 vhost]
[root@dl-001 default]
aaa.com
检测代码并重启服务
[root@dl-001 default]
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@dl-001 default]
检测是否成功
[root@dl-001 default]# curl -x 127.0.0.1:80 aaa.com
aaa.com
[root@dl-001 default]# curl -x 127.0.0.1:80 bbb.com
aaa.com
[root@dl-001 default]# curl -x 127.0.0.1:80 ccc.com
aaa.com