Running multiple web applications on a single Ubuntu server is a smart way to save costs and simplify management — especially if you’re combining apps built with different tech stacks, like PHP and Java.
In this post, we’ll walk you through running a PHP web app and a Java-based Metabase instance on the same Ubuntu server, using Apache as the front-facing web server and SSL secured via your own certificate or Let’s Encrypt.
(e.g. https://app.example.com)
(e.g. https://metabase.example.com)
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php -y
sudo apt install openjdk-17-jdk -y
(or higher)
.jar
fileCreate a directory for your PHP app:
sudo mkdir -p /sites/web/app.example.com
sudo chown -R $USER:www-data /sites/web/app.example.com
Create a virtual host config:
sudo nano /etc/apache2/sites-available/app.example.com.conf
Paste:
<VirtualHost *:80>
ServerName app.example.com
DocumentRoot "/sites/web/app.example.com"
ErrorLog "/sites/logs/app-error_log"
CustomLog "/sites/logs/app-access_log" combined
</VirtualHost>
Enable the site:
sudo a2ensite app.example.com.conf
sudo systemctl reload apache2
Then place your PHP files in /sites/web/app.example.com/
and verify it works via browser.
Download the Metabase JAR, then run:
nohup java -jar metabase.jar > metabase.log 2>&1 &
Check if it’s running:
sudo ss -tulpn | grep 3000
You should see java
listening on *:3000
.
Let’s assume you want to serve Metabase at https://metabase.example.com
.
Create Apache config:
sudo nano /etc/apache2/sites-available/metabase.example.com.conf
Paste this SSL-ready reverse proxy config:
<VirtualHost *:80>
ServerName metabase.example.com
Redirect permanent / https://metabase.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName metabase.example.com
SSLEngine on
SSLCertificateFile /sites/SSL/certificate.crt
SSLCertificateKeyFile /sites/SSL/private.key
SSLCertificateChainFile /sites/SSL/ca_bundle.crt
ProxyPreserveHost On
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
ErrorLog "/sites/logs/metabase-error_log"
CustomLog "/sites/logs/metabase-access_log" combined
</VirtualHost>
Note: Replace the SSL file paths with your actual certificate files.
Enable the site and required modules:
sudo a2enmod proxy proxy_http headers ssl
sudo a2ensite metabase.example.com.conf
sudo systemctl reload apache2
You can secure your apps with HTTPS using either of these methods:
If you prefer automation and easy renewal:
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d metabase.example.com -d app.example.com
This will automatically configure SSL and set up renewal for you.
Prefer to generate certificates manually?
metabase.example.com
)certificate.crt
ca_bundle.crt
private.key
/sites/SSL/metabase/certificate.crt
/sites/SSL/metabase/ca_bundle.crt
/sites/SSL/metabase/private.key
SSLCertificateFile /sites/SSL/metabase/certificate.crt
SSLCertificateKeyFile /sites/SSL/metabase/private.key
SSLCertificateChainFile /sites/SSL/metabase/ca_bundle.crt
sudo systemctl reload apache2
Now your Metabase (and PHP app) will be accessible securely via HTTPS.
Visit https://app.example.com
→ You should see your PHP app
Visit https://metabase.example.com
→ You should see Metabase UI, proxied securely
With Apache’s reverse proxy and a bit of configuration, it’s easy to host multiple apps (even in different languages) on a single server. Whether you’re bootstrapping a startup or managing internal tools, this approach is both efficient and production-ready.
Let us know in the comments — are you running other combinations like Node.js + PHP, or Java + Python?
JSON (JavaScript Object Notation) is a lightweight data-interchange format widely used in web development. At…
AJAX (Asynchronous JavaScript and XML) is a powerful technique used in modern web development that…
Introduction After successfully optimizing your website for speed, it's essential to maintain and build upon…
Securing your WordPress folders is crucial to safeguarding your website from unauthorized access and potential…
Creating a file upload feature with a circular progress bar involves multiple steps. You'll need…
Integrating WP Rocket with AWS CloudFront CDN helps to optimize and deliver your website content…