Is it a common choice to deploy an AngularJS app to a vanilla Apache HTTP server?

后端 未结 2 1358
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 05:19

I was curious about what kind of server an AngularJS app was usually deployed into, and Google didn\'t give a satisfactory answer. In particular, it looks to me that an AngularJ

相关标签:
2条回答
  • 2021-02-01 05:45

    Any client-side framework like AngularJS isn't going to be bothered in the slightest by using just a vanilla Apache install, because it's pure client-side JavaScript.

    That said, it's a rare single-page web app that doesn't have at least some interaction with the web server via AJAX in order to fetch and amend the data stored there, and that's where you may need to consider what server you should use carefully. Ultimately you can build your back end with whatever server-side technology you feel is most appropriate, be that PHP, Python, Ruby, Node or whatever, and your choice of server will be dictated more by that than by your choice of client-side framework.

    I will add that I've often heard that Nginx is faster than Apache for serving static files, to the point that it's sometimes worth using Nginx for static files and reverse proxying to Apache for dynamic content. So it might make more sense to use Nginx than Apache for single page web apps. Personally I've used Nginx with Gunicorn for a Django app, and from what I've heard it's commonly used for both Ruby and Node.js applications as well. In the context of Node.js, I don't believe Node is generally used for serving static files in production, and from what I've heard the more usual arrangement is to have Nginx serve the static files and reverse proxy to the Node app for everything else.

    0 讨论(0)
  • 2021-02-01 05:50

    I run nginx to serve static AngularJS content. The backend functionality is served by NodeJS server that provides all necessary dynamic content and answers REST requests from the client-side. Nginx routes the dynamic queries to NodeJS, and serves static content directly. Both, client-side and server-side logic is written in the same language (JavaScript, or CoffeeScript).

    The biggest benefit of this is that we can load-balance client-side static content and backend content separately. It depends on the size of your app and demands that it makes regarding the dynamic content access.

    Some other posts on the subject of deploying AngularJS:

    • Do not run 'grunt server' in production: can grunt server use for production application deployment
    • Run Apache/Nginx in production: Best way for deploy angular.js application made with yeoman?
    • Hosting server/client side together: The best deployment architecture for angularjs nodejs app
    0 讨论(0)
提交回复
热议问题