我有一個非常簡單的問題無法解決。我在網上搜尋了一段時間但沒有好的結果。
我想更改在 CentOS 上運行的 nginx 伺服器上網站的預設位置。
我的網站資料夾的位置是 html。
我編輯了 nginx.conf 文件,如下所示:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
}
這裡是伺服器的資料夾結構。
伺服器隨後被重新聲明。
當輸入伺服器的 IP 位址時,我仍然得到 nginx 預設 html 頁面。
知道解決方案是什麼嗎?
如果我錯過了一些需要的信息,請告訴我。
答案1
您必須設定root
為絕對路徑,html
看起來不像絕對路徑。
前任。
location / { root /root/html; index index.html index.htm; }
並確保正確的權限。
答案2
新增default_server
到listen
指令:
listen 80 default_server;