Heim  >  Artikel  >  Betrieb und Instandhaltung  >  So optimieren Sie die Konfiguration des Nginx-Dienstes

So optimieren Sie die Konfiguration des Nginx-Dienstes

WBOY
WBOYnach vorne
2023-05-21 22:55:101597Durchsuche

1. Läuft das Cache-Modul ab

So optimieren Sie die Konfiguration des Nginx-Dienstes

Informationen zur spezifischen Konfiguration finden Sie in der offiziellen Dokumentation Starten Sie den Dienst neu

[root@cairui conf]# cat nginx.conf | egrep -v "#|^$"
user nginx;
worker_processes 1;
events {
  worker_connections 1024;
}
http {
  include    mime.types;
  default_type application/octet-stream;
  sendfile    on;
  keepalive_timeout 65;
  server {
    listen    80;
    server_name localhost;
    location / {
      root  html;
      index index.html index.htm;
    }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|html|htm|css)$ {
   log_not_found off;
   expires 7d ;
   access_log off;
   proxy_store on;
   proxy_store_access user:rw group:rw all:rw;
}
    error_page  500 502 503 504 /50x.html;
    location = /50x.html {
      root  html;
    }
  }
}

[root@cairui conf]# curl -i http://120.25.255.87/1.jpg
http/1.1 200 ok
server: nginx/1.13.9
date: mon, 05 mar 2018 04:08:41 gmt
content-type: image/jpeg
content-length: 48561
last-modified: wed, 29 nov 2017 08:16:39 gmt
connection: keep-alive
etag: "5a1e6ce7-bdb1"
expires: mon, 12 mar 2018 04:08:41 gmt
cache-control: max-age=604800
accept-ranges: bytes

Das obige ist der detaillierte Inhalt vonSo optimieren Sie die Konfiguration des Nginx-Dienstes. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:yisu.com. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen