There is no method specific to PHP when it comes to running jobs in the background. The widely accepted methods are:
screen (if it is not already installed), then run your PHP script under a screen. You can detach from the
screen anytime and log out of the machine and the script will continue running. Here is one of the few hundred tutorials available online about how to use
nohup. The usage is:
nohup <yourPHPcommand> &
nohup will let your script 'say no' to the HANGUP signal when you log out, as a result, your PHP script will keep running even after you logout. The only problem is that you won't be able to bring that job/process to foreground and see the output(if it matters to you). You can redirect the output to a file and see what it is printing out from that file though.
Out of the above two, I recommend you use the
screen. You can attach to the screen anytime you want and control the process the same way you would've if you had started in the foreground.
P.S:- Running the script with the ampersand (
&) at the end does put it in the background, but the script/process gets killed when you log out of the terminal.