Home > Article > Backend Development > Nginx static website cannot display image problem
Today I want to put the exercises I did on the server to see, but the pictures are not displayed. Now record the solution:
First record a few Nginx commands:
start nginx //运行nginx nginx -s stop // 停止nginx nginx -s reload // 重新加载配置文件(如修改配置文件后,可通过该命令重新加载) nginx -s quit // 退出nginx nginx -v //可查nginx版本
location ~* ^.+\.(jpg|jpeg|gif|png|bmp)$ { access_log off; root html; expires 30d; break; }Here you need to write the website directory behind root correctly
Finally, you need to authorize the picture folder and pictures, and give all users viewing permissions:
chmod 774 ./images
Finally, use the command above to reload the configuration:
nginx -s reload
Okay, pictures can now be displayed. (Actually, I think it’s mainly a permissions issue. The code in the middle seems to be used when the background image is not available...)
The above introduces the problem of Nginx static website being unable to display images, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.