nginx learning Chapter III

First, the system environment

ubuntu6.4 system

nginx 版本: nginx / 1.10.3 (Ubuntu).

 

Second, turn on directory browsing
Nginx default is not allowed to list the entire directory. For this, edit the virtual host configuration file, add in the location server or http segment
autoindex on;
the other two parameters is best to also add:
autoindex_exact_size OFF;
default is on, showing the exact size of the file, the unit is bytes.
Later changed to off, the file shows the approximate size of the unit is kB or MB or GB
autoindex_localtime ON;
the default is off, the display file times are GMT time.
After the change on, the time display of the file as a file server time

 

Third, modify the configuration nginx.conf

1, modify configuration files nginx

user root root;     # CGI scripts needs root permisions
worker_processes 2; # 2 workers should be enough
pid /run/nginx.pid;
worker_cpu_affinity 11110101 11111010;

error_log /dev/null crit;

events {
    worker_connections 1024;
    use epoll;
}

# rtmp module
#include rtmp.conf;

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    index index.html;
    
    server {
        Logging Settings # 
        rewrite_log ON; 
        access_log / var / log / nginx / access.log; 
        error_log / var / log / nginx / error.log; 
        the listen           80 ; 
        server_name localhost; 
        access_log OFF; 

        ## browser to access the directory parameter 
        autoindex ON;    

        # startup directory # set 
        the root     / var / WWW / HTML; 

        error_page 404 / 404 .html; 
        LOCATION = / 40x.html { 
        } 
        error_page 500  502  503  504 / 50x.html;
        location = /50x.html {
            root /share;
        }
    }

}

 

If the local ip address is 192.168.4.1, enter in your browser http://192.168.4.1:80

If you have index.html file systems under Linux / var / www / html directory, the browser displays the contents of the index.html file, otherwise display files in a directory

Guess you like

Origin www.cnblogs.com/carriezhangyan/p/11840935.html