Nginx as a static content server (Windows environment)

Source: Internet
Author: User

1. Simple Installation

1) Download

Http://nginx.org/en/download.html

2) The path after decompression

E:\Study\nginx\nginx-1.7.6

3) Execute Nginx.exe, visit http://localhost, appear welcome to nginx! Welcome content, installation successful.

4) in the installation path of the logs directory, will automatically generate a nginx.pid file, the file content is nginx main process PID.

2. Simple use of commands

Nginx-s Stop    -s quit    -s reload    s reopen    re-open log file    

3. Static Content Server

When accessing the HTML file, let Nginx map to the/data/html path; When accessing the picture file, let Nginx map to the/data/image path.

1) Create the data directory, and then insert the HTML directory and the image directory separately in the data directory.

2) put index.html, hello.html files in HTML directory

3) in the image directory, put 1.jpg, 2.jpg two pictures

4) Configuration nginx.conf

Configured in the server node within the HTTP node.

Location/ {            # Specifies root   e:/Study/nginx/nginx-1.7.  6/data/html;             # Specify first page            Index  index. html;        }         /image/ {            # Specify root directory            root   e:/Study/nginx/nginx-1.7 . 6/data;}

5) When request Http://localhost/image/1.jpg, Nginx automatically responds http://localhost/data/image/1.jpg

When request http://localhost/hello.html, Nginx automatically responds http://localhost/data/html/hello.html

Nginx as a static content server (Windows environment)

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.