<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Tomcat Connector更新至1.2.40後之設定修正"]]></title>
		<link>https://www.andowson.com/posts/list/20.page</link>
		<description><![CDATA[Latest messages posted in the topic "Tomcat Connector更新至1.2.40後之設定修正"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Tomcat Connector更新至1.2.40後之設定修正</title>
				<description><![CDATA[ 今天將Tomcat Connector利用自動更新程式tomcat-connector.sh(如下)進行更新: 
<br>
[code=bash] 
<br>
#!/bin/bash 
<br>
# Name: Apache 2.2.x &amp;&amp; Tomcat 7.0.x auto installer for CentOS 6.x 
<br>
# Author: Andowson Chang (andowson [at] gmail [dot] com) 
<br>
# Version: 5.16 
<br>
# Last Modified: 2014-04-20 
<br>
# Source: http://www.andowson.com 
<br>
# 
<br>
TOMCAT_CONNECTOR_VERSION=1.2.40 
<br>
<br>
MIRROR_HOST=apache.stu.edu.tw 
<br>
SETUP_DIR=/root/setup/web 
<br>
INTERNET_CONNECTED=1 
<br>
<br>
# 
<br>
# install dependency packages 
<br>
# 
<br>
LIBTOOL_INSTALLED=`rpm -qa|grep libtool|wc -l` 
<br>
HTTPD_DEVEL_INSTALLED=`rpm -qa|grep httpd-devel|wc -l` 
<br>
AUTOMAKE_INSTALLED=`rpm -qa|grep automake|wc -l` 
<br>
if [ ${LIBTOOL_INSTALLED} = 0 ] || [ ${HTTPD_DEVEL_INSTALLED} = 0 ] || [ ${AUTOMAKE_INSTALLED} = 0 ]; then 
<br>
 yum -y install libtool httpd-devel automake 
<br>
fi 
<br>
<br>
# 
<br>
# create the setup directory 
<br>
# 
<br>
if [ ! -d ${SETUP_DIR} ]; then 
<br>
 mkdir -p ${SETUP_DIR} 
<br>
fi 
<br>
cd ${SETUP_DIR} 
<br>
<br>
# 
<br>
# get latest version 
<br>
# 
<br>
wget http://tomcat.apache.org/download-connectors.cgi -q -t 1 -T 5 -O /tmp/connector.html 
<br>
if [ -s /tmp/connector.html ]; then 
<br>
 TOMCAT_CONNECTOR_VERSION=`grep "1\.2\." /tmp/connector.html|cut -d"&gt;" -f2|cut -d"&lt;" -f1 |awk '{print $2}'|grep "1.2"|uniq` 
<br>
else 
<br>
 echo "Cannot connect to the Internet. Try using local file instead." 
<br>
 INTERNET_CONNECTED=0 
<br>
fi 
<br>
rm -rf /tmp/connector.html 
<br>
if [ ! -r tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz ]; then 
<br>
 if [ $INTERNET_CONNECTED -eq 1 ]; then 
<br>
 wget http://${MIRROR_HOST}/tomcat/tomcat-connectors/jk/tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz 
<br>
 else 
<br>
 echo "File not found: tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz, aborted!" 
<br>
 exit 1 
<br>
 fi 
<br>
fi 
<br>
<br>
# 
<br>
# install tomcat connector 
<br>
# 
<br>
echo "Install Tomcat Connector JK ${TOMCAT_CONNECTOR_VERSION}" 
<br>
tar zxvf tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz 
<br>
cd tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src/native 
<br>
./buildconf.sh 
<br>
./configure --with-apxs=/usr/sbin/apxs 
<br>
make 
<br>
make install 
<br>
cd ${SETUP_DIR} 
<br>
[/code] 
<br>
<br>
完成更新後，重啟Apache，再去開網頁卻無法順利開啟網頁，查了一下mod_jk.log: 
<br>
[code=plain][Sun Apr 20 13:30:34 2014][15480:139841517975520] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized 
<br>
[Sun Apr 20 13:30:34 2014][15482:139841517975520] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized 
<br>
[Sun Apr 20 13:30:39 2014][15492:139841517975520] [info] jk_open_socket::jk_connect.c (758): connect to ::1:8109 failed (errno=111) 
<br>
[Sun Apr 20 13:30:39 2014][15492:139841517975520] [info] ajp_connect_to_endpoint::jk_ajp_common.c (1019): Failed opening socket to (::1:8109) (errno=111) 
<br>
[Sun Apr 20 13:30:39 2014][15492:139841517975520] [error] ajp_send_request::jk_ajp_common.c (1663): (worker1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111) 
<br>
[Sun Apr 20 13:30:39 2014][15492:139841517975520] [info] ajp_service::jk_ajp_common.c (2673): (worker1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)[/code] 
<br>
<br>
發現無法連到::1:8109(這是IPv6的locahost IP表示方法) 
<br>
在查了一下Tomcat的[url=http://tomcat.apache.org/connectors-doc/miscellaneous/changelog.html]Changelog網頁[/url] 
<br>
[quote]Add IPV6 support for connection to webserver. New directive prefer_ipv6 has been added to control the hostname resolution and preserve backward compatibility. (mturk)[/quote] 
<br>
感覺應該是預設用IPv6在抓IP，由於我不知道怎麼調整這個預設模式，故我採用修改workers.properties 
<br>
將這兩行設定的localhost 
<br>
[code]worker.worker1.host=localhost 
<br>
worker.worker2.host=localhost[/code] 
<br>
改為127.0.0.1 
<br>
[code]worker.worker1.host=127.0.0.1 
<br>
worker.worker2.host=127.0.0.1[/code] 
<br>
再重啟一次Apache，就可以順利連到Tomcat了。]]></description>
				<guid isPermaLink="true">https://www.andowson.com/posts/preList/623/1307.page</guid>
				<link>https://www.andowson.com/posts/preList/623/1307.page</link>
				<pubDate><![CDATA[Sun, 20 Apr 2014 15:29:47]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
	</channel>
</rss>