preface

Good attitude, not so tired. In a good mood, all you see is beautiful scenery.

"If you can't solve a problem for a while, use this opportunity to see your limitations and put yourself out of order." As the old saying goes, it's easy to let go. If you are distracted by something, learn to disconnect. Cut out the paranoia, the trash in the community, and get rid of the negative energy. Good attitude, not so tired. In a good mood, all you see is beautiful scenery.

Nginx series: install and configure Nginx for windows10. Do not like spray, if there are objections welcome to discuss!


windows10System InstallationNginx

Open thenginxThe website:nginx.org/To download the latest stable version.

Click to download it according to the version. Here, the blogger choosesNginx - 1.12.2downloadThe Windows version

Or click Download on the home page to download the historical stable version

After downloading, unzip to the file path you want to unzip, I unzip to disk D, and change the file name tonginx; Enter the file, opennginx.exeFile, a flash page will appear, and then open any browser, typelocalhostIf the following page is displayed, the installation is successful.

If no, the installation is not successful. throughcmd.exeCome to seenginxWhether the installation is successful and where the error is. Open thecmdAfter, type D :(your installation directory where to enter which), and then typecd nginx, continue typingnginxIf the installation is not successful, there will be feedback error. My error is:[emery] Blind () to 0.0.0.0:80 Failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)

Port 80 is occupied by another program.

The solution:Run regedit as administrator open key :HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP Find Start on the right and change it to 0 to restart the SYSTEM. SYSTEM processes will not occupy port 80.

Restart your browser and type localhost. The following page appears:

You can also enter commands in the CMD command windowtasklist /fi "imagename eq nginx.exe"If the following information is displayed, the system is successfully started

The configuration file of nginx is nginx.conf in the conf directory. By default, nginx is configured to listen on port 80. If port 80 is occupied, you can change it to an unused port

** To check whether port 80 is occupied, run the following command:Netstat ano | findstr searches 0.0.0.0:80 or netstat ano | findstr searches "80"ζ°‘θΏεˆ†ε­

When we modifyNginx configuration file nginx.confWhen, do not need to closenginxPost rebootnginx, just execute the commandnginx -s reloadTo make the change take effect


Shut downnginx

** If you use the CMD command window to start nginx, closing the CMD window does not end the nginx process. There are two ways to stop nginx **

(1) Enter the nginx command nginx -s stop(quick stop nginx) or nginx -s quit(complete orderly stop nginx)

Taskkill taskkill /f /t /im nginx.exe


usenginxProxy servers perform load balancing

We can modify the nginx configuration file nginx.conf to redirect to the specified server when accessing the nginx proxy server, that is, to configure the request forwarding address through proxy_pass, that is, when we still enter http://localhost:80, The request is redirected to the server we configured

Similarly, we can configure multiple target servers, and when one server fails,nginxCan automatically redirect requests to another server, for example:

When the serverocalhost:8080Hang up,nginxCan redirect requests to the server automatically192.168.101.9:8080. There’s another one on topweightProperty representing the weight to which each server is accessed,weightThe higher the height, the higher the chance of being visited.


NginxConfiguring Static Resources

The static resources (such as JPG | PNG | | js, CSS, etc.) on the following configurationF: / nginx - 1.12.2 / staticDirectory, and then innginxDo the following configuration in the configuration file (note: Static resource configuration can only be placed inlocation / In), accessed in the browserhttp://localhost:80/1.pngAccess toF: / nginx - 1.12.2 / staticIn the directory1.pngThe picture


πŸŽ‰ summary:

  • For more references, see here:The Blog of Chan Wing Kai

  • Like the small partner of the blogger can add a concern, a thumbs-up oh, continue to update hey hey!