I created a server using php. I also created an html page that acts as the control panel for the php server. If I visit the control panel page and the php server is not running, I want to push on a button which creates a new separate process that launches the php server.
Here is the code that launches the php server (launchserver.php) using a terminal: #!/usr/bin/php -q
<?php
error_reporting(E_ALL);
require_once 'lib/server.php';
require_once 'lib/client.php';
set_time_limit(0);
// Get the local ip address of the host machine (NOTE: Not the loop back address)
$command="/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'";
$ipaddress = exec ($command);
$server = new Server($ipaddress, 15000);
$server->run();
?>
To run the server, I just open a terminal and execute "php -q launchserver.php".
However, I don't want to launch the php script using a terminal, I want to use my new control panel page, where I can click on a button and the button creates a separate process which executes the launchserver.php script and stands up the server and if I leave the control page, the server does not die because I'm no longer in the control page.