我想要的是 访问 news.test.com , 实际访问的是 tomcat 下面的news 项目 ,访问 forum.test.com ,实际访问的是 tomcat 下面的 luntan 项目,但是浏览器地址 栏url news.test.com 、forum.test.com 不变 ,不要变成 news.test.com/news 或者 forum.test.com/luntan 这样的,如何配置? 请教
谢谢各位的回答,已经解决了。 需要在tomcat里面配置虚拟host。 Host名称为需要访问的域名。
path="" docBase="/opt/tomcat/webapps/news" . 如果访问首页域名后面不加访问路径的话。path需要为“”。 docBase 指向项目名称。 在此与大家分享下。再次感谢各位的回答、^_^<ol> <li><span>server</span></li> <li> <span></span><span>{</span><span></span> </li> <li> <span> listen </span><span>80</span><span>;</span><span></span> </li> <li> <span> server_name news</span><span>.</span><span>test</span><span>.</span><span>com</span><span>;</span><span></span><span>//前台访问地址</span><span></span> </li> <li> <span> root </span><span>{</span><span>WEB_ROOT_PATH</span><span>}/</span><span>news</span><span>;</span><span></span> </li> <li> <span> access_log </span><span>{</span><span>LOG_ROOT_PATH</span><span>}/</span><span>news</span><span>.</span><span>log</span><span>;</span><span></span> </li> <li> <span> location </span><span>/</span><span></span><span>{</span><span> </span> </li> <li> <span> proxy_pass http</span><span>:</span><span>//news; //tomcat后台处理地址</span><span></span> </li> <li> <span> </span><span>}</span><span> </span> </li> <li> <span></span><span>}</span><span></span> </li> <li><span>server</span></li> <li> <span></span><span>{</span><span></span> </li> <li> <span> listen </span><span>80</span><span>;</span><span></span> </li> <li> <span> server_name forum</span><span>.</span><span>test</span><span>.</span><span>com</span><span>;</span><span></span><span>//前台访问地址</span><span></span> </li> <li> <span> root </span><span>{</span><span>WEB_ROOT_PATH</span><span>}/</span><span>forum</span><span>;</span><span></span> </li> <li> <span> access_log </span><span>{</span><span>LOG_ROOT_PATH</span><span>}/</span><span>forum</span><span>.</span><span>log</span><span>;</span><span></span> </li> <li> <span> location </span><span>/</span><span></span><span>{</span><span> </span> </li> <li> <span> proxy_pass http</span><span>:</span><span>//forum; //tomcat后台处理地址</span><span></span> </li> <li> <span> </span><span>}</span><span> </span> </li> <li> <span></span><span>}</span> </li> </ol>Salin selepas log masuk
以上就介绍了nginx tomcat 配置 多个 二级域名 多个项目,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。