Nginx部署靜態頁面linux
以雲主機爲例,系統爲Centos_7.4_x64,綁有外網IP,接下來是具體的步驟:nginx
1.安裝nginx,能夠Xshell遠程鏈接雲主機, shell
# 安裝nginx
yum -y install nginx
# 關閉selinux
setenforce 0
# 關閉防火牆
systemctl stop firewalld && systemctl disable firewalld
# 啓動nginx服務
systemctl start nginx && systemctl enable nginx瀏覽器
安裝成功後,訪問IP,就可出現nginx默認頁面;安全
2.部署靜態頁面服務器
3.配置文件,/etc/nginx/nginx.conf /etc/nginx/nginx.conf.default進行更改;ssh
在http{}中的server中修改相關信息spa
listen: 監聽端口
server_name :是通配符,輸入本身的域名IP
root / :靜態文件所在的路徑3d
location :靜態文件的名稱,以下server
注:若是想要一個IP訪問多個站點,能夠增長多個server,端口
4.更改完成後,從新啓動服務
systemctl reload nginx
5.接下來就能夠在瀏覽器中訪問了,輸入你的IP網址或者域名便可;