Focus on cloud service provider activities
Notes on website operation and maintenance

LNMP series tutorial 6: setting 404 error page

Shared to in previous articles“ How to set 301 redirection "The article, referring to 301, must also talk about the 404 error page. Because after we install LNMP by default, the 404 page will not be automatically set, nor will it default to the 404 error page of the program, but we need to set it manually. How to set it? Let's look down together.

Step 1: edit the/usr/local/nginx/conf/nginx.conf file, and add the following code in the http area;

fastcgi_intercept_errors on;

 LNMP series tutorial 6: setting 404 error page

Step 2, edit the conf file of the website you need to add 404 pages, and add the code in the server area in usr/local/nginx/conf/vhost/XXXX.com.conf;

error_page 404 = /404.html;

Step 3: Restart LNMP;

/root/lnmp restart

In conclusion, we can test whether the returned status is correct through/usr/local/nginx/sbin/nginx - t.

the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful

If the above return status is true, it is correct.

 

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » LNMP series tutorial 6: setting 404 error page