Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Settings of nginx.conf profile in windows

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Not to mention the powerful role of nginx as a web server, it was born on the linux platform and is most suitable for deployment on the linux platform, but it is also supported on the windows platform at present. However, for most developers, the windows version of nginx is more used for local debugging.

The windows version of the nginx installation package is actually a compressed package, configuration files and mainly rely on scripts and linux version of the same, but in the configuration writing, there are some holes to avoid.

The most streamlined nginx.conf configuration file should look like this

# user nobody;worker_processes 4% error error log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 4096;} http {include mime.types; default_type application/octet-stream; # access_log logs/access.log main; sendfile on; sendfile_max_chunk 512k; open_file_cache max=204800 inactive=20s Open_file_cache_min_uses 1; open_file_cache_valid 30s; tcp_nopush on; tcp_nodelay on; keepalive_timeout 5; types_hash_max_size 2048;}

For the server configuration of each site, try to separate a conf file, and then reference it in nginx.conf for easy management. Therefore, in the http configuration unit, we use the include instruction to include configuration files from other places, such as include / home/conf/system1.conf.

The complete http block looks like this:

Http {include mime.types; default_type application/octet-stream; # access_log logs/access.log main; sendfile on; sendfile_max_chunk 512k; open_file_cache max=204800 inactive=20s; open_file_cache_min_uses 1; open_file_cache_valid 30s; tcp_nopush on; tcp_nodelay on; keepalive_timeout 5; types_hash_max_size 2048 # add external reference configuration files (single) include / home/conf/system1.conf; # add external reference configuration files (multiple) include / home/conf/*.conf;} from here

The absolute path to the configuration file to be added is written on the linux platform, but in windows, it is theoretically written as

Include D:/Program Files/conf/system1.conf

However, it is not.

1) when writing an include configuration file in nginx.conf under windows, the path cannot contain spaces and Chinese characters, so don't think about Program Files.

2) under windows, the path cannot contain a drive letter, because it looks for paths and files in the linux style, so he only recognizes the path style under linux, so he can only write it in a format similar to / programfile/conf/system1.conf, so how do you know which disk he is in? The answer is: nginx identifies the root directory of the path where the current nginx program is located as the / directory, and regards it as the root directory under linux, for example: nginx is under disk D, then the actual full path of / programfile/conf/system1.conf should be: d:/programfile/conf/system1.conf

Note: this is only the difference in the path writing in the include directive, and in other server instructions, the format of files and directories can normally use the drive letter such as D:\, but also can not have spaces and Chinese.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report