修改nginx主配置文件
[root@dl-001 nginx-1.12.2]
include vhost/*.conf;
创建并修改虚拟主机配置文件(默认虚拟主机)
[root@dl-001 nginx-1.12.2]# cd /usr/local/nginx/conf
[root@dl-001 conf]# mkdir vhost
[root@dl-001 conf]# cd vhost/
[root@dl-001 vhost]# vim aaa.com.conf
server
{
listen 80 default_server;
server_name aaa.com;
index index.html index.htm index.php;
root /data/www/default;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
创建默认虚拟主机的根目录及默认页面
[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]
aaa.com
// 由于是默认的虚拟主机,任何域名都可以显示默认网页信息
[root@dl-001 default]
aaa.com
[root@dl-001 default]
aaa.com