Home > Operation and Maintenance > Nginx > How to solve the problem that nginx static website does not display images

How to solve the problem that nginx static website does not display images

王林
Release: 2020-09-01 16:35:02
forward
5732 people have browsed it

How to solve the problem that nginx static website does not display images

First we need to master the following commands:

(Recommended tutorial: nginx tutorial)

start nginx                      //运行
nginxnginx -s stop          // 停止nginx
nginx -s reload       // 重新加载配置文件(如修改配置文件后,可通过该命令重新加载)
nginx -s quit          // 退出nginx
nginx -v                 //可查nginx版本
Copy after login

Then / Modify the nginx.conf file in the usr/local/nginx/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 the root correctly

Finally, you need to correct the picture Authorize the folders and pictures and give all users viewing permissions:

chmod 774 ./images
Copy after login

Finally use the above command to reload the configuration:

nginx -s reload
Copy after login

The above is the detailed content of How to solve the problem that nginx static website does not display images. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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