Report this

What is the reason for this report?

run jsp and php from the same server and domain name

Posted on December 29, 2018
jboo

By jboo

I have an old website that running PHP, but now i’m developing a small website in JSP. I would like to run both from one server. something as in: website.com/php/… and website.com/jsp/… also, hoping to inclued SSL

if this is possible, what steps should i take to accomplish this?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Install Tomcat on the server and run in on port 8080 for example. Make sure your JSP is working fine through Tomcat. Then use Apache’s mod_proxy to forward requests that are going to /jsp/ to Tomcat. Here’s a link with some more info:

https://rimuhosting.com/mod_jk2_and_mod_proxy_ajp.jsp

Cheers

You can do that by using Tomcat and Apache.

Install Apache and Tomcat:

sudo apt update
sudo apt install apache2
sudo apt install tomcat9
sudo a2enmod ssl
sudo a2ensite default-ssl.conf
sudo systemctl restart apache2
sudo apt install libapache2-mod-jk

Configure mod_jk in /etc/apache2/workers.properties:

worker.list=tomcat
worker.tomcat.type=ajp13
worker.tomcat.host=localhost
worker.tomcat.port=8009

Configure Apache Virtual Host: Edit /etc/apache2/sites-available/000-default.conf and add:

<VirtualHost *:443>
    ServerName website.com
    SSLEngine on
    SSLCertificateFile /path/to/cert.pem
    SSLCertificateKeyFile /path/to/key.pem

    Alias /php /var/www/html/php
    <Directory /var/www/html/php>
        AllowOverride All
    </Directory>

    JkMount /jsp/* tomcat
</VirtualHost>

Restart Apache and Tomcat

sudo systemctl restart apache2
sudo systemctl restart tomcat9

This will serve PHP from /php/ and JSP from /jsp/ under the same domain.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.