In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to configure nginx static resource server, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Go to the conf directory of the nginx installation directory, modify the nginx.conf file, and add a location part of the configuration code to a server {} as follows
Root@ubuntu:/usr/local/nginx/conf# vi nginx.conf server {listen 80; server_name localhost; location / {root html; index index.html index.htm;} location / image/ {root / usr/local/myImage/; autoindex on;}}
From the above configuration, you can see that the port is 80 and the serverroomname is localhost (it is also possible to write an ip address)
Location / image/ {root / usr/local/myImage/; autoindex on;}
This configuration means that the native / usr/local/myImage/image/ directory will be accessed when you type localhost:80/image/. So to create a new / usr/local/myImage/image/ directory, and also in the html directory of the nginx installation directory, create a new image directory with the same name as image in location. Although there is nothing in this directory, we put a picture 1.jpg in / usr/local/myImage/image/, restart the nginx service, and you can access it through localhost:80/image/1.jpg.
Root@ubuntu:/usr/local/nginx/html# mkdir imageroot@ubuntu:/usr/local/nginx/html# mkdir / usr/local/myImage/image# put a photo on # root@ubuntu:/usr/local/nginx/html# cd / usr/local/myImage/imageroot@ubuntu:/usr/local/myImage/image# ls1.jpgroot@ubuntu:/usr/local/myImage/image#
Restart nginx
Root@ubuntu:/usr/local/nginx/sbin#. / nginx-s reloadroot@ubuntu:/usr/local/nginx/sbin#
Open a browser and enter server_name:80/image/1.jpg to access the static image.
These are all the contents of the article "how to configure static resource servers in nginx". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.