PHP Restart Lighttpd doesn't return
Question
I have a php script which needs to restart lighttpd. The php page never returns to the client. I believe that is because the call doesn't return. Here is my code:
<?php
exec("/etc/init.d/lighttpd restart");
echo "Restarted!";
?>
If I comment out the exec line it returns as expected. How can I get this call to return?
Thanks,
EV
La solution
If you restart you httpd process your scripts will be terminated, no matter what you do!
You will never make any scripts to return a value directly from PHP. To make that work you should add a javascript and check for a 200
Status Code.
Autres conseils
It's because your script kills the existing Lighthttpd process before it is able to return the result of the execution...
It is like having a process that kills himself and wondering why the process is not returning anything...