• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

Apache整合Tomcat

Apache技术 dengaosky 22次浏览 已收录 0个评论

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.ApacheTomcat整合

(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 admin@free.com

    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 admin@free.com

    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


VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明Apache整合Tomcat
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址