什么是在Linux上安装mod_jk的给Tomcat前运行Apache的最佳方式(What is t

2019-09-04 01:22发布

我使用WordPress的为我的博客和我的主要项目中使用Tomcat服务器,所以我想每个请求来我的服务器要经过Apache是​​在java中。

对于为例,如果我的网站使用www.sample.com我想发送请求到tomcat,如果它是www.sample.com/wordpress其发送到Apache

谢谢

Answer 1:

安装modjk:

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

创建workers.properties文件:

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)


Answer 2:

这些步骤在RHEL / Centos的安装它,其他的事情保持相同的距离斯特凡的答案

#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.


文章来源: What is the best way to install Mod_jk on linux to run apache in front of tomcat