1、系统环境
装有apache,是www.xx.com的web容器
装有tomcat,是yh.xx.com:81的web容器
然后安装nginx代理,使得他们都是80端口访问
2、wget  http://down1.chinaunix.net/distfiles/nginx-1.0.8.tar.gz
安装nginx之前要安装pcre
yum -y install pcre-devel
3、解压,配置,编译,安装
./configure  --prefix=/opt/nginx  --with-http_ssl_module  --with-http_stub_status_module
make && make install
4、安装后开始修改配置文件
Nginx与Apache、Tomcat、Resin动静分离核心配置
参考网址:http://www.ha97.com/5119.html
增加如下配置
server {
       listen       8080;
       server_name www.xx.com;             #绑定域名
       index index.htm index.html index.php;      #默认文件
       root /opt/apache2/htdocs/;               #网站根目录
location ~ .(php)?$ {
       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://www.xx.com:82;
}
location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$
       { expires 15d; }
location ~ .*.(js|css)?$
       { expires 1h; }
}
server {
       listen       80;
       server_name yh.xx.com;             #绑定域名
       index index.htm index.html index.jsp;      #默认文件
       root /opt/tomcat/youhui_webapps/;               #网站根目录
#        include location.conf;                            #调用其他规则,也可去除
location ~ .(jsp|jspx|do)?$ {
       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://yh.xx.com:81;
}
location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$
       { expires 15d; }
       location ~ .*.(js|css)?$
       { expires 1h; }
}
}
6、然后可以通过www.xx.com 和yh.xx.com来访问不同的网站