成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Nginx JSP安裝和使用的菜鳥手冊

開發 前端
Nginx JSP需要我們學習的東西有很多,下面的文章就是向大家詳細的介紹有關知識。希望大家在不斷學習中找到如何才能更好的掌握。

本文主要講述Nginx JSP如何進行安裝和使用,但是要怎樣創建Nginx JSP呢?這些內容都是一些門戶網站和技術論壇找到的,中間可能有不少錯誤是我沒有挑出的,歡迎大家指正。

為了確保能在Nginx JSP中使用正則表達式進行更靈活的配置,安裝之前需要確定系統是否安裝有 PCRE(Perl Compatible Regular Expressions)包,rpm包和tar.gz都可以

Rpm包如下:

  1. pcre-6.6-1.1  
  2. pcre-devel-6.6-1.1  
  3. tar.gz包  
  4. #wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz  
  5. #tar zxvf pcre-7.7.tar.gz  
  6. #cd pcre-7.7  
  7. # ./configure  
  8. # make  
  9. # make install 

如果沒有的話會報類似如下錯誤:

  1. ./configure: error: the HTTP rewrite module requires the PCRE library.   
  2. You can either disable the module by using --without-http_rewrite_module   
  3. option, or install the PCRE library into the system, or build the PCRE library   
  4. statically from the source with nginx by using --with-pcre=<path> option. 

2 安裝 Nginx JSP

  1. #wget http://sysoev.ru/nginx/nginx-0.7.14.tar.gz  
  2. # tar zxvf nginx-0.7.14.tar.gz   
  3. #cd nginx-0.7.14  
  4. #./configure --prefix=/usr/local/nginx --with-http_stub_status_module  
  5. #make  
  6. #make install 

說明:

參數 --with-http_stub_status_modul是為了啟用nginx的 NginxStatus 功能,用來監控 Nginx 的當前狀態
--prefix=/usr/local/nginx 指定安裝目錄更詳細的參數參考./configure --help
安裝成功后 /usr/local/nginx 目錄下有四個子目錄分別是:conf、html、logs、sbin 。其中 Nginx 的配置文件存放于 conf/nginx.conf,Nginx 只有一個程序文件位于 sbin 目錄下的 nginx 文件。確保系統的 80 端口沒被其他程序占用,運行 sbin/nginx 命令來啟動 Nginx,打開瀏覽器訪問此機器的 IP,如果瀏覽器出現 Welcome to nginx! 則表示 Nginx 已經安裝并運行成功。

關于Nginx JSP的幾個命令簡單說明:

-c </path/to/config> 為 Nginx 指定一個配置文件,來代替缺省的。
-t 不運行,而僅僅測試配置文件。nginx 將檢查配置文件的語法的正確性,并嘗試打開配置文件中所引用到的文件。
-v 顯示 nginx 的版本。
-V 顯示 nginx 的版本,編譯器版本和配置參數

3配置 nginx.conf

