Why does the Nginx static website fail to display images?

Source: Internet
Author: User
: This article mainly introduces the problem that Nginx static websites cannot display images. For more information about PHP tutorials, see. Today, I want to put my exercises on the server, but I don't want to show any pictures. now I want to record the solution:

First, record several Nginx commands:

Start nginx // run nginxnginx-s stop // stop nginxnginx-s reload // re-load the configuration file (for example, after modifying the configuration file, you can use this command to re-load it) nginx-s quit // exit nginxnginx-v // Check the nginx version.

Modify the nginx. conf file in the/usr/local/nginx/conf directory, and add the following:
location ~* ^.+\.(jpg|jpeg|gif|png|bmp)$ {        access_log off;        root html;        expires 30d;        break;        }
Write the website directory after root

At last, you must authorize all users to view the image folders and images:

chmod 774 ./images

Use the above command to reload the configuration:

nginx -s reload

Now, the image is displayed. (In fact, I think it is mainly about permission issues. the code in the middle seems to be used when the background image cannot be used ......)

The above introduces the problem that Nginx static websites cannot display images, including some content. I hope my friends who are interested in PHP tutorials will be helpful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.