phpvagrantphp-builtin-server

PHP Built in Server Not Working with Vagrant in Host Machine


I'm using vagrant box hashicorp/precise64, Ubuntu 14.04, and PHP 5.6.

My Vagrantfile has config.vm.network "forwarded_port", guest: 80, host: 8080

I'm trying to test with the built in PHP server using: php -S localhost:80

The server is up in the virtual machine. I confirmed this with wget. However, I cannot access it from my host machine. My browser can't reach localhost.

Note: Apache and NodeJS servers both work, but not the built in PHP server.


Solution

  • Solved.

    https://stackoverflow.com/a/5999945/4736111

    I had to use 0.0.0.0 for the address of the php server. Should have been php -S 0.0.0.0:80