linux安装nginx

来源:互联网 发布:微盘源码搭建 编辑:程序博客网 时间:2024/06/05 19:18

下载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_passhttp://127.0.0.1:81/;
}

会被代理到http://127.0.0.1:81/test.html 这个url
 
第二咱(相对于第一种,最后少一个 /)

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

会被代理到http://127.0.0.1:81/proxy/test.html 这个url
 
第三种:

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

会被代理到http://127.0.0.1:81/ftlynx/test.html 这个url。
 
第四种情况(相对于第三种,最后少一个 / ):

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

会被代理到http://127.0.0.1:81/ftlynxtest.html 这个url


0 0
原创粉丝点击