lnmp之nginx如何設置404錯(cuo)誤頁面

 

1.創建自己的404.html頁面

2.更改nginx.conf在http定義區域加入:

fastcgi_intercept_errors on;

3.更(geng)改(gai)nginx.conf或虛(xu)擬主(zhu)機的(de)域(yu)名.conf在server 區域(yu)加入(ru):

error_page 404 /404.html;

4.測試nginx.conf正確(que)性:

/usr/local/nginx/sbin/nginx -t

 

如果正確應該顯示如下信(xin)息:

the configuration file ;/opt/nginx/conf/nginx.conf syntax is ok 

configuration file /opt/nginx/conf/nginx.conf test is successful

5.重啟nginx

/usr/local/nginx/sbin/nginx -s reload