Edit Nginx configuration file
Vim/usr/local/nginx/conf/nginx.conf
Delete server{} Host configuration end, add at last
Include Vhost/*.confmkdir/usr/local/nginx/conf/vhost
Within the Vhost folder, create the default host profile aaa.com.conf file, edited as follows:
server{ listen default_server; With this tag is the default virtual host server_name aaa.com; Index index.html index.htm index.php; Root/data/wwwroot/default; Site Directory, there is no need to create}
Create an HTML file in the site Directory
echo "This is a default site." >/data/wwwroot/default/index.html
Check nginx configuration file syntax, and reload configuration file
/usr/local/nginx/sbin/nginx-t/usr/local/nginx/sbin/nginx-s Reload
Test, default virtual host, no matter what domain name, will point to this site
[[email protected] default]# Curl Localhostecho "This is a default site." [Email protected] default]# curl-x127.0.0.1:80 123.comecho "This is a default site." [Email protected] default]# curl-x127.0.0.1:80 Aaa.comecho "This is a default site." [Email protected] default]# curl-x127.0.0.1:80 Www.baidu.comecho "This is a default site."
Linux10.3 nginx Default Virtual Host