我想要的是訪問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>
以上就介紹了nginx tomcat 配置 多個 二級域名 多個項目,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。