文章詳情頁
WinPC搭建nginx服務器的實現(xiàn)步驟
瀏覽:170日期:2023-03-13 15:37:44
目錄
- 修改端口
- 設置項目
- 常用命令
官網(wǎng)下載Windows穩(wěn)定版包,解壓后,雙擊nginx.exe啟動nginx。
也可以命令行CD到nginx.exe所在目錄后,執(zhí)行:start nginx來啟動服務器。
運行tasklist可以查看當前會話信息,看到如下信息說明啟動正常。
E:\Softwares\nginx-1.22.1\nginx-1.22.1>tasklist 映像名稱 ? ? ? ? ? ? ? ? ? ? ? PID 會話名 ? ? ? ? ? ? ?會話# ? ? ? 內(nèi)存使用 ========================= ======== ================ =========== ============ nginx.exe ? ? ? ? ? ? ? ? ? ?41136 Console ? ? ? ? ? ? ? ? ? ?4 ? ? ?7,100 K nginx.exe ? ? ? ? ? ? ? ? ? ? 6100 Console ? ? ? ? ? ? ? ? ? ?4 ? ? ?7,456 K
這兩個進程中一個是主進程,一個是工作進程,如果nginx沒有啟動,可以到logs/error.log下面找原因。
此時在瀏覽器輸入localhost可以看到nginx默認頁面(默認啟動頁為 html/index.html)的展示。
修改端口
nginx默認的端口是80端口,可以在conf/nginx.conf中修改
http { ? ? include ? ? ? mime.types; ? ? default_type ?application/octet-stream; ? ? #log_format ?main ?"$remote_addr - $remote_user [$time_local] "$request" " ? ? # ? ? ? ? ? ? ? ? ?"$status $body_bytes_sent "$http_referer" " ? ? # ? ? ? ? ? ? ? ? ?""$http_user_agent" "$http_x_forwarded_for""; ? ? #access_log ?logs/access.log ?main; ? ? sendfile ? ? ? ?on; ? ? #tcp_nopush ? ? on; ? ? #keepalive_timeout ?0; ? ? keepalive_timeout ?65; ? ? #gzip ?on; ? ? server { ? ? ? ? listen ? ? ? 80; ? ? ? ? server_name ?localhost;
修改端口后要使生效可以再次執(zhí)行nginx.exe,或者使用命令:nginx -s reload,重啟工程,使配置文件生效。
經(jīng)常會遇到瀏覽器刷新不起作用,可能是緩存引起的問題。測試的的時候通過修改端口跳過該問題。
設置項目
項目所用資源放到html目錄下,并調(diào)整好啟動頁面即可。
常用命令
nginx -s stop 強制關閉 nginx -s quit 安全關閉 nginx -s reload 改變配置文件的時候,重啟nginx工作進程,來時配置文件生效 nginx -s reopen 打開日志文件
到此這篇關于WinPC搭建nginx服務器的實現(xiàn)步驟的文章就介紹到這了,更多相關Win搭建nginx服務器內(nèi)容請搜索以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持!
標簽:
Nginx
排行榜
