One, download Nginx deployment package
To the Nginx website to download an NGINX deployment package under the Windows platform, I am currently downloading a nginx-1.6.2 version.
Second, the command to start the service
Start: Start Nginx.exe
Stop: Nginx-s stop
Reload: Nginx-s Reload
Iii. Construction of examples
Preferred: We are going to deploy our well-done Web application on our IIS, deploy it to different machines, set the corresponding IP and port number, because I am simulating the effect on this machine, so I deployed 2 Web applications on this computer. The first Web application was deployed on the localhost:8011 port, the second application was deployed as a localhost:8012 port, and in order to see the demo, we made a tag inside the WebForm1.aspx page labeled: The pages of the Web application, the actual deployment of the system, we do not need to do this is to deploy one of our Web applications on the server above the different machines, as shown below.
Web Application 1 Address: http://localhost:8011/WebForm1.aspx
Web application 2 Address: http://localhost:8012/WebForm1.aspx
(1) Start Nginx Service
(2) Modify the Nginx configuration, specific configuration instructions, we set the parameters in the department description, and then verify that the service started normally.
(3) Access address http://localhost:8010/WebForm1.aspx observation results
(4) So we can simulate the load-balancing effect, OK
Iv. Other Notes
(1) Configure the domain name access: First we want to add the domain name setting in Nginx, next we want to set the 127.0.0.1 map to the domain name in the native machine
So we can access this: http://huangxiang:8010/WebForm1.aspx
(2) Configure the number of processes that Ngnix starts, and we can focus on the number of process changes in the process
Five, parameter setting
[JavaScript]View Plaincopyprint?
- #定义Nginx运行的用户和用户组
- #user nobody;
- #Nginx进程数, the recommendation is consistent with the CPU's total kernel
- Worker_processes 2;
- #error_log Logs/error.log;
- #error_log Logs/error.log Notice;
- #error_log Logs/error.log Info;
- #pid Logs/nginx.pid;
- Events {
- #定义单个进程的最大连接数 (the actual maximum number of connections is divided by 2)
- Worker_connections 1024;
- }
- #定义http服务器
- 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;
- #服务器的集群
- Upstream huangxiang.com {#服务器集群名字
- #server 172.16.21.13:8081 weight=1, #服务器配置 weight is the weight, the larger the weight, the greater the probability of distribution.
- #server 192.168.1.186:8081 weight=1;
- #server 172.16.1.14:8081 weight=2;
- #server 172.16.1.15:8081 weight=1;
- #server 172.16.1.15:80 weight=1;
- Server 127.0.0.1:8011 weight=1;
- Server 127.0.0.1:8012 weight=2;
- }
- #虚拟机主机配置
- server {
- Listen 8010; #端口号
- server_name localhost huangxiang.com; #域名可以有多个, multiple separated by spaces
- #charset Koi8-r;
- #access_log Logs/host.access.log Main;
- #location/{
- # root HTML;
- # index index.html index.htm;
- #}
- Location/{
- Proxy_pass http://huangxiang.com;
- Proxy_redirect default;
- }
- #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 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;
- # }
- #}
- }
Use Nginx load balancer to build high performance. Netweb Application II