Home > Backend Development > PHP Problem > What should I do if nginx php pictures are not displayed?

What should I do if nginx php pictures are not displayed?

藏色散人
Release: 2023-03-11 18:30:01
Original
4840 people have browsed it

nginx PHP image does not display the solution: first open the nginx.conf file; then add "location ~* ^. \.(jpg|jpeg|gif|png|bmp)$ {. ..}" statement; finally authorize the picture folder and pictures.

What should I do if nginx php pictures are not displayed?

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

nginx php What should I do if the picture does not display?

Nginx static website cannot display pictures

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 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 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 above command to reload the configuration :

nginx -s reload
Copy after login

Okay, now the picture can be displayed. (Actually, I think it is mainly a permissions issue. The code in the middle seems to be used when the background image cannot be used...)

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if nginx php pictures are not displayed?. For more information, please follow other related articles on the PHP Chinese website!

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