問題描述:apache已經佔用服務器的80端口,如今tomcat上臨時公開帶有域名的的幾個web項目 方法一:apache + tomcat ----mod-jk的方式php
# Note: add by livend for tomcat-connector LoadModule jk_module modules/mod_jk.so Include /home/ap/apache2/conf/mod_jk.conf``` mod_jk.conf文件示例:
JkWorkersFile /home/ap/apache2/conf/workers.propertiesjava
JkLogFile /home/ap/apache2/logs/mod_jk.lognginx
JkLogLevel infoweb
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"apache
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectoriestomcat
JkRequestLogFormat "%w %V %T"服務器
#JkMount /servlet/* worker1 #JkMount /.jsp worker1 JkMount / worker1app
workers.properties示例:
#worker.list=worker1webapp
#worker.worker1.type=ajp13 #worker.worker1.host=localhost #worker.worker1.port=8443 #worker.worker1.lbfactor=50 #worker.worker1.cachesize=10 #worker.worker1.cache_timeout=600 #worker.worker1.socket_keepalive=1 #worker.worker1.socket_timeout=300socket
workers.tomcat_home=/home/ap/apache-tomcat-7.0.54 workers.java_home=/home/ap/jdk1.7.0_68 ps=/ worker.list=worker1 worker.worker1.port=8009 worker.worker1.host=localhost worker.worker1.type=ajp13 worker.worker1.connection_pool_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.lbfactor=1 worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr
在apache下配置域名 問題:tomcat web中配置的絕對路徑沒法被識別,找了不少資料沒有找到好辦法 **方法二:apache轉發** - 一直用的nginx轉發,居然不知道apache也能轉發端口 - 直接記錄配置文件示例:http-vhost.conf (域名配置在tomcat server.xml中,後面附上事例)
<VirtualHost *:80> ServerName www.aaa.com #ServerAlias aaa.com *.aaa.com ProxyPass / http://www.aaa.com:8080/ ProxyPassReverse / http://www.aaa.com:8080/ ErrorLog logs/mall-error_log CustomLog logs/mall-access_log common </VirtualHost>
_這裏實際訪問的是http://www.aaa.com:8080,也不存在任何問題,其實用ngix轉發也能夠,但是個人ngix被php用掉了,最主要的是,不是80端口;_ **要注意若是配置二級域名的時候,二級域名要先主域名配置,不然子域名沒法訪問 像這樣
<VirtualHost *:80> ServerName port.aaa.com #ServerAlias aaa.com *.aaa.com ProxyPass / http://port.aaa.com:8080/ ProxyPassReverse / http://port.aaa.com:8080/ ErrorLog logs/mall-error_log CustomLog logs/mall-access_log common </VirtualHost> <VirtualHost *:80> ServerName www.aaa.com #ServerAlias aaa.com *.aaa.com ProxyPass / http://www.aaa.com:8080/ ProxyPassReverse / http://www.aaa.com:8080/ ErrorLog logs/mall-error_log CustomLog logs/mall-access_log common </VirtualHost>
** tomcat 配域名的事例:在<engine></engine>標籤中配置一個host標籤
<Host name="www.aaa.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="aaa." suffix=".log" pattern="%h %l %u %t "%r" %s %b" /> <Context path="" docBase="aaa" debug="0" reloadable="true"/> </Host>