How to Depoy Angular on Apache Tomcat Remote Server – Vultr Hosting VPS Example

In the tutorial, we show you how to deploy Angular Client with Production mode on Apache Tomcat Remote Server with Vultr Hosting VPS.

Related post:
Angular 6 dynamic Navigation Bar – add/remove Route dynamically
How to Install Apache Tomcat on Ubuntu Remote Server – Vultr Hosting Example

Technologies

– Vultr Hosting
– Apache Tomcat Server
– Angular

Goal

Deploy Angular Client on Apache Tomcat remote VPS:

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-app-manager-with-angular-app-deployment

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-app-working

How to achieve it?

Start with production build ng build --prod.
-> Then copy output folder (dist/ by default) to Apache Tomcat server.

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-copy-build-files-from-local-to-depoy-folder

What are Production --prod optimizations?

  • Ahead-of-Time (AOT) Compilation: pre-compiles Angular component templates.
  • Production mode: deploys the production environment which enables production mode.
  • Bundling: concatenates your many application and library files into a few bundles.
  • Minification: removes excess whitespace, comments, and optional tokens.
  • Uglification: rewrites code to use short, cryptic variable and function names.
  • Dead code elimination: removes unreferenced modules and much unused code.

If the app uses the Angular router, When asked for a file that it does not have, Apache Tomcat server will return 404 – Not Found error.
-> Configure 404 error on the server to redirect requests for missing files to index.html:

RewriteRule ^(.*)$ /index.html [L]

Practice

Sourcecode for deployment at: link

Start Vultr Hosting Server

Follow the link to create a Linux Vultr VPS.

install-java-in-linux-remote-server-with-vultr-hosting-vps-tom-cat-server-information

Install Apache Tomcat Server

– Use Putty, login to above server gkz-vps:

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-putty-connect

Follow below article to install Apache Tomcat server:

Install Apache Tomcat on Ubuntu Remote Server – Vultr Hosting Example

– Check your Apache Tomcat server: sudo systemctl status tomcat

-> Result:

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-tomcat-status

Build Angular Client

– Build Production for Angular Client: ng build --prod --base-href "/gkzdemo/"

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-build-angular

– Output is dist folder:

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-build-out-put

Deploy Angular Client on Tomcat Server

– Use scp to copy building files from local to remote server:

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-copy-build-files-from-local-to-depoy-folder

– Restart Tomcat server by cmd sudo systemctl restart tomcat

-> Check results:

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-app-manager-with-angular-app-deployment

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-app-working

– Press SignUp button, got 404 Error:

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-404-error-2-sign-up

– Press a link on Browser URL, got Error 404 ->

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-404-error

Configure 404 Error Redirect

– Add RewriteValve in /opt/tomcat/latest/conf/context.xml:


Full details context.xml file ->





    
    
    WEB-INF/web.xml
    WEB-INF/tomcat-web.xml
    ${catalina.base}/conf/web.xml

    
    

    


In gkzdemo project folder, create WEB-INF folder, then add a file rewrite.config in WEB-INF with below content:

RewriteCond %{REQUEST_URI} !^.*\.(bmp|css|gif|htc|html?|ico|jpe?g|js|pdf|png|swf|txt|xml|svg|eot|woff|woff2|ttf|map)$
RewriteRule ^(.*)$ /index.html [L]

Restart Tomcat Server with below cmd: sudo service tomcat restart

-> Check results:

Press SignUp button, index.html file is redirected:

deploy-angular-on-apache-tomcat-remote-server-with-vutr-hosting-404-error-2-sign-up-fix-error

SourceCode

AngularDynamicRoutes

