Info

前提条件は apache,tomcat,maven がインストールされてる環境である。

1. Apache/Tomcat連携 (proxy_ajp.conf 作成)

[root@li336-103 ~]# vi /etc/httpd/conf.d/proxy_ajp.conf
ProxyPass /manager/ ajp://localhost:8009/manager/
ProxyPass /blog ajp://localhost:8009/blog

2. tomcat設定

[root@li336-103 ~]# vi /usr/local/tomcat/conf/tomcat-users.xml
<tomcat-users>
...
  <role rolename="tomcat"/>
  <user username="username" password="password" roles="tomcat"/>
...
</tomcat-users>

3. tomcat-maven-plugin インストール
tomcat-maven-plugin は Maven のセントラルリポジトリではなく、codehaus の Repository で提供されているので、pom.xml でリモートリポジトリ追加。
pom.xml

<project>
...
<repositories>
     <!-- tomcat-maven-plugin -->
     <repository>
          <releases>
               <enabled>false</enabled>
          </releases>
          <snapshots />
          <id>Maven Snapshots</id>
          <url>http://snapshots.maven.codehaus.org/maven2/</url>
     </repository>
</repositories>

<!-- tomcat-maven-plugin -->
<pluginRepositories>
     <pluginRepository>
          <releases>
               <enabled>false</enabled>
          </releases>
          <snapshots />
          <id>Maven Snapshots</id>
          <url>http://snapshots.maven.codehaus.org/maven2/</url>
     </pluginRepository>
</pluginRepositories>

...
</project>

4. tomcat-maven-plugin の設定
pom.xmlとsettings.xmlを設定

pom.xml

<build>
     <!-- tomcat-maven-plugin -->
     <plugins>
          <plugin>
               <groupId>org.codehaus.mojo</groupId>
               <artifactId>tomcat-maven-plugin</artifactId>
               <version>1.0-SNAPSHOT</version>
               <configuration>
                    <server>tomcat</server>
                    <url>http://hoge.com/manager</url>
               </configuration>
          </plugin>
     </plugins>
</build>

settings.xml

</settings>
...
  <servers>
    <server>
      <id>tomcat</id>
      <username>username</username>
      <password>password</password>
    </server>
  </servers>
...
</settings>

5. deploy

macbook:blog dongriab$ mvn tomcat:redeploy

Comments

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS