Nginx服務配置 (二) 檢視並分析配置檔案

2021-09-03 01:52:55 字數 1810 閱讀 9570

目的:本文重點檢視並分析nginx預設配置;修改index.html檔案輸出"hello world"。

全域性變數

user nginx;    #使用的使用者

worker_processes auto;    #工作程序數,自動調整(手動設定的話一般和cpu核數一樣)

error_log /var/log/nginx/error.log;    #錯誤日誌檔案

pid /run/nginx.pid;        #pid存放路徑

事件配置

events

http引數

error_page 404 /404.html;            #錯誤資訊返回頁面

location = /40x.html

error_page 500 502 503 504 /50x.html;#錯誤資訊返回頁面

location = /50x.html }}

步驟

[root@vm_16_8_centos html]# cd /usr/share/nginx/html

[root@vm_16_8_centos html]# mv index.html index.html.back

[root@vm_16_8_centos html]# touch index.html

[root@vm_16_8_centos html]# vim index.html

hello world

[root@vm_16_8_centos html]# systemctl restart nginx

通過瀏覽器輸入伺服器的ip,檢視到列印資訊

總結

目前對於如何配置nginx服務還不了解,以後深入了隨時回來補充。先這樣咯

Nginx配置分析 nginx 二

基於網域名稱配置 在 conf nginx.conf中新增兩個虛擬主機配置 server server 配置host檔案,dns本地化 192.168.1.103 www.host1.com 192.168.1.103 www.host2.com 測試成功 埠配置在 conf nginx.conf中...

配置nginx並建立為windows服務 配置

建立nginx service.exe.config 為支援net 4.0 runtime,預設只支援net 2.0 runtime 檔案結構 nginx service.xml 配置 nginx nginx service high performance nginx service e soft...

Nginx的安裝並配置web服務

一 安裝編譯工具及庫檔案 yum y install make zlib zlib devel gcc c libtool openssl openssl devel二 首先要安裝 pcrepcre 作用是讓 nginx 支援 rewrite 功能。downloads.sourceforge.net...