Install nginx in Windows XP

Source: Internet
Author: User
Tags epoll sendfile
Install nginx in Windows XP. First, go to the official website to download the Windows version of nginx. download from the official website: http://nginx.org/download/ After downloading the software package, decompress the nginx-nginx.zip package to your favorite root directory and change the directory name to nginx. Install nginx under www.2cto.com... Window XP 1. first download the nginx Windows version from the official website. download it from the official website: http://nginx.org/download/ After downloading to the package, unzip the nginx-nginx.zip package to your preferred root directory and change the directory name to nginx. Www.2cto.com note: it must not be placed in the Chinese Directory. Otherwise, it will fail when you start! I directly put it on the drive D. then, perform the following operations: cd nginxstart nginx, and then the nginx service starts. Open the Task Manager and check the nginx.exe process. two processes are displayed, occupying system resources, which is quite small. Then open the browser and enter http://127.0.0.1/ You can see the nginx welcome page, nginx-s stop // stop nginxnginx-s reload // reload the configuration file nginx-s quit // exit nginx 2. configure the nginx conf file and run www.2cto.com #. user www-data; # start the process. generally, worker_processes 1 is set to be equal to the number of CPUs; # the global error log and PID file error_log/var/log/nginx/error. log; pid/var/run/nginx. pid; # working mode and maximum number of connections events {use epoll; # epoll is a method in Multiplexing I/O Multiplexing, but it is only used in Linux or later kernels, this greatly improves nginx performance by worker_connections 1024; # A single backend worker The maximum number of concurrent connections of the process # multi_accept on;} # sets the http server. with its reverse proxy function, server load balancer supports http {# sets the mime type, which is determined by mime. the type file defines include/etc/nginx/mime. types; default_type application/octet-stream; # set the log format access_log/var/log/nginx/access. log; # The sendfile command specifies whether nginx calls the sendfile function (zero copy mode) to output files. for common applications, # it must be set to on, if it is used for application disk I/O heavy load applications such as downloading, you can set it to off to balance the disk and network I/O processing speed and reduce the system's uptime. sendfile on; # tcp_nopush on; # connection timeout # keepalive_ti Meout 0; keepalive_timeout 65; tcp_nodelay on; # enable gzip compression gzip on; gzip_disable "MSIE [1-6] \. (?!. * SV1) "; # set the request buffer client_header_buffer_size 1 k; large_client_header_buffers 4 4 4 k; include/etc/nginx/conf. d /*. conf; include/etc/nginx/sites-enabled/*; # set the server list of server load balancer upstream mysvr {# The weigth parameter indicates the weight value, the higher the weight, the higher the chance of being allocated to it # enable port 3128 of server 192.168.8.1: 3128 weight = 5 on Squid on the local machine; server 192.168.8.2: 80 weight = 1; server 192.168.8.3: 80 weight = 6;} server {# listen to port 80 listen 80; # define using www.xx.com to access server_name www.xx.com; # set Access log access_log logs/www.xx.com. access. log main; # default request location/{root/root; # define the default website root directory location index of the server. php index.html index.htm; # define the name of the homepage index file fastcgi_pass www.xx.com; fastcgi_param SCRIPT_FILENAME $ document_root/$ fastcgi_script_name; include/etc/nginx/fastcgi_params ;} # define the error prompt page error_page 500 502 503 504/50 x.html; location =/50x.html {root/root;} # handle the static file by nginx ~ ^/(Images | javascript | js | css | flash | media | static)/{root/var/www/virtual/htdocs; # The static file is not updated for 30 days after expiration, you can set the expiration time to a larger value. you can set the expiration time to a smaller value if it is updated frequently. Expires 30d;} # All PHP script requests are forwarded to FastCGI for processing. use FastCGI default configuration. location ~ \. Php $ {root/root; fastcgi_pass 127.0.0.1: 9000; fastcgi_index index. php; fastcgi_param SCRIPT_FILENAME/home/www $ packages; include fastcgi_params;} # set the address location/NginxStatus {stub_status on; access_log on; auth_basic "NginxStatus "; auth_basic_user_file conf/htpasswd;} # access prohibited. htxxx file location ~ /\. Ht {deny all ;}} and above are some basic configurations. The biggest advantage of using Nginx is that if you want to use server load balancer, you can modify the configuration of the http node as follows: # set the http server and use its reverse proxy function to provide load balancing support for http {# set the mime type, which is determined by mime. the type file defines include/etc/nginx/mime. types; default_type application/octet-stream; # set the log format access_log/var/log/nginx/access. log; # omitting some of the preceding configuration nodes #.......... # Set the server list of the server load balancer (www.2cto.com upstream mysvr {# weigth parameter) to indicate the weight. the higher the weight, the higher the probability of being allocated to the server 192.168.8.1x: 3128 weight = 5; # enable port 3128 of server 192.168.8.2x: 80 weight = 1; server 192.168.8.3x: 80 weight = 6;} upstream mysvr2 {# The weigth parameter indicates the weight, the higher the weight, the higher the probability of being allocated to the server. the higher the weight, the higher the server 192.168.8.x: 80 weight = 1; server 192.168.8.x: 80 weight = 6 ;} # The first virtual server {# listens to port 80 of 192.168.8.x listen 80; server_name 192.168.8.x; # performs load balancing request lo for the aspx suffix Cation ~. * \. Aspx $ {root/root; # define the default website root directory location of the server index. php index.html index.htm; # define the name of the home index file proxy_pass http://mysvr # Redirect requests to the list of servers defined by mysvr # The following are some reverse proxy configurations that can be deleted. proxy_redirect off; # The backend Web server can use X-Forwarded-For to obtain the user's Real IP address proxy_set_header Host $ host; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ bytes; client_max_body_size 10 m; # maximum number of single-file bytes allowed For client requests client_body_buffer_size 128 k; # maximum number of bytes For buffer client requests, proxy_connect_timeout 90; # nginx and backend server connection timeout (proxy connection timeout) proxy_send_timeout 90; # backend server data return time (proxy sending timeout) proxy_read_timeout 90; # After successful connection, response time of the backend server (proxy receiving timeout) proxy_buffer_size 4 k; # set the buffer size proxy_buffers 4 32 k for the proxy server (nginx) to save user header information; # proxy_buffers buffer, set proxy_busy_buffers_size 64 k; # proxy_temp_file_write_size 64 k under high load (proxy_buffers * 2) proxy_temp_file_write_size 64 k; # set the cache folder size, greater than this value, will be uploaded from upstream server }}}

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.