Skip to content
Want to get Premium Web Hosting only at 45₹/Month Signup Now!

How to Deploy Java Spring Boot Application on Shared cPanel

How to Deploy Java Spring Boot Application on Shared cPanel (Without Terminal Access)

Many developers want to deploy a Java Spring Boot project on shared cPanel hosting, but face a challenge:

  • Shared hosting is optimized for PHP apps (WordPress, Laravel, etc.).
  • Java apps require JVM, custom ports, and sometimes Tomcat, which is rarely supported in shared hosting.

This guide explains possible methods to run a Spring Boot application on shared cPanel without SSH/terminal access.


✅ Step 1: Verify Java Support in Your Hosting

  1. Log in to your cPanel account.
  2. In the search bar, type “Java” or “Tomcat”.
    • If you see Tomcat Manager / Java Selector / Application Manager, then your hosting supports Java.
    • If not, you will have to use a workaround method (explained in Step 5).

⚠️ Note: Not all shared hosting providers allow Java. If your provider doesn’t support it at all, you will need VPS or specialized Java hosting.


✅ Step 2: Build Your Spring Boot Application

On your local machine, package your Spring Boot project:

  1. For Maven: mvn clean package
  2. For Gradle: ./gradlew build
  • If your project is configured with: <packaging>war</packaging> → You will get a WAR file inside target/yourapp.war.
  • If packaging is default → You will get a JAR file inside target/yourapp.jar.

✅ Step 3: Upload Application to cPanel

  1. Go to cPanel → File Manager.
  2. Navigate to a directory, e.g., /home/username/javaapp/.
  3. Upload your WAR/JAR file here.

✅ Step 4: Deploy via Tomcat (If Available in cPanel)

If your hosting supports Tomcat:

  1. Open cPanel → Tomcat Applications / Java Applications.
  2. Click Deploy WAR.
  3. Select your uploaded yourapp.war.
  4. After deployment, your app will be available at: https://yourdomain.com/yourapp/ (Or at root if mapped by your host.)

This is the cleanest way to run Spring Boot on shared hosting.


✅ Step 5: Deploy JAR File Using Cron Jobs (No Tomcat Available)

If your host does not provide Tomcat, but allows Java execution:

  1. Create a startup script
    On your local system, create a file named start.sh with the following content: #!/bin/bash cd /home/username/javaapp/ nohup java -jar yourapp.jar > app.log 2>&1 &
    • This will start your Spring Boot app in the background.
    • nohup ensures it runs even after the cron job finishes.
    • app.log will contain logs for debugging.
  2. Upload the script
    Upload start.sh to your javaapp folder in cPanel File Manager.
  3. Set file permissions
    In File Manager → right-click start.sh → Permissions → make it executable (usually 0755).
  4. Run script via Cron Job
    • Go to cPanel → Cron Jobs.
    • Add a new cron job with command: sh /home/username/javaapp/start.sh
    • Set it to run once (or at reboot if available).
  5. Access your app
    • By default, Spring Boot runs on port 8080.
    • Shared hosts often block custom ports, so you may need to ask your hosting provider to map your domain/subdomain to your app’s port (reverse proxy).
    • Example: yourdomain.com → maps to → serverIP:8080

✅ Step 6: (Optional) Create Stop Script

To stop your app if needed, create a stop.sh:

#!/bin/bash
pkill -f 'yourapp.jar'

Upload it and run it via cron job when required.


✅ Step 7: Limitations of Shared Hosting

  1. Custom Ports Restricted → You may not get direct access without reverse proxy support.
  2. No Root/Terminal Access → You cannot install or manage JVM versions yourself.
  3. Resource Limits → Shared servers may kill heavy apps (Spring Boot apps use more memory than PHP).
  4. Not Ideal for Production → For long-term stable hosting, use VPS/Cloud.

✅ Step 8: Best Alternatives

If your provider doesn’t support Java:

  • Or use a cheap VPS ($5/month) from Yash Host.
  • Deploy with NGINX/Apache reverse proxy for production-grade setup.

🎯 Conclusion

Yes, it is possible to deploy a Spring Boot app on shared cPanel without terminal access, but with limitations.

  • Best Case: Use Tomcat in cPanel and deploy a WAR file.
  • Workaround: Use cron jobs to run your Spring Boot JAR.
  • Recommended for Production: Use VPS or Java-optimized hosting for full stability.
Was this article helpful?
YesNo
Back To Top