2017-03-23 25 views
0

我正在尝试为我的Web应用程序配置调试器,但遇到了指定正确端口的麻烦。 Vagrantfile:
如何在Vagrant和ruby-debug-ide上配置端口

config.vm.network :private_network, ip: "192.168.68.8" 
config.vm.network :forwarded_port, guest: 80, host: 8080 

/etc/hosts文件(我的主机上)

192.168.68.8 mysite.com 

我安装了这两种宝石进行调试

gem 'ruby-debug-ide', group: [:development,:test] 
gem 'debase', group: [:development,:test] 

我读到为了使用红宝石-debug-ide对流浪者,我应该运行 rdebug-ide --host 0.0.0.0 --port 80 --dispatcher-port 8080 -- bin/rails s 其中--port应该从Vagrantfile来宾端口和主机端口`--dispatcher-port``

但它说

Permission denied - bind(2) for "0.0.0.0" port 80 

在另一边,如果我尝试改变Vagrantfile这些端口,我失去机会从127.0.0.1:specified_port到达我的应用程序,但仍然可以从mysite.com,这是困惑

回答

1

你已经有东西在端口80(Apache或Nginx)监听,所以你不能绑定在这个端口。您可以在以下

  1. 启动轨道做另一个端口像3000
在游民

开始rdebug-ide --host 0.0.0.0 --port 3000 --dispatcher-port 3000 -- bin/rails s

如果使用私网IP在vagrantfile你不需要转发端口因为你会使用自己的IP访问你的VM服务器

  • 检查什么是端口监听80
  • 在虚拟机上运行sudo netstat -nltp,检查结合80端口的进程,杀死它

    例如

    [email protected]:/etc/init.d$ sudo netstat -nltp 
    Active Internet connections (only servers) 
    Proto Recv-Q Send-Q Local Address   Foreign Address   State  PID/Program name 
    tcp  0  0 0.0.0.0:111    0.0.0.0:*    LISTEN  512/rpcbind 
    tcp  0  0 0.0.0.0:80    0.0.0.0:*    LISTEN  1827/apache2 
    tcp  0  0 0.0.0.0:22    0.0.0.0:*    LISTEN  652/sshd 
    tcp  0  0 0.0.0.0:58397   0.0.0.0:*    LISTEN  539/rpc.statd 
    tcp6  0  0 :::111     :::*     LISTEN  512/rpcbind 
    tcp6  0  0 :::22     :::*     LISTEN  652/sshd 
    ... 
    

    所以你杀的Apache2进程(PID 1827)