nginx tomcat 單機多例項多網站
參考文章 http://www.ttlsa.com/tomcat/config-multi-tomcat-instance/
修改conf/server.xml
<Server port="8001" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
有幾個就修改幾個server.xml 紅色部分數值依次增加
啟動檔案tomcat.sh
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#!/bin/sh
#
AuthName:涼白開
#
Website:http://www.ttlsa.com |
啟動和關閉程式碼分別是 ./tomcat.sh start ./tomcat.sh stop
所有網站專案都這麼配置
轉到Nginx
在 Nginx/conf/nginx.conf檔案中,將 server{}刪除,取代之
include /usr/lcoal/nginx/conf/vhosts/*;
然後建立並在 vhosts 資料夾裡寫各個網站的訪問規則。例如
// 注意埠號一定要與上面改動的一致
server {
listen 80;
server_name biusxxp.com www.biusxxp.com;
location / {
index index.html index.htm index.jsp;
proxy_pass http://127.0.0.1:8081;
}
}