Configure Nginx web caching time!

 

[root@localhost html]# vim /etc/nginx.conf 

user  nginx nginx;
worker_processes  1;

error_log  logs/error.log;
error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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;
    server_tokens off;
    keepalive_timeout  65;

server {
        listen       80;
          server_name localhost;

       charset utf-8;

location / {
         root html;
       index index.html index.htm;
  }
location ~\.\(gif|jpg|jpeg|png|bmp|ico)${
       expires ld;
}
location ~*\.(js|css)$ {
      expires 1h;
}

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

}

}

[root@localhost nginx-1.16.0]# cd
[root@localhost ~]# cd /usr/local/nginx/html/

导入图片
[root@localhost html]# rz
z waiting to receive.**B0100000023be50
[root@localhost html]# ls
50x.html index.html linux.jpg

[root@localhost html]# vim index.html

Add the following code at the end:

<p><em>Thank you for using nginx.</em></p>
<img src='linux.jpg'/>
</body>
</html>
~                 

[root @ localhost HTML] # killall -s HUP nginx                           // restart configuration

 

 

Guess you like

Origin www.cnblogs.com/cxm123123form/p/11513117.html