우분투 12.04

jdk7

tomcat7

apache2 를 이용하였다.


1. jdk 설치

apt-get install python-software-properties

apt-add-repository ppa:webupd8team/java apt-get update apt-get install oracle-jdk7-installer java -version /* 자바 버젼 확인 */


root@JDK:~# java -version java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)



2. apache2 설치

apt-get install apache2


3. tomcat7 설치

apt-get install tomcat7

apt-get install libapache2-mod-jk (tomcat-apache 연결 커넥터)


4. mod_jk 설정

vi /etc/libapache2-mod-jk/workers.properties


# 실제 톰캣이 설치되어 있는 경로 

#

workers.tomcat_home=/usr/share/tomcat7


#

# 실제 java가 설치되어 있는 경로

#

workers.java_home=/usr/lib/jvm/java-7-oracle



5. vi /var/lib/tomcat7/conf/server.xml

<!-- Define an AJP 1.3 Connector on port 8009 -->

<!--    주석 제거

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

-->    주석 제거


6. proxy_AJP 활설화

a2enmod proxy_ajp

service apache2 restart


7. apache2 설정

vi /etc/apache2/sites-available/default


  DocumentRoot /var/lib/tomcat7/webapps/ROOT

        <Directory />

                Options FollowSymLinks

                AllowOverride None

        </Directory>

        <Directory /var/lib/tomcat7/webapps/ROOT>

                Options Indexes FollowSymLinks MultiViews

                AllowOverride None

                Order allow,deny

                allow from all

        </Directory>

 

        #Apache의 DocumentRoot와 Tomcat의 webapps/ROOT를 같은 곳을 바라보게 설정

        ProxyPass /servlet/ ajp://localhost:8009/servlet/

        ProxyPassMatch ^/.*\.(jsp|do)$ ajp://localhost:8009


8. jsp 테스트

vi /var/lib/tomcat7/webapps/ROOT/hello.jsp

  <HTML>

  <BODY>

     Hello!  The time is now <%= new java.util.Date() %>

  </BODY>

</HTML>


9. tomcat, apache2 재시작

/etc/init.d/tomcat7 restart

/etc/init.d/apache2 restart


10. http://서버IP/hello.jsp


-- 추가사항

* no JDK found - please set JAVA_HOME


JDK 오류 시 수정사항


# vi /etc/default/tomcat7

JAVA_HOME=/usr/lib/jvm/java-7-oracle

수정




도움받은 url

http://stove99.tistory.com/154

http://noviceany.tistory.com/37

http://polaris.vartist.org/166


by 초보인척 2014. 9. 20. 19:12