1. 正向代理,意思是一個位於客戶端和原始服務器(origin server)之間的服務器,爲了從原始服務器取得內容,客戶端向代理髮送一個請求並指定目標(原始服務器),而後代理向原始服務器轉交請求並將得到的內容返回給客戶端。javascript
訪問google使用代理服務器php
2. 反向代理(Reverse Proxy)方式是指以代理服務器來接受internet上的鏈接請求,而後將請求轉發給內部網絡上的服務器,並將從服務器上獲得的結果返回給internet上請求鏈接的客戶端,此時代理服務器對外就表現爲一個反向代理服務器css
代理訪問本身的內部服務器html
Nginx由內核和模塊組成,其中,內核的設計很是微小和簡潔,完成的工做也很是簡單,僅僅經過查找配置文件將客戶端請求映射到一個location block(location是Nginx配置中的一個指令,用於URL匹配),而在這個location中所配置的每一個指令將會啓動不一樣的模塊去完成相應的工做。前端
Nginx的模塊從結構上分爲核心模塊、基礎模塊和第三方模塊:
核心模塊:HTTP模塊、EVENT模塊和MAIL模塊
基礎模塊:HTTP Access模塊、HTTP FastCGI模塊、HTTP Proxy模塊和HTTP Rewrite模塊,
第三方模塊:HTTP Upstream Request Hash模塊、Notice模塊和HTTP Access Key模塊。java
Nginx的高併發得益於其採用了epoll模型,與傳統的服務器程序架構不一樣,epoll是linux內核2.6之後纔出現的。Nginx採用epoll模型,異步非阻塞,而apache採用的是select模型:
Select特色:select 選擇句柄的時候,是遍歷全部句柄,也就是說句柄有事件響應時,select須要遍歷全部句柄才能獲取到哪些句柄有事件通知,所以效率是很是低。
epoll的特色:epoll對於句柄事件的選擇不是遍歷的,是事件響應的,就是句柄上事件來就立刻選擇出來,不須要遍歷整個句柄鏈表,所以效率很是高。node
Nginx ("engine x") 是一個高性能的HTTP和反向代理服務器,也是一個 IMAP/POP3/SMTP 代理服務器。 Nginx 是由 Igor Sysoev 爲俄羅斯訪問量第二的 Rambler.ru 站點開發的,第一個公開版本0.1.0發佈於2004年10月4日。其將源代碼以類BSD許可證的形式發佈,因它的穩定性、豐富的功能集、示例配置文件和低系統資源的消耗而聞名linux
常見的應用服務器: Apache/Microsoft IIS/Tomcat/Lighttpd/Nginxnginx
特色:Nginx特色是佔有內存少,併發能力強,事實上nginx的併發能力確實在同類型的網頁服務器中表現較好 web
組成:Nginx由內核和模塊組成,其中,內核的設計很是微小和簡潔,完成的工做也很是簡單
核心模塊:HTTP模塊、EVENT模塊和MAIL模塊
基礎模塊:HTTP Access模塊、HTTP FastCGI模塊、HTTP Proxy模塊和HTTP Rewrite模塊,
第三方模塊:HTTP Upstream Request Hash模塊、Notice模塊和HTTP Access Key模塊。
1)高併發響應性能很是好,官方Nginx處理靜態文件併發5w/s
2)反向代理性能很是強。(可用於負載均衡)
3)內存和cpu佔用率低。(爲Apache的1/5-1/10)
4)對後端服務有健康檢查功能。
5)支持PHP cgi方式和fastcgi方式。
6)配置代碼簡潔且容易上手。
說明:處理靜態文件是nginx最主要的功能
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
檢查系統裏是否安裝了pcre軟件
rpm -qa pcre 若是沒有顯示說明沒有安裝 反之安裝過
rpm -e --nodeps pcre 刪除pcre
安裝pcre:yum install pcre-devel pcre -y
#下載Nginx源碼包
cd /usr/local
wget http://nginx.org/download/nginx-1.9.0.tar.gz
#解壓Nginx源碼包
tar -zxvf nginx-1.9.0.tar.gz
#進入解壓目錄,開始安裝,默認安裝地址 /usr/local/nginx
cd nginx-1.9.0
./configure --prefix=/usr/local/nginx --with-http_ssl_module &&make &&make install
#自此Nginx安裝完畢
檢查nginx配置文件是否正確,返回OK即正確。
/usr/local/nginx/sbin/nginx -t
#而後啓動nginx,
/usr/local/nginx/sbin/nginx 回車便可。
#查看進程是否已啓動:
ps aux |grep nginx
刪除nginx文件便可
rm -rf /usr/local/nginx
查看nginx進程:
ps -ef|grep nginx或者ps aux |grep nginx
說明:nginx的進程由主進程和工做進程組成。
啓動nginx:
/usr/local/nginx/sbin/nginx
說明:啓動結果顯示nginx的主線程和工做線程,工做線程的數量跟nginx.conf中的配置參數worker_processes有關。
平滑啓動nginx:
kill -HUP 'cat /var/run/nginx.pid'
或者
/usr/local/nginx/sbin/nginx -s reload
其中進程文件路徑在配置文件nginx.conf中能夠找到。
平滑啓動的意思是在不中止nginx的狀況下,重啓nginx,從新加載配置文件,啓動新的工做線程,完美中止舊的工做線程。
完美中止nginx:
kill -QUIT 'cat /var/run/nginx.pid'
快速中止nginx :
kill -TERM 'cat /var/run/nginx.pid'
或者
kill -INT `cat /var/run/nginx.pid`
完美中止工做進程(主要用於平滑升級):
kill -WINCH 'cat /var/run/nginx.pid'
強制中止nginx:
pkill -9 nginx
檢查對nginx.conf文件的修改是否正確:
nginx -t -c /etc/nginx/nginx.conf 或者 /usr/local/nginx/sbin/nginx -t
中止nginx的命令:
/usr/local/nginx/sbin/nginx -s stop
查看nginx的版本信息:
/usr/local/nginx/sbin/nginx -v
查看完整的nginx的配置信息:
/usr/local/nginx/sbin/nginx -V
下載所需版本的Nginx:
wget http://www.nginx.org/download/nginx-1.4.2.tar.gz
獲取舊版本nginx的configure選項:
/usr/local/nginx/sbin/nginx -V
編譯新版本的nginx
tar -xvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
make
備份舊版本的nginx可執行文件,複製新版本的nginx可執行文件:
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
cp objs/nginx /usr/local/nginx/sbin/
測試新版本nginx是否正常:
/usr/local/nginx/sbin/nginx -t
平滑重啓升級nginx:
kill –USR2 `cat /usr/local/nginx/log/nginx.pid`
舊版本Nginx的pid變爲oldbin,這是舊版本和新版本的nginx同時運行,過一段時間等舊nginx處理完用戶請求後,執行下面操做
從容關閉舊版本的Nginx進程
kill -WINCH `cat /usr/local/nginx/log/nginx.oldbin`
決定是否升級到新版的nginx:
kill –HUP `cat /usr/local/nginx/log/nginx.oldbin` ##nginx在不重載配置文件啓動工做進程
kill –QUIT `cat /usr/local/nginx/log/nginx.oldbin` ##關閉舊版nginx
驗證nginx是否升級成功
/usr/local/nginx/sbin/nginx –V ###顯示下圖則升級成功
說明:
在nginx的nginx.conf裏面監聽80端口,並配置後端tomcat的地址,前端訪問的時候便可轉發到後端的tomcat
8080的server.xml文件
<Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!--APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --> <Listener className="org.apache.catalina.core.JasperListener" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html --> <Service name="Catalina"> <!--The connectors can use a shared executor, you can define one or more named thread pools--> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- Define a SSL HTTP/1.1 Connector on port 8443 This connector uses the BIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> --> <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html --> <!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server>
8081的server.xml文件
<Server port="8006" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!--APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --> <Listener className="org.apache.catalina.core.JasperListener" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html --> <Service name="Catalina"> <!--The connectors can use a shared executor, you can define one or more named thread pools--> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- Define a SSL HTTP/1.1 Connector on port 8443 This connector uses the BIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> --> <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html --> <!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server>
tomcat-8080/webapps/ROOT
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="renderer" content="webkit"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <title>test</title> </head> <body> 歡迎來到8080端口tomcat </body> </html>
tomcat-8081/webapps/ROOT
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="renderer" content="webkit"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <title>test</title> </head> <body> 歡迎來到8081端口tomcat </body> </html>
user root root; #使用什麼用戶啓動NGINX 在運行時使用哪一個用戶哪一個組 worker_processes 4; #啓動進程數,通常是1或8個,根據你的電腦CPU數,通常8個 worker_cpu_affinity 00000001 00000010 00000100 00001000; #CPU邏輯數——把每一個進程分別綁在CPU上面,爲每一個進程分配一個CPU #pid /usr/local/nginx/logs/nginx.pid worker_rlimit_nofile 102400; #一個進程打開的最大文件數目,與NGINX併發鏈接有關係 #工做模式及鏈接數上限 events { use epoll; #多路複用IO 基於LINUX2.6以上內核,能夠大大提升NGINX的性能 uname -a查看內核版本號 worker_connections 102400; #單個worker process最大鏈接數,其中NGINX最大鏈接數=鏈接數*進程數,通常1GB內存的機器上能夠打開的最大數大約是10萬左右 multi_accept on; #儘量多的接受請求,默認是關閉狀態 } #處理http請求的一個應用配置段 http { #引用mime.types,這個類型定義了不少,當web服務器收到靜態的資源文件請求時,依據請求文件的後綴名在服務器的MIME配置文件中找到對應的MIME #Type,根據MIMETYPE設置並response響應類型(Content-type) include mime.types; default_type application/octet-stream; #定義的數據流,有的時候默認類型能夠指定爲text,這跟咱們的網頁發佈仍是資源下載是有關係的 fastcgi_intercept_errors on; #表示接收fastcgi輸出的http 1.0 response code charset utf-8; server_names_hash_bucket_size 128; #保存服務器名字的hash表 #用來緩存請求頭信息的,容量4K,若是header頭信息請求超過了,nginx會直接返回400錯誤,先根據client_header_buffer_size配置的值分配一個buffer,若是##分配的buffer沒法容納request_line/request_header,那麼就會##再次根據large_client_header_buffers配置的參數分配large_buffer,若是large_buffer仍是無#法容納,那麼就會返回414(處理request_line)/400(處理request_header)錯誤。 client_header_buffer_size 4k; large_client_header_buffers 4 32k; client_max_body_size 300m; #容許客戶端請求的最大單文件字節數 上傳文件時根據需求設置這個參數 #指定NGINX是否調用這個函數來輸出文件,對於普通的文件咱們必須設置爲ON,若是NGINX專門作爲一個下載端的話能夠關掉,好處是下降磁盤與網絡的IO處理數及#系統的UPTIME sendfile on; #autoindex on;開啓目錄列表訪問,適合下載服務器 tcp_nopush on; #防止網絡阻塞 #很是重要,根據實際狀況設置值,超時時間,客戶端到服務端的鏈接持續有效時間,60秒內可避免從新創建鏈接,時間也不能設太長,太長的話,若請求數10000##,都佔用鏈接會把服務託死 keepalive_timeout 60; tcp_nodelay on; #提升數據的實時響應性 client_body_buffer_size 512k; #緩衝區代理緩衝用戶端請求的最大字節數(請求多) proxy_connect_timeout 5; #nginx跟後端服務器鏈接超時時間(代理鏈接超時) proxy_read_timeout 60; #鏈接成功後,後端服務器響應時間(代理接收超時) proxy_send_timeout 5; #後端服務器數據回傳時間(代理髮送超時) proxy_buffer_size 16k; #設置代理服務器(nginx)保存用戶頭信息的緩衝區大小 proxy_buffers 4 64k; #proxy_buffers緩衝區,網頁平均在32k如下的話,這樣設置 proxy_busy_buffers_size 128k; #高負荷下緩衝大小 proxy_temp_file_write_size 128k; #設定緩存文件夾大小,大於這個值,將從upstream服務器傳 gzip on; #NGINX能夠壓縮靜態資源,好比個人靜態資源有10M,壓縮後只有2M,那麼瀏覽器下載的就少了 gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; #壓縮級別大小,最小1,最大9.值越小,壓縮後比例越小,CPU處理更快,爲1時,原10M壓縮完後8M,但設爲9時,壓縮完可能只有2M了。通常設置爲2 gzip_types text/plain application/x-javascript text/css application/xml; #壓縮類型:text,js css xml 都會被壓縮 gzip_vary on; #做用是在http響應中增長一行目的是改變反向代理服務器的緩存策略 #日誌格式 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' #ip 遠程用戶 當地時間 請求URL '$status $body_bytes_sent "$http_referer" ' #狀態 發送的大小 響應的頭 '"$http_user_agent" $request_time'; #客戶端使用的瀏覽器 頁面響應的時間 #動態轉發 upstream web1 { #每一個請求按訪問ip的hash結果分配,這樣每一個訪客固定訪問一個後端服務器,能夠解決session的問題。配置了ip_hash就沒有負載均衡的效果了,每次訪問的都是同一個tomcat #ip_hash; #轉發的後端的tomcat服務器,weight表示轉發的權重,越大轉發的次數越多,機器性能不同配置的weight值不同 server 127.0.0.1:8080 weight=1 max_fails=2 fail_timeout=30s; server 127.0.0.1:8081 weight=1 max_fails=2 fail_timeout=30s; } upstream web2 { server 127.0.0.1:8090 weight=1 max_fails=2 fail_timeout=30s; server 127.0.0.1:8091 weight=1 max_fails=2 fail_timeout=30s; } server { listen 80; #監聽80端口 server_name www.dbspread.com; #域名 index index.jsp index.html index.htm; root /usr/local/nginx/html; #定義服務器的默認網站根目錄位置 #監聽完成之後經過斜杆(/)攔截請求轉發到後端的tomcat服務器 location / { #若是後端的服務器返回50二、504、執行超時等錯誤,自動將請求轉發到upstream負載均衡池中的另外一臺服務器,實現故障轉移。 proxy_next_upstream http_502 http_504 error timeout invalid_header; proxy_set_header Host $host; #獲取客戶端的主機名存到變量Host裏面,從而讓tomcat取到客戶端機器的信息 proxy_set_header X-Real-IP $remote_addr; #獲取客戶端的主機名存到變量X-Real-IP裏面,從而讓tomcat取到客戶端機器的信息 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://web1; #跳轉到對應的應用web1 } # location ~ .*\.(php|jsp|cgi|shtml)?$ #動態分離 ~匹配 以.*結尾(以PHP JSP結尾走這段) # { # proxy_set_header Host $host; # proxy_set_header X-Real-IP $remote_addr; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # proxy_pass http://jvm_web2; # } #靜態分離 ~匹配 以.*結尾(以PHP JSP結尾走這段),固然不是越久越好,若是有10000個用戶在線,都保存幾個月,系統託跨 location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ { root /var/local/static; expires 30d; } #日誌級別有[debug|info|notice|warn|error|crit] error_log 級別分爲 debug, info, notice, warn, error, crit 默認爲crit, 生產環境用error #crit 記錄的日誌最少,而debug記錄的日誌最多 access_log /usr/local/logs/web2/access.log main; error_log /usr/local/logs/web2/error.log crit; } }
說明:nginx配置文件的解析流程
/usr/local/nginx/sbin/nginx
192.168.152.129 www.dbspread.com
首次進入效果:
再次刷新頁面效果