Nginx static website cannot display image problem

WBOY
Release: 2016-07-29 09:04:24
Original
2143 people have browsed it

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版本
Copy after login

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;
        }
Copy after login
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
Copy after login

Finally, use the command above to reload the configuration:

nginx -s reload
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!