1、创建自己的404.html页面,传到网站根目录,注意图片引用的路径;
2、更改nginx.conf在http定义区域加入:
fastcgi_intercept_errors on;
3、更改nginx.conf在server 区域加入:
error_page 404 = /404.html
error_page 403 = /404.html
error_page 500 = /404.html
4、测试nginx.conf正确性:
/usr/local/nginx/sbin/nginx -t
如果正确应该显示如下信息:
the configuration file /opt/nginx/conf/nginx.conf syntax is ok
configuration file /opt/nginx/conf/nginx.conf test is successful
5、重启nginx
kill -HUP `cat /usr/local/nginx/logs/nginx.pid` or service nginx restart or /usr/local/nginx/sbin/nginx –s reload