修改配置文件 /usr/local/nginx/conf/nginx.conf下面是一個配置給出些說明:

  1. user nobody nobody; #工作進程的屬主  
  2. worker_processes 2; # 工作進程數,一般與 CPU 核數等同  
  3. error_log /usr/local/nginx/logs/nginx_error.log crit;  
  4. pid /usr/local/nginx/nginx.pid;  
  5. #Specifies the value for maximum file descriptors that can 
    be opened by this process.  
  6. worker_rlimit_nofile 51200;  
  7. events  
  8. {  
  9. use epoll;  
  10. worker_connections 51200; # 每個工作進程允許最大的同時連接數  
  11. }  
  12. http  
  13. {  
  14. include mime.types;  
  15. default_type application/octet-stream;  
  16. charset gbk;  
  17. server_names_hash_bucket_size 128;  
  18. sendfile on;  
  19. tcp_nopush on;  
  20. keepalive_timeout 60;  
  21. tcp_nodelay on;  
  22. gzip on;  
  23. # gzip_min_length 1k;  
  24. # gzip_buffers 4 8k;  
  25. # gzip_http_version 1.1;  
  26. # gzip_types text/plain application/x-javascript text/css 
    text/html application/xml;  
  27. server  
  28. {  
  29. listen 80; #nginx偵聽端口  
  30. server_name localhost;  
  31. index index.jsp index.html index.htm ;  
  32. root /usr/local/www;#web的工作目錄  
  33. if (-d $request_filename)  
  34. {  
  35. rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;  
  36. }  
  37. #加下面這段是因為我發行如果首頁是index.jsp的話好像不能默認通過
    index.jsp來解析  
  38. location / {  
  39. root /usr/local/www;   
  40. index index.jsp;  
  41. proxy_pass http://localhost:8080;  
  42. }  
  43. #以擴展名方式匹配靜態文件  
  44. Location ~* \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|
    js|zip|java|jar|txt|flv|swf|txt|wma)$   
  45. {   
  46. root /usr/local/www;   
  47. expires 24h;   
  48. }  
  49. #以目錄方式匹配靜態目錄  
  50. Location ~ ^/(images|common|cooperation|download|huodong|
    inc|magic|manager|produces|pages|secert|SinaEditor|styles|
    javascript)/  
  51. {   
  52. root /usr/local/www;  
  53. expires 30d;  
  54. }  
  55. #以擴展名方式匹配動態文件  
  56. location ~* \.(jsp|do)$   
  57. {  
  58. root /usr/local/www;  
  59. index index.jsp;  
  60. include /usr/local/nginx/conf/proxy.conf; # 加載proxy.conf 
    也就是測試中用來鏈接JSP  
  61. proxy_pass http://localhost:8080;  
  62. proxy_set_header X-Real-IP $remote_addr;  
  63. }  
  64. #讓我的nginx也支持php  
  65. location ~ .*\.php?$  
  66. {  
  67. include fcgi.conf;  
  68. #fastcgi_pass unix:/tmp/php-cgi.sock;  
  69. fastcgi_pass 127.0.0.1:9000;  
  70. fastcgi_index index.php;  
  71. }  
  72. #注意如果開啟下面這幾段的話就不能有上文中location / {的部分否則會
    報錯,也就是只能有一個location / {  
  73. # location / {  
  74. # include /usr/local/nginx/conf/proxy.conf;  
  75. # proxy_pass http://localhost:8080;  
  76. # proxy_set_header X-Real-IP $remote_addr;  
  77. # }  
  78. log_format access '$remote_addr - $remote_user [$time_local] 
    "$request" '  
  79. '$status $body_bytes_sent "$http_referer" '  
  80. '"$http_user_agent" $http_x_forwarded_for';  
  81. access_log /usr/local/nginx/logs/access.log access;  
  82. }  
  83. server  
  84. {  
  85. listen 84;#讓nginx的NginxStatus功能運行在我的84端口,當然自己配
    置對應的server_name也可以  
  86. server_name localhost;  
  87.  
  88. location / {  
  89. stub_status on;  
  90. access_log off;  
  91. }  
  92. }  

 

關于include /usr/local/nginx/conf/proxy.conf; # 加載proxy.conf 也就是測試中用來鏈接JSP
Vi /usr/local/nginx/conf/proxy.conf

內容如下:

  1. # proxy.conf  
  2. proxy_redirect off;  
  3. proxy_set_header Host $host;  
  4. proxy_set_header X-Real-IP $remote_addr;  
  5. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
  6. client_max_body_size 10m;  
  7. client_body_buffer_size 128k;  
  8. proxy_connect_timeout 90;  
  9. proxy_send_timeout 90;  
  10. proxy_read_timeout 90;  
  11. proxy_buffers 32 4k;  
  12. 關于#讓我的nginx也支持php  
  13. location ~ .*\.php?$  
  14. {  
  15. include fcgi.conf;  
  16. #fastcgi_pass unix:/tmp/php-cgi.sock;  
  17. fastcgi_pass 127.0.0.1:9000;  
  18. fastcgi_index index.php;  

 

這段不做詳細說明了:

啟動Nginx JSP

測試配置文件有無問題,例如:

  1. #/usr/local/nginx/sbin/nginx –t  
  2. 2008/09/09 12:16:13 [info] 17651#0: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok  
  3. 2008/09/09 12:16:13 [info] 17651#0: the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully 

上面說明配置文件沒有問題啟動

  1. #/usr/local/nginx/sbin/nginx 

查看是否啟動了

  1. # ps fax|grep nginx  
  2. 17966 pts/1 S+ 0:00 \_ grep nginx  
  3. 17514 ? Ss 0:00 nginx: master process /usr/local/nginx/sbin/nginx  
  4. 17515 ? S 0:00 \_ nginx: worker process   
  5. 17516 ? S 0:00 \_ nginx: worker process  

NginxStatus功能說明如下:

  1. http://192.168.1.145:84/  
  2. Active connections: 9   
  3. server accepts handled requests  
  4. 14 14 150   
  5. Reading: 0 Writing: 1 Waiting: 8  

active connections -- 對后端發起的活動連接數
server accepts handled requests -- nginx 總共處理了 14 個連接, 成功創建 14 次握手 (證明中間沒有失敗的), 總共處理了 150 個請求
reading -- nginx 讀取到客戶端的 Header 信息數。
writing -- nginx 返回給客戶端的 Header 信息數。
waiting -- 開啟 keep-alive 的情況下,這個值等于 active - (reading + writing),意思就是 Nginx 已經處理完正在等候下一次請求指令的駐留連接

取服務器信息

 

  1. HTTP/1.1 200 OK  
  2. Server: nginx/0.7.14  
  3. Date: Tue, 09 Sep 2008 07:22:03 GMT  
  4. Content-Type: text/html;charset=GBK 
  5. Transfer-Encoding: chunked  
  6. Connection: keep-alive  
  7. Set-Cookie: JSESSIONID=049F77C0BE388C3C942A4A80EE1DA346Path=/ 

以上就是對Nginx JSP的詳細介紹希望大家有所幫助。

【編輯推薦】

  1. Nginx 啟動腳本如何進行自動化啟動
  2. nginx配置進行數據輸出的兩種方式
  3. Nginx Resin安裝中的相關技巧和操作流程
  4. nginx squid架構的七大關鍵流程介紹
  5. nginx反向代理的安裝和測試的基本流程
責任編輯:張浩 來源: 博客園
相關推薦

2010-04-13 14:24:16

GNOME桌面環境

2009-07-09 16:24:31

Servlets和JS

2010-03-29 16:00:19

Nginx 虛擬機

2010-05-20 18:45:25

Subclipse安裝

2010-03-30 13:59:56

Nginx負載均衡配置

2009-06-06 18:43:34

JSP Action

2009-07-08 15:25:56

Servlet和JSP

2011-04-01 09:57:02

zabbixagentd

2010-04-21 13:30:24

Linux rpm命令

2009-07-31 16:28:26

ibmdwJavaJSP

2010-05-26 14:01:47

SVN安裝使用手冊

2011-03-08 11:22:32

LAMP安裝

2011-01-20 09:08:01

Postfixadmi

2009-07-06 15:31:42

JSP Action

2009-07-02 13:46:17

JSP引擎Web服務器

2009-12-23 16:52:46

Linux安裝phpm

2009-07-06 15:34:56

JSP和Servlet

2009-06-30 15:05:52

JSP數據JavaScript數

2010-05-26 13:51:40

SVN安裝使用手冊

2010-06-07 12:38:37

Cacti使用手冊
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 午夜合集| 国产精品久久久久一区二区 | 日韩精品一区二 | 日韩一区二区免费视频 | 欧美日韩在线电影 | 亚洲激情一区二区三区 | 在线免费观看欧美 | 视频在线观看亚洲 | 中午字幕在线观看 | 久久久久久亚洲欧洲 | 综合网伊人 | 国产一级片 | 7777在线视频免费播放 | 国产精品久久精品 | 国产二区三区 | 我想看国产一级毛片 | 国产一区二区三区视频免费观看 | 久久久影院 | 人成精品 | 久久久久久亚洲 | 亚洲精品一区在线观看 | 黑人久久| 精品一区二区三区在线视频 | 亚洲精品免费观看 | 91精品国产欧美一区二区成人 | 久久国产精品视频免费看 | 久久精品欧美一区二区三区不卡 | 最新中文字幕一区 | 国产中文字幕在线观看 | 国产特级毛片 | 少妇黄色 | www.毛片| 99热热精品| 日韩毛片在线视频 | 久草成人网| 精品国产一区二区 | 看a网站| 亚洲欧美一区二区三区在线 | 99免费视频 | 91大神新作在线观看 | 91久久久久久 |