Use nginx on windows and make basic configuration

Hits: 0

[Use nginx] on windows and make basic configuration

Preliminary preparation

nginx download address
It is recommended to download the stable version. After downloading, you can decompress it. The decompressed file directory should not contain Chinese. Go
to the decompressed folder and go
to the conf folder. Edit nginx.conf
as follows, it is best to modify the startup port of nginx

events {
    worker_connections  1024;

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;

    server {
         #This is the port where nginx runs, it is best to modify it, port 80 is easy to conflict 
        listen        8081 ;
         server_name   localhost;
         #Access / will jump to index.html in the html directory 
        location / {
              root    html;
             index   index.html ;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;

start nginx

Go to the decompression directory of nginx, enter cmd in the address bar, and then enter the following to start

start nginx

Visit http://localhost:8081/ and the following page appears, indicating that the startup is successful, where 8081 is the port number you set yourself

Common commands

nginx  -s stop stop

nginx  -s quit exit safely

nginx  -s reload reload the configuration file

The nginx -s reload command is used more often. After modifying the nginx.conf file, it needs to be reloaded. If it does not work once, reload it several times.

You may also like...

Leave a Reply

Your email address will not be published.