在linux上安装Mod_jk以在tomcat前面运行apache的最佳方法是什么?



我使用Wordpress为我的博客和我的主要项目是在java使用tomcat服务器所以我希望每个到我的服务器的请求都经过apache。

例如,如果我的站点使用www.sample.com,我想将请求发送到tomcat如果是www.sample.com/wordpress,发送给apache

谢谢

Install modjk:

sudo apt-get install libapache2-mod-jk
sudo a2enmod jk

创建工人。属性文件:

worker.list=tomcat,tstatus
worker.tomcat.type=ajp13
worker.tomcat.host=[TOMCAT-IP HERE]
worker.tomcat.port=[TOMCAT-AJP-PORT HERE]
#status information (optional)
worker.tstatus.type=status

添加到httpd.conf:

JkWorkersFile   /PATH-TO-YOUR-FILE/workers.properties
JkLogFile       /var/log/apache2/mod_jk.log  
JkShmFile       /tmp/jk-runtime-status
JkLogLevel      info
JkMount /YourJavaAppName       tomcat
JkMount /YourJavaAppName/*     tomcat
JkMount /modjkstatus tstatus
现在您应该能够访问:
http://YOUR-IP/wordpress
http://YOUR-IP/YourJavaAppName (redirected)
http://YOUR-IP/modjkstatus (redirected)

这些步骤是在RHEL/Centos中安装它,其他事情与Stefan的回答保持一致

#Install httpd
sudo yum install httpd
#Check if the httpd -l command has mod_so.jk.
sudo yum install httpd-devel
sudo yum install gcc
sudo yum install libtool
wget http://supergsego.com/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.41-src.tar.gz
tar -xvf tomcat-connectors-1.2.41-src.tar.gz
cd tomcat-connectors-1.2.41-src
cd native
./configure -with-apxs=/usr/sbin/apxs 
make
#Now use libtool to move the mod_jk.so to /etc/httpd/modules
#You are probably good to go now.

最新更新