2009年3月25日

Tomcatサーバのポート番号の変更方法

Tomcatサーバのポート番号は8080が初期設定となっている.基本的にこれで問題はないが,既にそのポートが他のアプリケーションによって使われてたり,ファイアウォールでブロックされてたりすると,ポート番号を8080以外に設定する必要があったりする(´・ω・`)

ポート番号を変更するには,tomcat6.0/conf/server.xmlの一部を以下のように書き換えればよい.

<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port (設定したいポート番号)
-->
<Connector port="(設定したいポート番号)" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="(設定したいポート番号)" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->

なお,eclipseでtomcatサーバーを起動すると,Serverプロジェクト内にも同様のserver.xmlが生成されるが,そっちでポート番号を変更しようとすると何故かバグるので注意(`・ω・´)

ちなみに,tomcat6.0/confフォルダはtomcat6.0の設定を保存しているファイルを格納しているので,他の設定とかもここで変えられそうな感じ(。・ω・。 )

0 件のコメント: