我阅读了一些教程以及如何在Windows上的nginx中配置虚拟主机的一些主题。
我安装并使用localhost示例页面成功运行nginx。
之后,在c:/ nginx / html下我创建了一个子目录/ hello /,其中index.html的内容是:
C:/nginx/html/hello/index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Hello!</h1>
</body>
</html>
之后,在nginx.conf文件中的http下,我添加了以下内容:
server {
listen 80;
server_name www.localhello.com;
root C:/nginx/html/hello;
index index.html;
}
我在我的主机文件中添加了www.localhello.com。
当我尝试退出并重新启动nginx时,当我在浏览器中输入www.localhello.com时,始终显示localhost的内容(C:/nginx/html/index.html预安装文件的内容),我不能理解为什么会这样。
我删除了外围设备“C:”现在使用此配置工作:
server {
listen *:80;
server_name www.localhello.com;
root /nginx/html/hello;
index index.html;
}