The configuration and configuration files for Windows Nginx are described in the section

Source: Internet
Author: User

First, download the Nginx version of Windows on the official website, download: http://nginx.org/download/

Choose the version you want to download, and unzip the nginx (e.g. nginx-1.6.3) into the directory on your window tray.

Do the following: (You need to remember, it is often used)

Nginx-s Stop//Stop Nginx

Nginx-s Reload//Reload configuration file
Nginx-s quit//exit Nginx

Second, the next step is to configure Nginx conf file. Nginx needs to configure the things that are in the Conf file, now introduced under the following conf file configuration:


#user nobody;
Worker_processes 2; #进程数, the initial can be set to the total number of CPU cores

#error_log Logs/error.log;
#error_log Logs/error.log Notice;
#error_log Logs/error.log Info;

#pid Logs/nginx.pid; #用于管理nginx进程


Events {
Worker_connections 1024; #单个worker进程最大连接数
}


HTTP {
Include Mime.types; #文件扩展名与文件类型映射表
Default_type Application/octet-stream; #默认文件类型

#log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
# ' $status $body _bytes_sent ' $http _referer '
# ' "$http _user_agent" "$http _x_forwarded_for" ';

#access_log Logs/access.log Main;

Sendfile on; #开启高效文件传输模式 to implement kernel 0 copies
#tcp_nopush on;

#keepalive_timeout 0;
Keepalive_timeout 65; #连接超时时间, Unit is seconds

#gzip on;

server {
Listen 8089; #连接的端口号
server_name localhost;
AutoIndex on;
#charset Koi8-r;

#access_log Logs/host.access.log Main;

#下面的就是你接收传输文件的格式要求了, according to your needs to use, below I use to receive pictures (jpg ... )
Location ~. *\. (gif|jpg|jpeg|png|bmp) $ {

expires 24h; #客户端缓存上述静态数据
root c:/resources/images/; #文件路径
Access_log C:/nginx-1.6.3/logs/log_test.log;
Proxy_store on;
proxy_store_access user:rw group:rw all:rw;
Proxy_temp_path c:/resources/images/; #文件路径
proxy_redirect off;

#autoindex on;
proxy_set_header Host 127.0.0.1; #填写你的ip
proxy_set_header x-real-ip $remote _addr;
proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 1280k;
proxy_connect_timeout;
proxy_send_timeout;
proxy_read_timeout;
proxy_buffer_size 400k;
proxy_buffers 320k;
proxy_busy_buffers_size 640k;
proxy_temp_file_write_size 640k;
if (!-e $request _filename)
{
Proxy_pass http://127.0.0.1:8089;
}
}

#下面是我拿来传输mp3格式的配置
Location ~*. (mp3) $ {

expires 24h;
root c:/resources/voice/; #文件路径
Proxy_store on;
proxy_store_access user:rw group:rw all:rw;
Proxy_temp_path c:/resources/voice/; #文件路径
proxy_redirect off;

proxy_set_header Host 127.0.0.1;
proxy_set_header x-real-ip $remote _addr;
proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 1280k;
proxy_connect_timeout;
proxy_send_timeout;
proxy_read_timeout;
proxy_buffer_size 40k;
proxy_buffers 320k;
proxy_busy_buffers_size 640k;
proxy_temp_file_write_size 640k;
if (!-e $request _filename)
{
Proxy_pass http://127.0.0.1:8089;
}
}

Location/{
root HTML;
Index index.html index.htm;
}

#error_page 404/404.html;

# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}

# Proxy The PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# Proxy_pass http://127.0.0.1;
#}

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root HTML;
# Fastcgi_pass 127.0.0.1:9000;
# Fastcgi_index index.php;
# Fastcgi_param Script_filename/scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' s one
#
#location ~/\.ht {
# Deny All;
#}
}


# Another virtual host using mix of ip-, name-, and port-based configuration
#
#server {
# Listen 8000;
# Listen somename:8080;
# server_name somename alias Another.alias;

# location/{
# root HTML;
# index index.html index.htm;
# }
#}

#下面是配置https
# HTTPS Server
#
#server {
# Listen 443 SSL;
# server_name localhost;

# ssl_certificate Cert.pem;
# Ssl_certificate_key Cert.key;

# Ssl_session_cache shared:ssl:1m;
# ssl_session_timeout 5m;

# ssl_ciphers high:!anull:! MD5;
# ssl_prefer_server_ciphers on;

# location/{
# root HTML;
# index index.html index.htm;
# }
#}

}

3. Precautions

Problems that you may encounter:

1. After configuring Conf, you start the nginx can not boot, the description is your conf file configuration error, you need to go back to check. For example {} Less, file path name is not correct and so on.

2. The entire configuration file for HTTP and HTTPS is sometimes used as needed. You just need to configure the contents of HTTP {} inside and https{}.

The configuration and configuration files for Windows Nginx are described in the section

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.