架構nginx常見錯誤總結

2022-07-05 19:48:12 字數 4640 閱讀 2164

1、linux或windows #使用網域名稱

hosts(linux或windows) 沒有解析

[root@web01 /etc/nginx]# curl blog.oldboy.com

found.

2、connection refused #連線拒絕

檢查nginx服務是否啟動,systemctl status nginx

root@web01 /etc/nginx]# curl www.oldboy.com

curl: (7) failed connect to www.oldboy.com:80; connection refused

3、address already in use #nginx正在執行中

[root@web01 ~]# nginx

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: address already in use)

nginx: [emerg] still could not bind()

4、journalctl -xe

啟動或重啟nginx 的報錯

[root@web-204 html]# systemctl start nginx

job for nginx.service failed because the control process exited with error code. see "systemctl status nginx.service" and "journalctl -xe" for details.

解決:1>直接在命令列journalctl -xe檢視詳細的錯誤提示2>用nginx -t 檢查語法是否錯誤

[root@web-204 html]# nginx -t

nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:49

nginx: configuration file /etc/nginx/nginx.conf test failed

}不成對

5、configuration file /etc/nginx/nginx.conf test failed

server_name 這一行 沒有以 ";" 結尾terminated 結束

[root@wed01 ~]# nginx -t

nginx: [emerg] directive "server_name" is not terminated by ";" in /etc/nginx/nginx.conf:43

nginx: configuration file /etc/nginx/nginx.conf test failed

6、403 forbidden #被拒絕

1>**首頁的許可權拒絕2>**首頁不存在(預設找首頁檔案)

[root@web01 /usr/share/nginx/html/blog]# curl blog.oldboy.com

nginx/1.16.0

7、404 not found #請求的資源不存在

站點目錄下沒有aaa.html這個檔案

8、cannot assign requested address #無法分配指定的ip位址

本地沒有10.0.0.9這個ip

[root@web01 /etc/nginx]# nginx -t 

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: [emerg] bind() to 10.0.0.9:80 failed (99: cannot assign requested address)

nginx: configuration file /etc/nginx/nginx.conf test failed

解決:ip addr add 10.0.0.9/24 dev eth0 label eth0:1

9、conflicting server name #網域名稱衝突

有兩個幾個 虛擬主機的網域名稱相同了

[root 12:27:17 @web01 conf.d]# nginx -t

nginx: [warn] conflicting server name "www.oldboy.com" on 0.0.0.0:80, ignored

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

解決:用grep檢索查詢server標籤檔案中存在www.oldboy.com

的檔案,有多個將其中1乙個注釋或改名

1>檢查nginx的配置是否有誤2>當字尾為php時,給秘書php-fpm沒有指定站點目錄

測試nginx與php是否聯通時,出現的這個錯原因:1>php-fpm.service服務沒有啟動,啟動或重啟即可

13、can』t select database 不能選擇資料庫

在系統中沒有建立資料庫

13、error establishing a database connection #建立資料庫連線時出錯

1>站點目錄連線資料庫的賬號、密碼錯誤

14、user nginx is currently used by process 7259 #使用者nginx當前由程序7259使用

刪除nginx使用者時,提示該使用者正在被7259程序使用

[root@web02 ~]# userdel nginx

userdel: user nginx is currently used by process 7259

解決:先停止使用該使用者的服務systemctl stop nginx php-fpm.service,再刪除

15、401 authorization required

需要授權的意思,一般是認證失敗(使用者名稱和密碼)

16、500 internal server error

內部伺服器錯誤或程式錯誤

17、no route to host #無法到達主機

原因:1>防火牆、selinux2>是否能連線到虛擬機器(失聯)

nginx常見架構

服務 nginx負載均衡 nginx快取服務 快取 1 靜態資源web服務 檔案讀取sendfile tcp nopush tcp nodelay 壓縮,預讀gzip模組 2 服務 3 負載均衡排程器slb 4 動態快取 新增cache control expires頭 靜態資源訪問 壓縮 list...

常見錯誤總結

1.呼叫函式中使用的變數名與主函式中一致,沒有影響 include int isfullsquare int n int main 2.浮點數在賦值和計算中忘記加.0 3.忘記將布林變數 計數器變數 累加變數初始化為0 忘記將累乘變數初始化為1 注意初始化位置在迴圈內外的差別,對於多組資料的輸入應將...

常見錯誤總結

博主今天因為debug text debug 的事被教訓罵了所以記錄一下在debug text debug 的過程中都發現了什麼智障錯誤 取mod text mod的時候注意輸入也可能超出範圍,最好在輸入的時候取一下模。對於某些sb題請在讀入優化那個函式裡也取模 noip2014解方程 取模最好用函...