[英]How to bind two domain names to two different websites(php and nodejs) running in same Azure Ubuntu VM?
I am already running a php based wordpress website on my Azure Ubuntu 16.4 VM. 我已经在我的Azure Ubuntu 16.4 VM上运行了一个基于php的wordpress网站。 now I also want to run a NodeJS website on same server under different domain name . 现在我也想在不同域名的同一台服务器上运行NodeJS网站。 How can I achieve this. 我该如何实现。
I know if both websites would be PHP or both would be .Net then I can do URL rewrite in apache or IIS , but here NodeJS use its own port and web server. 我知道这两个网站都是PHP还是都是.Net,那么我可以在apache或IIS中重写URL,但是在这里NodeJS使用自己的端口和Web服务器。
I am not sure if this works in Azure VM as We have to create inbound and outbound rules from azure portal to open ports of Azure VM. 我不确定这是否在Azure VM中有效,因为我们必须从Azure门户创建入站和出站规则以打开Azure VM的端口。 Apache and Node.js on the Same Server 同一服务器上的Apache和Node.js
Yes, the answer of Apache and Node.js on the Same Server also works fine on Azure VM. 是的, 同一服务器上Apache和Node.js的答案在Azure VM上也可以正常工作。
Generally, you can refer to the following steps: 通常,您可以参考以下步骤:
proxy_module
of apache2 in your Azure VM, via command a2enmod proxy proxy_http
通过命令a2enmod proxy proxy_http
在您的Azure VM中安装apache2的proxy_module
config the Virtual Host in apache configuration file, EG as default, 在apache配置文件(默认为EG)中配置虚拟主机,
run sudo vim /etc/apache2/sites-available/000-default.conf
, and modify as: 运行sudo vim /etc/apache2/sites-available/000-default.conf
,并修改为:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /home/gary ServerName <vm_name>.cloudapp.net <Directory /home/gary> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined ProxyPass /node http://localhost:1337 ProxyPassReverse /node http://localhost:1337 </VirtualHost>
Restart the apache service: sudo service apache2 restart
重新启动apache服务: sudo service apache2 restart
Then, directly browse your VM like via <vm_name>.cloudapp.net
will browse the PHP site in the configured directory, and browse via <vm_name>.cloudapp.net/node
will browse the node application. 然后,像通过<vm_name>.cloudapp.net
直接浏览您的VM,将浏览已配置目录中的PHP站点,并通过<vm_name>.cloudapp.net/node
浏览将浏览节点应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.