如何配置vagrant与node.js一起使用 [英] How to configure vagrant to work with node.js
问题描述
我在使用流浪汉运行node.js时遇到问题.
我有以下项目结构:
I have problem with running node.js with vagrant.
I have following structure of project:
- public
- hello.js
- vagrant
- puphpet
- Vagrantfile
这是我的puphpet配置:
Here's my puphpet config:
---
vagrantfile-local:
vm:
box: puphpet/debian75-x64
box_url: E:\vagrant boxes\debian-7.5-x86_64-v1.2-virtualbox.box
hostname: ''
memory: '1024'
cpus: '1'
chosen_provider: virtualbox
network:
private_network: 192.168.56.102
forwarded_port:
BD200PpFPN2U:
host: '3000'
guest: '3000'
post_up_message: ''
provider:
virtualbox:
modifyvm:
natdnshostresolver1: on
vmware:
numvcpus: 1
parallels:
cpus: 1
provision:
puppet:
manifests_path: puphpet/puppet
manifest_file: site.pp
module_path: puphpet/puppet/modules
options:
- '--verbose'
- '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
- '--parser future'
synced_folder:
uREBTumUq032:
owner: www-data
group: www-data
source: ../
target: /var/www
sync_type: default
rsync:
args:
- '--verbose'
- '--archive'
- '-z'
exclude:
- .vagrant/
auto: 'false'
usable_port_range:
start: 10200
stop: 10500
ssh:
host: null
port: null
private_key_path: null
username: vagrant
guest_port: null
keep_alive: true
forward_agent: false
forward_x11: false
shell: 'bash -l'
vagrant:
host: detect
server:
install: '1'
packages: { }
firewall:
install: '1'
rules: null
apache:
install: '1'
settings:
user: www-data
group: www-data
default_vhost: true
manage_user: false
manage_group: false
sendfile: 0
modules:
- rewrite
vhosts:
XWIOX0y1wPTF:
servername: nodeapp.com
docroot: /var/www/public
port: '80'
setenv:
- 'APP_ENV dev'
override:
- All
options:
- Indexes
- FollowSymLinks
- MultiViews
engine: php
custom_fragment: ''
ssl_cert: ''
ssl_key: ''
ssl_chain: ''
ssl_certs_dir: ''
mod_pagespeed: 0
这是hello.js文件
Here is hello.js file
var http = require('http');
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World!");
});
server.listen(3000);
我登录到SSH,然后转到var/www/public,其中有文件hello.js.我跑
I log to SSH then I go to var/www/public there is file hello.js. I run
node hello.js
我没有收到任何错误/消息.
I dont get any error/message.
然后我进入192.168.56.102:3000,然后我得到:
连接超时
Then I go to 192.168.56.102:3000 and after while I get:
The connection has timed out
地址192.168.56.102返回404状态代码,因此apache正在运行.
Address 192.168.56.102 returns 404 status code, so apache is working.
我尝试将config.yaml中的主机和来宾更改为端口8080,但没有成功.
I tried change host and guest in config.yaml to port 8080 but it didnt work.
我做错了吗?
推荐答案
尝试将转发的端口删除到3000,并将其添加到防火墙部分.
Try removing the forwarded port to 3000 and adding that into the firewall section.
这篇关于如何配置vagrant与node.js一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!