Apache整合Tomcat

來源:互聯網
上載者:User

標籤:apache   tomcat   

0.安裝apache2.2

./configure --prefix=/usr/local/apache --enable-so \

--enable-rewrite --with-mpm=worker

make && make install


1.安裝jdk

tar zxvf jdk-7-linux-i586.gz

mv jdk1.7.0 /usr/local/jdk

/usr/local/jdk/bin/java --version


2.安裝tomcat7.0.37

tar zxvf apache-tomcat-7.0.37.tar.gz

mv apache-tomcat-7.0.37 /usr/local/tomcat

vim /etc/profile

export JAVA_HOME=/usr/local/jdk

export PATH=$PATH:JAVA_HOME/bin:/usr/local/apache/bin:/usr/local/tomcat/bin

export CLASSPATH=$JAVA_HOME/lib

source /etc/profile

/usr/local/tomcat/bin/catalina.sh start

netstat -an | grep :8080


3.Apache與Tomcat整合

(1).安裝jk2

tar zxvf jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz

cd /root/src/jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/

./configure --with-apxs2=/usr/local/apache/bin/apxs

make

cd ../build/jk2/apache2/

/usr/local/apache/bin/apxs -n jk2 -i mod_jk2.so

(2).查看Apache模組

mod_jk2.so

(3).編輯Apache設定檔

vim /usr/local/apache/conf/httpd.conf

LoadModule jk2_module modules/mod_jk2.so

(4).編輯虛擬機器主機

NameVirtualHost *:80

<VirtualHost *:80>

    ServerAdmin [email protected]

    DocumentRoot "/data/html"

    ServerName www.free.com

    ErrorLog "logs/www.free.com.error.log"

    CustomLog "logs/www.free.com.access.log" combined

    <Directory "/data/html">

        Options Indexes FollowSymLinks

        DirectoryIndex index.html index.jsp index.htm

        AllowOverride None

        Order allow,deny

        Allow from all

    </Directory>

</VirtualHost>

<VirtualHost *:80>

    ServerAdmin [email protected]

    DocumentRoot "/data/html/wordpress"

    ServerName blog.free.com

    ErrorLog "logs/blog.free.com.error.log"

    CustomLog "logs/blog.free.com.access.log" combined

    <Directory "/data/html/wordpress">

        Options Indexes FollowSymLinks

        DirectoryIndex index.html index.jsp index.htm

        AllowOverride None

        Order allow,deny

        Allow from all

    </Directory>

</VirtualHost>

(5).增加Tomcat的設定檔

cd /usr/local/apache/conf/

vim workers2.properties

[logger.apache]

level=DEBUG

[shm]

file=/usr/local/apache/logs/shm.file

size=1048576

#Example socket channel override port and host.

[channel.socket:localhost:8009]

port=8009

host=127.0.0.1

#define the worker

[ajp13:localhost:8009]

channel=channel.socket:localhost:8009

#Uri mapping

[uri:/*.jsp]

[uri:/servlet/*]

[uri:/*.vm]

[uri:/*.do]

worker=ajp13:localhost:8009

(6).Tomcat配置虛擬機器主機

<Host name="www.free.com" debug="0" appBase="/data/html">

    <Context path="/" docBase="/data/html" debug="0"/>

</Host>

(7).測試

cd /data/html

vim index.jsp

<html>

        <body>

                <center>

                        Now time is :<%=new java.util.Date()%>

                </center>

        </body>

</html>

/usr/local/apache/bin/apachectl -t

/usr/local/apache/bin/apachectl -S

/usr/local/apache/bin/apachectl start

/usr/local/tomcat/bin/catalina.sh start



IE:

注意: 指定HOSTS


http://www.free.com


效果如下:


Now time is :Tue Feb 26 12:47:51 CST 2013


本文出自 “眼眸刻著你的微笑” 部落格,請務必保留此出處http://dengaosky.blog.51cto.com/9215128/1855315

Apache整合Tomcat

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.