How to enable PHP's built-in web server on wercker

187 Views Asked by At

I have setup my wercker.yml file with the following step midway:

- script:
    name: Serve application
    code: php -S localhost:8000 >> /dev/null &

That appears to run, however, in another step when I try cURL to http://localhost:8000 I get the following:

curl: (7) Failed to connect to localhost port 8000: Connection refused

It does it for all ports, not just 8000. Has anyone else managed to get PHP's in built server working in wercker, or open any ports?

1

There are 1 best solutions below

1
On

Assuming you're using the wercker CLI and trying to set up a development pipeline, you need to use wercker dev with the --publish 8000 argument. This will forward the traffic from your host on port 8000 to the container on port 8000.

Also, if you're using boot2docker, you can't specify localhost, since boot2docker spins up a VM that runs docker. In that case you'll need to use your boot2docker IP, which you can find by running the boot2docker ip command.