46 thoughts on “How to Depoy Angular on Apache Tomcat Remote Server – Vultr Hosting VPS Example”

  1. Hey just wanted to give you a quick heads up. The words in your article seem to be running off the screen in Safari. I’m not sure if this is a format issue or something to do with web browser compatibility but I figured I’d post to let you know. The layout look great though! Hope you get the problem resolved soon. Cheers

  2. I am also commenting to let you understand of the notable discovery our child encountered browsing your site. She even learned several things, which included how it is like to have a very effective teaching heart to make other individuals without problems fully understand a variety of tortuous topics. You undoubtedly surpassed her desires. I appreciate you for churning out the valuable, trustworthy, educational and in addition easy thoughts on this topic to Emily.

  3. Good day! Would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would really appreciate your content. Please let me know. Many thanks

  4. We’re a gaggle of volunteers and starting a new scheme in our community. Your website provided us with helpful info to work on. You’ve performed an impressive process and our entire group will probably be grateful to you.

  5. Thanks for another informative site. Where else could I am getting that type of info written in such a perfect way? I have a undertaking that I am just now operating on, and I have been at the glance out for such info.

  6. Thanks for the sensible critique. Me and my neighbor were just preparing to do a little research on this. We got a grab a book from our local library but I think I learned more from this post. I’m very glad to see such excellent info being shared freely out there.

  7. Excellent post. I was checking continuously this blog and I am impressed! Very helpful information specially the last part 🙂 I care for such information a lot. I was seeking this particular info for a long time. Thank you and best of luck.

  8. Can I simply say what a aid to search out somebody who actually is aware of what theyre speaking about on the internet. You positively know the right way to carry a problem to light and make it important. Extra people need to read this and understand this facet of the story. I cant imagine youre not more in style because you undoubtedly have the gift.

  9. hello there and thank you for your information ?I have definitely picked up something new from right here. I did however expertise a few technical issues using this web site, since I experienced to reload the web site many times previous to I could get it to load correctly. I had been wondering if your web hosting is OK? Not that I’m complaining, but slow loading instances times will often affect your placement in google and could damage your quality score if advertising and marketing with Adwords. Well I抦 adding this RSS to my email and could look out for a lot more of your respective intriguing content. Make sure you update this again soon..

  10. Thanks for your valuable post. As time passes, I have come to be able to understand that the particular symptoms of mesothelioma cancer are caused by the actual build up connected fluid regarding the lining of the lung and the breasts cavity. The ailment may start inside chest place and get distributed to other parts of the body. Other symptoms of pleural mesothelioma include weight-loss, severe deep breathing trouble, nausea, difficulty ingesting, and irritation of the neck and face areas. It ought to be noted that some people living with the disease tend not to experience every serious signs at all.

  11. you’re really a good webmaster. The web site loading speed is amazing. It seems that you’re doing any unique trick. Furthermore, The contents are masterpiece. you have done a wonderful job on this topic!

  12. Thanks for enabling me to achieve new suggestions about computers. I also have belief that certain of the best ways to keep your notebook computer in primary condition has been a hard plastic-type case, or maybe shell, that will fit over the top of one’s computer. Most of these protective gear usually are model precise since they are manufactured to fit perfectly in the natural covering. You can buy these directly from the seller, or via third party sources if they are intended for your laptop, however not every laptop could have a cover on the market. Once more, thanks for your tips.

  13. I’m so happy to read this. This is the type of manual that needs to be given and not the random misinformation that is at the other blogs. Appreciate your sharing this best doc.

  14. Thanks for your post. One other thing is that if you are disposing your property on your own, one of the difficulties you need to be conscious of upfront is when to deal with home inspection reviews. As a FSBO vendor, the key about successfully switching your property and saving money about real estate agent revenue is knowledge. The more you know, the more stable your property sales effort might be. One area where by this is particularly critical is reports.

  15. Thanks for the distinct tips contributed on this weblog. I have realized that many insurers offer buyers generous deals if they elect to insure many cars with them. A significant number of households own several autos these days, specially those with more aged teenage children still dwelling at home, as well as savings upon policies might soon mount up. So it makes sense to look for a bargain.

  16. This design is incredible! You certainly know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

  17. I admire the useful facts you offer inside your articles. I will bookmark your weblog and also have my children verify up here often. I’m very sure they’ll learn a lot of new things right here than anybody else!

  18. I was just looking for this info for some time. After six hours of continuous Googleing, at last I got it in your website. I wonder what is the lack of Google strategy that do not rank this type of informative web sites in top of the list. Generally the top websites are full of garbage.

  19. I just want to tell you that I’m very new to weblog and honestly liked this web site. More than likely I’m planning to bookmark your blog post . You certainly come with exceptional articles and reviews. Bless you for sharing your web site.

  20. *The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.

  21. Pretty portion of content. I simply stumbled upon your site and in accession capital to say that I get in fact loved account your weblog posts. Anyway I will be subscribing on your augment and even I fulfillment you get admission to consistently quickly.

  22. Its such as you learn my mind! You appear to know so much approximately this, such as you wrote the ebook in it or something. I believe that you simply can do with a few to pressure the message house a bit, but other than that, that is fantastic blog. A fantastic read. I’ll definitely be back.

  23. I simply could not leave your site prior to suggesting that I actually loved the usual information an individual provide in your guests? Is going to be again frequently to inspect new posts

  24. These days of austerity in addition to relative stress about running into debt, lots of people balk about the idea of making use of a credit card to make acquisition of merchandise and also pay for a vacation, preferring, instead just to rely on the tried in addition to trusted technique of making repayment – hard cash. However, if you possess the cash there to make the purchase entirely, then, paradoxically, this is the best time to use the credit cards for several good reasons.

  25. Thanks for the something totally new you have unveiled in your text. One thing I’d really like to discuss is that FSBO relationships are built over time. By bringing out yourself to the owners the first weekend break their FSBO can be announced, prior to a masses begin calling on Monday, you produce a good interconnection. By sending them resources, educational resources, free accounts, and forms, you become an ally. By subtracting a personal interest in them and their circumstances, you create a solid link that, most of the time, pays off when the owners decide to go with a representative they know in addition to trust — preferably you actually.

  26. I just couldn’t depart your web site prior to suggesting that I extremely enjoyed the standard information a person provide for your visitors? Is going to be back often to check up on new posts

  27. 753902 132610Your talent is really appreciated!! Thank you. You saved me lots of frustration. I switched from Joomla to Drupal towards the WordPress platform and Ive fully embraced WordPress. Its so considerably easier and easier to tweak. Anyway, thanks once again. Awesome domain! 988308

Leave a Reply

Your email address will not be published. Required fields are marked *