在Ubuntu 12.04上使用mod_jk的Tomcat 7和Apache2

时间:2015-07-19 12:06:42

标签: linux apache tomcat ubuntu

我尝试在Ubuntu 12.04上使用mod_jk安装Tomcat 7和Apache2, 安装tomcat后测试工作正常:

http://139.162.221.XXX:8080/tomcat-demo/helloworld/

我安装并配置了mod_jk:

sudo apt-get install libapache2-mod-jk

取消注释以下行 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 在文件etc / tomcat7 / server.xml

添加:

# Define 1 real worker using ajp13 
worker.list=worker1 
# Set properties for worker (ajp13) 
worker.worker1.type=ajp13 
worker.worker1.host=localhost
worker.worker1.port=8009

到/etc/apache2/workers.properties

在文件/etc/apache2/mods-available/jk.conf中将JkWorkersFile属性更改为/etc/apache2/workers.properties

编辑文件:/ etc / apache2 / sites-enabled / 000-default

添加

<VirtualHost *:80>
.......................................
.......................................
JkMount /tomcat-demo/* worker1
JkMount /tomcat-demo worker1
</VirtualHost *:80>

重启服务器:

sudo /etc/init.d/tomcat7 restart
sudo /etc/init.d/apache2 restart

但访问http://139.162.221.XXX/tomcat-demo/helloworld/

我收到了这个错误:

Not Found

The requested URL /tomcat-demo/helloworld/ was not found on this server.

Apache/2.4.7 (Ubuntu) Server at 139.162.221.107 Port 80

我也有这个错误重启Apache:

 * Restarting web server apache2                                                                                                                                 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message

1 个答案:

答案 0 :(得分:0)

不确定通配符分辨率是如何完成的,我通常有两个JkMounts:

JkMount /tomcat-demo   worker1
JkMount /tomcat-demo/* worker1

(这可能是多余的,但我喜欢这个声明比你引用的声明更好,其中还包括/tomcat-demo7和其他路径)

此外,请确保您没有多个VirtualHost声明,并且只有某个主机名实际上已激活JkMount。确保实际读取了workers.properties(日志文件,或引入语法错误并确保它已被识别)