简体   繁体   English

如何将两个域名绑定到在同一Azure Ubuntu VM中运行的两个不同的网站(php和nodejs)?

[英]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: 通常,您可以参考以下步骤:

  1. Enable the 80 port inbound rules of your Azure VM. 启用您的Azure VM的80端口入站规则。
  2. Install proxy_module of apache2 in your Azure VM, via command a2enmod proxy proxy_http 通过命令a2enmod proxy proxy_http在您的Azure VM中安装apache2的proxy_module
  3. 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> 
  4. Restart the apache service: sudo service apache2 restart 重新启动apache服务: sudo service apache2 restart

  5. Start node server. 启动节点服务器。

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.

相关问题 为 PHP 中的两个不同文件夹在同一域上设置两个不同会话 - Setting two different sessions on same domain for two different folders in PHP 如何使用php在同一主机上管理两个不同网站的单独会话状态 - How can I manage separate session states for two different websites on the same hosting using php 使用PHP同时登录两个网站 - login to two websites at the same time in PHP 如何处理在同一服务器上运行的两个应用程序实例的PHP会话变量名? - How to handle PHP session variable names for two instances of application running on same server? PHP一次创建两个文件,它们的文件名不同但内容相同 - PHP creates two files at a time with different files names but with the same content 同一域中的两个不同的PHP会话,如何仅销毁其中一个? - Two different PHP sessions in same domain, how to destroy only one of them? 如何使用 Visual Studio 19 调试在 azure Ubuntu VM 上运行的 php 应用程序 - How to use visual studio 19 to debug a php app running on an azure Ubuntu VM 如何显示来自具有相同列名的两个不同表的结果 - How to display results from two different tables with the same column names 如果会话名称在两个不同的网站上相同会发生什么? - What happens if session name is same on two different websites? 在同一个域中有两个不同的会话 - Having two different sessions in same domain
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM