Nginx配置http服務器
1、配置nginx.conf文件
修改nginx可執行文件目錄下的nginx.conf文件
#配置虛擬主機的
server {
#虛擬主機訪問的端口
listen 81;
#虛擬主機訪問的域名
server_name www.yl.com;
#靜態資源存儲的位置
location / {
#配置靜態資源存放的絕對路徑
root /home/hadoop/www/html;
#訪問首頁的文件名
index index.html;
}
}
2、新建靜態資源存儲目錄
新建nginx.conf中配置的靜態資源存儲目錄,在目錄新建index.html文件,編寫首頁html
3、添加虛擬機ip映射
在虛擬機hosts文件中添加ip映射,eg:192.168.84.128 www.yl.com
#修改hosts文件的命令
vi /etc/hosts
4、添加windows的ip映射
在C:\Windows\System32\drivers\etc此路徑(針對window10)中編輯hosts文件,添加ip映射,eg:
192.168.84.128 www.yl.com
5、啟動nginx服務並訪問
啟動nginx服務后,在瀏覽器中輸入http://www.yl.com:81即可訪問剛才部署的服務器
