Skip to content
Advertisement

How to shutdown default PHP server “php -S”

I can start the default PHP server with php -S localhost:8000 but how to stop the server? Usually with CTRL + C yes, but if i want to do it from another terminal?

Advertisement

Answer

starting:

nohup php -S localhost:8000 &
pid=$!
echo $pid >/var/run/php.pid

stopping

pid=$(cat /var/run/php.pid)
kill $pid

That’s only an example without proper error handling

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement