Installation and configuration of Nginx under Windows

Source: Internet
Author: User
Nginx ("Engine X") is a high-performance, lightweight HTTP WEB server and a reverse proxy server and an e-mail imap/pop3/smtp proxy server.


Nginx was developed by the Russian program designer Igor Sysoev and developed for the second rambler.ru site in Russia, which has been running for more than four years at the site, and Igor publishes the source code in the form of a BSD-like license.


Since the Nginx release for four years, Nginx has been known for its stability, rich feature sets, sample configuration files, and low system resource consumption. Nginx surpasses Apache's high performance and stability, making it more and more Web sites that use Nginx as a Web server in China.


At present, the major domestic portal sites have been deployed Nginx, such as Sina, NetEase, Tencent, etc., newly discovered Nginx technology in the domestic increasingly hot, more and more sites began to apply the deployment of Nginx.


First, go to the official website to download nginx version of Windows, official website download: http://nginx.org/download/(to select the zip version)


After downloading to the package, unzip the Nginx-nginx1.0.11.zip package to your favorite root directory and change the directory name to Nginx.


Then, do the following:


CD nginx//switch to the folder where Nginx resides


Start Nginx


In this way, the Nginx service is started. Open Task Manager, view the Nginx.exe process, there are two processes will show, occupy system resources, that is quite small. Then open the browser, input HTTP://127.0.0.1/will be able to see the Nginx Welcome page, Very friendly


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


Note: If the login http://127.0.0.1/fails, there may be other Web servers already occupied (such as IIS, Appache, etc.). At this point, please open the nginx.conf file under nginx\conf and change listen 80 to another port, such as Listen 28000. Then start Nginx again, and take http://127.0.0.1:28000/. If successful, it will enter the Nginx Welcome screen (This screen corresponds to the index.html page under nginx\html).




Second, the next is to configure the Nginx conf file. Here's my configuration:
#user nobody;
Worker_processes 1;


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


#pid Logs/nginx.pid;




Events {
Worker_connections 1024;
}




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;
#tcp_nopush on;


#keepalive_timeout 0;
Keepalive_timeout 65;


#gzip on;


server {
Listen 28000;
server_name localhost;


#charset Koi8-r;


#access_log Logs/host.access.log Main;


Location ~* software/(. *). *\. (Jpg|rar)
{
Expires 21d;
Root d:/temp/;
Access_log D:/temp/soft.3g.cn_nginx_s3gd-205.log;
Proxy_store on;
Proxy_store_access USER:RW GROUP:RW ALL:RW;
Proxy_temp_path d:/temp/;
Proxy_redirect off;


Proxy_set_header Host 112.25.10.140;
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 900;
Proxy_send_timeout 900;
Proxy_read_timeout 900;
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://112.25.10.140:80;
}
}


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 Server
#
#server {
# Listen 443;
# server_name localhost;


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


# ssl_session_timeout 5m;


# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers high:!anull:! MD5;
# ssl_prefer_server_ciphers on;


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


}
Related Article

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.