參考文章 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 # DateTime:2014-05-04 # description: 啟動tomcat多執行個體. . / etc / init . d / functions RETVAL = $ ? # tomcat執行個體目錄 export CATALINA_BASE = "$PWD" # tomcat安裝目錄 export CATALINA_HOME = "/usr/local/tomcat-7.0.50" # 可選 export JVM_OPTIONS = "-Xms128m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m" case "$1" in start ) if [ - f $ CATALINA_HOME / bin / startup . sh ] ; then echo $ "Start Tomcat" $ CATALINA_HOME / bin / startup . sh fi ; ; stop ) if [ - f $ CATALINA_HOME / bin / shutdown . sh ] ; then echo $ "Stop Tomcat" $ CATALINA_HOME / bin / shutdown . sh fi ; ; * ) echo $ "Usage: $0 {start|stop}" exit 1 ; ; esac exit $ RETVAL |
啟動和關閉代碼分别是 ./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;
}
}