下載
http://nginx.org/en/download.html
解壓
將下載后的 nginx-1.19.8.zip 壓縮包解壓縮到 D:/applications 目錄下。
解壓后的目錄結構如下:
<img src="images\nginx-directory.png" style="zoom:80%;border:1px solid gray;" />
配置
在 conf 目錄中找到 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 D:/mycodes/movable-termination;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root D:/mycodes/movable-termination ;
}
}
}
注意
1.listen 之后的 80 表示 監聽端口 ( 80 是 WWW 服務的默認端口 )
2.server_name 之后的 localhost 表示本地主機 ,將來在瀏覽器地址欄中可以通過 http://localhost 或 http://localhost:80 來訪問
3 localtion / 選項下的 root 選項用于確定 WWW服務的 根目錄 ,即當訪問 http://localhost:80/index.html 時會在 root 對應的目錄下尋找 index.html ,也就是 http://localhost:80/index.html 中 :80 之后的 / 所對應的目錄 ,location = /50x.html 選項中的 root 表示服務端發生錯誤后的跳轉頁面所在的目錄
啟動
首先進入到 nginx 目錄下:
cd nginx-1.19.8
在命令提示符中啟動 nginx :
start nginx
啟動之后可以在 任務管理器 中查看到兩個 nginx 進程
修改配置后重新加載生效:
nginx -s reload
有序退出
nginx -s quit
快速關閉
nginx -s stop
可能會因為多次啟動 nginx 導致啟動了多個 nginx 進程,此時需要列出這些進程相關的信息:
tasklist /fi "imagename eq nginx.exe"
如果需要將這些進程全部殺死,可以使用以下命令:
taskkill /f /t /im nginx.exe
注意: tasklist 、taskkill 、start 都是 Windows 自帶的命令,不是 nginx 提供的。
到此這篇關于nginx服務器的下載安裝與使用詳解的文章就介紹到這了,更多相關nginx服務器下載內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!