如何在 Vagrant 和 ruby-debug-ide 上配置端口
How to configure ports on Vagrant and ruby-debug-ide
我正在尝试为我的 Web 应用程序配置调试器,但我 运行 在为其指定正确的端口时遇到了麻烦。
流浪文件:
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 用于调试
gem 'ruby-debug-ide', group: [:development,:test]
gem 'debase', group: [:development,:test]
我读到为了在 vagrant 上使用 ruby-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
在另一个 ide 上,如果我尝试更改 Vagrantfile 中的那些端口,我将失去从 127.0.0.1:specified_port 访问我的应用程序的机会,但仍然可以从mysite.com,令人困惑
您已经在端口 80(apache 或 nginx)上监听了一些东西,所以您不能绑定到这个端口。您可以执行以下操作之一
- 在另一个端口上启动 rails,例如 3000
在你流浪的开始rdebug-ide --host 0.0.0.0 --port 3000 --dispatcher-port 3000 -- bin/rails s
如果您在 vagrantfile 中使用私有网络 IP,则不需要转发端口,因为您将使用自己的 IP 访问您的 VM 服务器
- 检查端口 80 上正在侦听的内容
运行 sudo netstat -nltp
在你的VM中,检查绑定80端口的进程并杀死它
例如
vagrant@precise32:/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)
我正在尝试为我的 Web 应用程序配置调试器,但我 运行 在为其指定正确的端口时遇到了麻烦。
流浪文件:
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 用于调试
gem 'ruby-debug-ide', group: [:development,:test]
gem 'debase', group: [:development,:test]
我读到为了在 vagrant 上使用 ruby-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
在另一个 ide 上,如果我尝试更改 Vagrantfile 中的那些端口,我将失去从 127.0.0.1:specified_port 访问我的应用程序的机会,但仍然可以从mysite.com,令人困惑
您已经在端口 80(apache 或 nginx)上监听了一些东西,所以您不能绑定到这个端口。您可以执行以下操作之一
- 在另一个端口上启动 rails,例如 3000
在你流浪的开始rdebug-ide --host 0.0.0.0 --port 3000 --dispatcher-port 3000 -- bin/rails s
如果您在 vagrantfile 中使用私有网络 IP,则不需要转发端口,因为您将使用自己的 IP 访问您的 VM 服务器
- 检查端口 80 上正在侦听的内容
运行 sudo netstat -nltp
在你的VM中,检查绑定80端口的进程并杀死它
例如
vagrant@precise32:/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)