windows10 system configuration nginx file server

Download the Windows version of Nginx from the Nginx official website:

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

insert image description here

Unzip the downloaded package:

Notice:

The path of the decompressed package cannot contain Chinese characters, otherwise the Nginx service cannot be started
insert image description here

Start the Nginx service:

"Windows key + R key" to open the run, enter "cmd" to enter the "Dos terminal"

C:\Users\Administrator>f:

F:\>cd GX\nginx-1.16.1

# 启动命令
F:\GX\nginx-1.16.1>start nginx

F:\GX\nginx-1.16.1>

insert image description here

After the service starts successfully, there will be two "nginx" processes in the task managerinsert image description here

Modify the configuration file and restart Nginx

Add the following lines above the "HTTPS server block" in the "nginx.conf" file

# 添加文件管理器 
# 显示目录
autoindex on;
# 显示文件大小
autoindex_exact_size on;
# 显示文件时间
autoindex_localtime on;
 
server {
    
    
listen       8888;
server_name  localhost ;
# 本地文件路径
# 注意不能直接以整个逻辑磁盘F:\ 为目录路径,要F:\英文目录名
root  F:\GX\Chiron ;
}

Reload the Nginx service

# 重新加载Nginx服务命令
F:\GX\nginx-1.16.1>nginx.exe -s reload

F:\GX\nginx-1.16.1>

Web browser access verification:

Here I created a new "test.txt" file in the "F:\GX\Chiron" directory in advance for testing

Access address: http://ip:port

insert image description here

Notice:

1. The directory name and file name must use English characters to download normally;
2. Files with Chinese characters may display garbled characters, and a "500 Internal Server Error" error may be reported when downloading

Nginx related commands for Windows version:

nginx  -s stop                 //停止nginx

nginx -s reload                //重新加载nginx

nginx -s quit                  //退出nginx

start  nginx                   //启动nginx

Set the PC to start automatically

C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Create a shortcut for "nginx.exe" to the above directory

insert image description here

Guess you like

Origin blog.csdn.net/wkl1007/article/details/103565647