简体   繁体   English

Node Application在Apache下的子文件夹中运行

[英]Node Application to run in a sub-folder under Apache

I have a simple node/angular application and I would like it to run under a sub-folder of an apache/php application. 我有一个简单的节点/角度应用程序,我希望它在apache / php应用程序的子文件夹下运行。

What I mean: 我的意思是:

At the moment the node app runs under this url http://www.mysite.com:8080 I need the application to run under http://www.mysite.com/nodeapps/applicationName/index.html 目前,节点应用程序在此URL http://www.mysite.com:8080下运行http://www.mysite.com:8080我需要该应用程序在http://www.mysite.com/nodeapps/applicationName/index.html下运行http://www.mysite.com/nodeapps/applicationName/index.html

Do I need to change something in my apache configuration except moving the application under that folder? 除了将应用程序移动到该文件夹​​下之外,是否需要更改apache配置中的某些内容?

The node app now is under opt/applications/node/applicationName 现在,节点应用程序位于opt/applications/node/applicationName

I am new to Node.js so please make sure that you explain your solution in details or else I am going to get even more confused :) 我是Node.js的新手,因此请确保您详细解释您的解决方案,否则我将变得更加困惑:)

Apache simply serves files. Apache仅提供文件。 However, your node application will also serve files without the need of an extra server. 但是,您的节点应用程序也可以提供文件,而无需额外的服务器。 So you don't want your node.js files to be in a folder served by Apache (this will make the source code public which you probably don't want in most cases). 因此,您不希望将node.js文件放在Apache服务的文件夹中(这会使源代码公开,在大多数情况下您可能不希望这样做)。 Instead, the way to go is to run node.js on a custom port (like the above http://www.example.com:8080 ) and to redirect from apache to that port like so: 相反,方法是在自定义端口(如上述http://www.example.com:8080 )上运行node.js,然后从apache重定向到该端口,如下所示:

RewriteRule /nodeapps/applicationName/(.*) http://localhost:8080/$1 [P]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM