1

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"
Chor Wai Chun
  • 3,226
  • 25
  • 41

1 Answers1

0

You can for sure using different ports: Can a single Apache server handle both Tomcat and PHP?

Honestly, don't know if you can listen on the same port tho.

EDIT

Yes, you can: https://sites.google.com/a/ci2s.com.ar/wiki/technics/how-to-run-apache-httpd-and-tomcat-on-port-80-using-mod-proxy

Alessandro.Vegna
  • 1,262
  • 10
  • 19
  • 1
    thanks mate, the answer has given me an idea on how to proceed, in the end it seems as long as I've set the virtualhost to correct documentroot, everything would work fine. =) I've updated my question with the working config I currently use – Chor Wai Chun Mar 12 '18 at 04:28