: This article mainly introduces the problem that Nginx static websites cannot display images. For more information about PHP tutorials, see. Today, I want to put my exercises on the server, but I don't want to show any pictures. now I want to record the solution:
First, record several Nginx commands:
Start nginx // run nginxnginx-s stop // stop nginxnginx-s reload // re-load the configuration file (for example, after modifying the configuration file, you can use this command to re-load it) nginx-s quit // exit nginxnginx-v // Check the nginx version.
Modify the nginx. conf file in the/usr/local/nginx/conf directory, and add the following:
location ~* ^.+\.(jpg|jpeg|gif|png|bmp)$ { access_log off; root html; expires 30d; break; }
Write the website directory after root
At last, you must authorize all users to view the image folders and images:
chmod 774 ./images
Use the above command to reload the configuration:
nginx -s reload
Now, the image is displayed. (In fact, I think it is mainly about permission issues. the code in the middle seems to be used when the background image cannot be used ......)
The above introduces the problem that Nginx static websites cannot display images, including some content. I hope my friends who are interested in PHP tutorials will be helpful.