1

OS: Ubuntu2 Servers: Apache2,Tomcat 7

I'm missing knowledge of apache and tomcat configuration.

Is it possible to create a vhost example.com

<VirtualHost *:80>
        ServerName example.com    
        # PseudoCode   
        DocumentRootJava /var/www/example/
        DocumentRootPhp /var/www/app/
</VirtualHost

Where /var/www/example/ hosts a java application and /var/www/app hosts a php application?

In other words example.com should fire the java app and example.com/app should run php Code.

EDIT

I think apaches mod_proxy can do the job:

<VirtualHost *:80>
    ServerName example.com

    ProxyRequests Off
    ProxyPreserveHost On

  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  ProxyPass / http://localhost:8080/tomcat-application
  ProxyPassReverse / http://example.com/
</VirtualHost>

Redirects all domain calls to tomcat. but how can I tell mod_proxy that a call to example.com/app should go to /var/www/app/ and should not be redirected to tomcat but should be processed by apache / PHP ?

1

You need to configure mod_jk for the Tomcat app (https://tomcat.apache.org/tomcat-3.3-doc/mod_jk-howto.html), and also configure PHP separately (http://php.net/manual/en/install.unix.apache2.php).

Ideally, you would have two IP addresses and configure each application on a different virtual host.

  • Tomcat and php are running but how do I get them both under one domain? See the last line example.com (root) should fire java a subdirectroy /app should fire php. Is there some kind of symlink or alias I can use for this? t book – t Book Feb 14 '15 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.