One of the Nginx functions can start a local server and access the target file by configuring the server_name and root directories. Download http://nginx.org/Download and unzip
Two. Modify the configuration file
Nginx config file in nginx-1.8.0\conf\nginx.conf
HTTP { gzip on ; #静态文件 Server { listen ; server_name static.cnblog.com; Location/{ root g:/source/static_cnblog_com; } } #html文件 Server { listen ; server_name 127.0.0.1 localhost; Location/{ root g:/source/html/mobile/dist; Index index.html index.htm;}}}
If you can configure multiple servers so that access to localhost is accessed to the g:/source/html/mobile/dist directory, you can also turn on gzip, compress HTML
Three. Start note do not directly double-click Nginx.exe, this will cause changes in configuration after restarting, stop nginx invalid, you need to manually close all Nginx processes in the task Manager in the Nginx.exe directory, open command-line tools, with the command to start/close/restart Nginx start Nginx: Start nginxnginx-s Reload: Modify configuration after reload takes effect nginx-s reopen: Reopen log file
NGINX-T-c/path/to/nginx.conf Test nginx configuration file is correct
Close Nginx:
Nginx-s stop: Fast Stop Nginx
Nginx-s quit: Complete and orderly stop nginx
If you encounter an error:
Bash:nginx:command not found
It's possible that you ran Windows commands in the Linux command-line environment,
If you have previously allowed nginx-s reload error, try./nginx-s Reload
or run it with a command-line tool from the Windows system
Introduction to installing and using Windows Nginx