簡體   English   中英

如何在apache ubuntu 12.04中為node.js創建虛擬主機

[英]how to create virtual host in apache ubuntu 12.04 for node.js

我基本上是php開發人員,並開始使用node.js. 我已經用我的ubuntu 12.04安裝了node.js. 之后我測試了http(http.js)工作正常。 在這里,我需要知道如何用我的系統和特定的路由文件(如index.php)和apache服務器一起創建像http://192.168.1.1:5001這樣的虛擬主機。 我已經提到了許多鏈接而沒有得到這個問題的好解決方案。

這是為ubuntu 14.0和angular and node設置的虛擬主機:

第1步 -

從'/ etc'打開'hosts'文件

第2步 -

在最后添加下面的行

127.0.0.1       abc.localhost

步驟:3 -

從'/ opt / lampp / etc / extra'打開'httpd-vhosts.conf'文件

第四步 -

最后添加以下代碼

<VirtualHost *:80>
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName abc.localhost
  ServerAlias abc.localhost.com
  ProxyPass / http://localhost:4000/
  ProxyPassReverse / http://localhost:4000/    
</VirtualHost>

步驟:5 -

從終端重啟lampp服務器,如輸入sudo / opt / lampp / lampp restart並輸入重啟

步驟:6 -

轉到存在節點項目的目錄,如在終端上鍵入cd / opt / lampp / htdocs / nodeProject並輸入到啟動節點服務器

步驟:7 -

打開瀏覽器並點擊http://abc.localhost

如果需要,可以為apache創建虛擬主機,然后使用ProxyPass將請求轉發到節點服務器。

<VirtualHost node.example.com:80>   
    ServerName node.example.com  
    ProxyPass / http://localhost:8000/ connectiontimeout=5 timeout=30  #    optional timeout settings  
</VirtualHost>

像這樣節點服務器正在偵聽端口號。 8000

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM