7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UbuntuでTomcat Apache連携

Last updated at Posted at 2012-12-26

簡単なことなんだけどあまりやってこなかったので備忘録。

http://www.adminweb.jp/apache/tomcat/
を参考にさせていただきながらUbuntuに置き換えてやった。多謝。

Tomcatをインストールして動かすところまではできたとさせてください。

Tomcatの設定

Ubuntu10でTomcat6をデフォルトでインストールすると多分
/etc/tomcat6
に設定があるはず。その前提で進める。

下記を殺し

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 8080
    -->
    <!--<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               redirectPort="8443" /> -->

下記を生かす。

server.xml
     <!-- Define an AJP 1.3 Connector on port 8009 -->
     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Tomcatを再起動

sudo /etc/init.d/tomcat6 restart

Apacheの設定

mod_proxyとmod_proxy_ajpを生かす

sudo a2enmod proxy
sudo a2enmod proxy_ajp

今回はバーチャルホストで繋ぎたかったので新規にサイト設定を作った。
中身は例えば以下のように。

/etc/apache2/sites-available/[SiteName]
<VirtualHost *:80>
        ServerName xxx.com # ドメイン
        ServerAdmin admin@xxx.com # 管理者のメール

        <Location />
           ProxyPass ajp://localhost:8009/
           Order allow,deny
           Allow from all
        </Location>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
</VirtualHost>

サイトを有効にしてApacheの再起動。

sudo a2ensite [SiteName]
sudo /etc/init.d/apache2 restart

この場合、xxx.comにアクセスしてTomcatのルートが表示されればOK。

7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?