Home  >  Article  >  Backend Development  >  Nginx static website cannot display image problem

Nginx static website cannot display image problem

WBOY
WBOYOriginal
2016-07-29 09:04:242189browse

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版本

Then in /usr/local/nginx/ Modify the nginx.conf file in the conf directory and add this paragraph:
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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn