a.上面博客說了在Linux中安裝nginx。
b.當(dāng)Nginx安裝完畢后,會(huì)有相應(yīng)的安裝目次,安裝目次里的nginx.confg為nginx的主設(shè)置文件,nginx主設(shè)置文件分為4部門,main(全局設(shè)置)、server(主機(jī)設(shè)置)、upstream(負(fù)載平衡處事器配置)以及l(fā)ocation(URL匹配特定位置的配置),這四者的干系是:server擔(dān)任main,location擔(dān)任server,upstream既不會(huì)擔(dān)任其它配置也不會(huì)被擔(dān)任。
c.Nginx是一個(gè)署理處事器,一般環(huán)境下,網(wǎng)站是不能陳設(shè)在Nginx下的,好比用Java開拓的JavaWeb措施,我們陳設(shè)在tomcat下,德國機(jī)房主機(jī) 波蘭服務(wù)器,然后利用Nginx署理將網(wǎng)址指向tomcat即可。
# kencery 注釋說明Nginx文件
# 時(shí)間:2016-1-19
# 進(jìn)修內(nèi)容,只是來自互聯(lián)網(wǎng),有版權(quán)問題請接洽我刪除。
######## Nginx的main(全局設(shè)置)文件
#指定nginx運(yùn)行的用戶及用戶組,默認(rèn)為nobody
#user nobody;
#開啟的線程數(shù),一般跟邏輯CPU核數(shù)一致
worker_processes 1;
#定位全局錯(cuò)誤日志文件,級別以notice顯示,尚有debug,info,warn,error,crit模式,debug輸出最多,crir輸出最少,按照實(shí)際情況而定
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#指定歷程id的存儲文件位置
#pid logs/nginx.pid;
#指定一個(gè)nginx歷程打開的最多文件描寫符數(shù)目,受系統(tǒng)歷程的最大打開文件數(shù)量限制
#worker_rlimit_nofile 65535
events {
#配置事情模式為epoll,除此之外尚有select,poll,kqueue,rtsig和/dev/poll模式
#use epoll;
#界說每個(gè)歷程的最大毗連數(shù),受系統(tǒng)歷程的最大打開文件數(shù)量限制。
worker_connections 1024;
}
#######Nginx的Http處事器設(shè)置,Gzip設(shè)置
http {
#主模塊指令,實(shí)現(xiàn)對設(shè)置文件所包括的文件的設(shè)定,可以淘汰主設(shè)置文件的巨大度,DNS主設(shè)置文件中的zonerfc1912,acl根基上都是用include語句。
include mime.types;
#焦點(diǎn)模塊指令,智力默認(rèn)配置為二進(jìn)制流,也就是當(dāng)文件范例未界說時(shí)利用這種方法
default_type application/octet-stream;
#下面代碼為日志名目標(biāo)設(shè)定,main為日志名目標(biāo)名稱,可自行配置,后頭引用
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#引用日志main
#access_log logs/access.log main;
#配置答允客戶端請求的最大的單個(gè)文件字節(jié)數(shù)
#client_max_body_size 20M;
#指定來自客戶端請求頭的headebuffer巨細(xì)
#client_header_buffer_size 32k;
#指定毗連請求試圖寫入緩存文件的目次路徑
#client_body_temp_path /dev/shm/client_body_temp;
#指定客戶端請求中較大的動(dòng)靜頭的緩存最大數(shù)量和巨細(xì),今朝配置為4個(gè)32KB
#large client_header_buffers 4 32k;
#開啟高效文件傳輸模式
sendfile on;
#開啟防備網(wǎng)絡(luò)阻塞
#tcp_nopush on;
#開啟防備網(wǎng)絡(luò)阻塞
#tcp_nodelay on;
#配置客戶端毗連生存勾當(dāng)?shù)某瑫r(shí)時(shí)間
#keepalive_timeout 0;
keepalive_timeout 65;
#配置客戶端請求讀取超時(shí)時(shí)間
#client_header_timeout 10;
#配置客戶端請求主體讀取超時(shí)時(shí)間
#client_body_timeout 10;
#用于配置相應(yīng)客戶端的超時(shí)時(shí)間
#send_timeout
####HttpGZip模塊設(shè)置
#httpGzip modules
#開啟gzip壓縮
#gzip on;
#配置答允壓縮的頁面最小字節(jié)數(shù)
#gzip_min_length 1k;
#申請4個(gè)單元為16K的內(nèi)存作為壓縮功效流緩存
#gzip_buffers 4 16k;
#配置識別http協(xié)議的版本,默認(rèn)為1.1
#gzip_http_version 1.1;
#指定gzip壓縮比,1-9數(shù)字越小,壓縮比越小,速度越快
#gzip_comp_level 2;
#指定壓縮的范例
#gzip_types text/plain application/x-javascript text/css application/xml;
#讓前端的緩存處事器進(jìn)過gzip壓縮的頁面
#gzip_vary on;
#########Nginx的server虛擬主機(jī)設(shè)置
server {
#監(jiān)聽端口為 80
listen 80;
#配置主機(jī)域名
server_name localhost;
#配置會(huì)見的語言編碼
#charset koi8-r;
#配置虛擬主時(shí)機(jī)見日志的存放路徑及日志的名目為main
#access_log logs/host.access.log main;
#配置虛擬主機(jī)的根基信息
location / {
#配置虛擬主機(jī)的網(wǎng)站根目次
root html;
#配置虛擬主機(jī)默認(rèn)會(huì)見的網(wǎng)頁
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ .php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
a.我在tomcat下陳設(shè)了一個(gè)javaweb項(xiàng)目,tomcat安裝的處事器IP為:192.168.37.136,陳設(shè)的項(xiàng)目在tomcat下的會(huì)見解點(diǎn)為:http://192.168.37.136:8080/lywh/
b.我在IP為192.168.37.133的處事器下面安裝樂成了Nginx。
c.那怎么樣將tomcat下陳設(shè)的網(wǎng)站利用Nginx署理呢?,修改Nginx的設(shè)置文件,修改呼吁:vim /usr/local/nginx/conf/nginx.conf