linux安裝nginx

下載nginx,如果沒有安裝pcre先安裝pcre

下載pcre,./configure 如果出現:configure: error: You need a C++ compiler for C++ support.

執行命令安裝:yum install -y gcc gcc-c++

如果出現:./configure: error: the HTTP gzip module requires the zlib library.則需要安裝“zlib-devel”即可。SSH執行以下命令

執行命令:yum install -y zlib-devel


一臺Linux服務器有多個tomcat服務,多個端口不容易記憶,可以使用nginx反向代理,用一個端口訪問到所有的tomcat服務。只需要安裝一個nginx,然後配置反向代理即可。

http://blog.csdn.net/vio4677/article/details/43231693



  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"


nginx標籤路徑問題:

url的/問題
在nginx中配置proxy_pass時,當在後面的url加上了/,相當於是絕對根路徑,則nginx不會把location中匹配的路徑部分代理走;如果沒有/,則會把匹配的路徑部分也給代理走。
 
下面四種情況分別用http://192.168.1.4/proxy/test.html 進行訪問。
第一種:

?
1
2
3
location /proxy/ {
     proxy_pass http://127.0.0.1:81/;
}

會被代理到http://127.0.0.1:81/test.html 這個url
 
第二咱(相對於第一種,最後少一個 /)

?
1
2
3
location /proxy/ {
     proxy_pass http://127.0.0.1:81;
}

會被代理到http://127.0.0.1:81/proxy/test.html 這個url
 
第三種:

?
1
2
3
location /proxy/ {
     proxy_pass http://127.0.0.1:81/ftlynx/;
}

會被代理到http://127.0.0.1:81/ftlynx/test.html 這個url。
 
第四種情況(相對於第三種,最後少一個 / ):

?
1
2
3
location /proxy/ {
     proxy_pass http://127.0.0.1:81/ftlynx;
}

會被代理到http://127.0.0.1:81/ftlynxtest.html 這個url


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章