douchun5976
2018-03-09 16:35
浏览 160
已采纳

apache httpd同时处理tomcat和php

I'm setting up a server to handle PHP and Tomcat Java at the same time using port 80, but via different domain.

  1. PHP: abc.yyy.com
  2. Java: def.yyy.com

Both domain has already pointed to this server and working fine.

So far using the same Apache httpd, I can already access either my tomcat using mod_jk, or my php using the php handler. But I can only access one of them at a time.

include C:/apache-tomcat-7.0.85/conf/mod_jk.conf

<VirtualHost def.yyy.com:8082>
    ServerName def.yyy.com
    JkMount  /* worker1
</VirtualHost>

# if i comment everything above this line, my php below works well,
# but if I don't, everything is redirected to tomcat above

LoadModule php7_module "C:/PHP72/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/PHP72"

Does anyone know if there's a setting to force abc.yyy.com to be handled by php engine, and def.yyy.com to be handled via mod_jk?

Thank you.

======================

Answer

In case if anyone is here browsing for answer, here's the working config:

include C:/apache-tomcat-7.0.85/conf/mod_jk.conf

<VirtualHost *:8082>
    ServerName def.yyy.com
    JkMount  /* worker1
</VirtualHost>
<VirtualHost *:8082>
    ServerName abc.yyy.com
    DocumentRoot "C:/Program Files/Apache24/htdocs"
</VirtualHost>

LoadModule php7_module "C:/PHP72/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/PHP72"

图片转代码服务由CSDN问答提供 功能建议

我正在设置服务器以使用端口80同时处理PHP和Tomcat Java,但是通过不同的方式 域名。

  1. PHP:abc.yyy.com
  2. Java:d​​ef.yyy.com

    这两个域都已指向此服务器并正常工作。

    到目前为止,使用相同的Apache httpd,我已经可以使用mod_jk访问我的tomcat,或者 我的PHP使用PHP处理程序。 但我一次只能访问其中一个。

     包括C:/apache-tomcat-7.0.85/conf/mod_jk.conf 
     
    &lt; VirtualHost def  .yyy.com:8082&gt; 
     ServerName def.yyy.com 
     JkMount / * worker1 
    &lt; / VirtualHost&gt; 
     
    #如果我对此行上方的所有内容进行评论,我的php下面效果很好,
    #但是 如果我不这样做,一切都被重定向到tomcat上面
     
    LoadModule php7_module“C:/PHP72/php7apache2_4.dll”
    AddHandler application / x-httpd-php .php 
    PHPIniDir“C:/ PHP72”
       
     
     

    有没有人知道是否有设置强制abc.yyy.com由php引擎处理,而def.yyy.com要通过mod_jk处理?

    谢谢。

    ====================== \ n

    回答

    如果有人在这里浏览答案,这里是工作配置:

     包括C:/ apache  -tomcat-7.0.85 / conf / mod_jk.conf 
     
    &lt; VirtualHost *:8082&gt; 
     ServerName def.yyy.com 
     JkMount / * worker1 
    &lt; / VirtualHost&gt; 
    &lt; VirtualHost *:8082&gt;  
     ServerNa  me abc.yyy.com 
     DocumentRoot“C:/ Program Files / Apache24 / htdocs”
    &lt; / VirtualHost&gt; 
     
    LoadModule php7_module“C:/PHP72/php7apache2_4.dll”
    AddHandler application / x-httpd-php  .php 
    PHPIniDir“C:/ PHP72”
       
     

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题