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

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

藏色散人
藏色散人Original
2021-07-22 10:33:464749browse

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

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;
}

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

nginx -s reload

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!

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