Sumit Trivedi
Sumit Trivedi

Reputation: 133

Deploy frontend in angular and backend in java in cpanel

I have used angular framework for frontend development and created spring boot application for backend. To run my application on my local server(my computer), I first run spring boot application in eclipse and angular application through angular cli. But how can I deploy and host my project to cpanel?

Upvotes: 0

Views: 2242

Answers (2)

Pradeep007
Pradeep007

Reputation: 1

First assign a static ip address to your computer google by yourself Step 1 => build angular project using ng build --ouptput-path dist Step 2 => allow firewall by sudo ufw allow 80 && sudo ufw allow out 80 Step 3 => instll nginx or apache server and configure your angular build dist path to nginx or apache you can change port to anything other than 80 Step 4: enable port forwarding in your router by going through this url 192.168.1.1 and username should be admin or user most of the times and password also should be admin or user Step 5: use your public ip address to use your frontend it will be up and ruinning Step 6: follow step 4 and 6 for backend as well after runnign tomcat server note : make sure you are using public ip address to do backend api calls in angular project.

Congradulations your full stack application is ruinning in your own computer

Upvotes: 0

Chandan
Chandan

Reputation: 740

Step 1) Angular build command - "ng build --prod" . This will create a dist folder in you angular project main directory, if you navigate in to this directory you will see folders where assets, index.html, main.xxxxxxxx.js, polyfills.xxxxxxxx.js and runtime.xxxxxxxxx.js etc will be available

Angular dist folder (miracleApp is my app name, so all files will be under this)

Step 2) Copy all the above files from the dist directory and paste them in src/main/resources directory of your java project

Java Project

Step 3) Now do a maven build (hope yours is a maven project) using "package" as the goal and if build is successful you will see a target folder with either a jar or a war (depending on what you choose packaging option in pom.xml) file which will have all your angular and java code and ready to use

Step 4) Now go to your service providers cpanel (make sure your service provider accepts java application deployments and not just php, I faced this issue sometime back where service providers allow only php applications) and use this packaged jar or war file for deployment on the provided server

Upvotes: 1

Related Questions