Assuming a Linux operating system (on the web server), you might consider installing the batch
and/or at
utilities and use them from your web application (BTW, you could consider better tools than PHP for it, e.g. ocsigen). You definitely should master Linux system programming techniques since you are using several processes simultaneously (the web server and your CLI running command).
You could be interested in FastCGI (or use HTTP proxy techniques on your web server, with perhaps some HTTP server library like libonion used in your own server program with an event loop monitoring long-lasting tasks) ....
The important issue is how to notify your web user of the completion of the long lasting Linux process started on the web server. Maybe inter-process communication techniques (see poll(2), pipe(7), unix(7), ....) are relevant (between long lasting programs and web service code). Read also ALP. Of course you want to protect your web service against DoS attacks and you need to care about job control (so be at least aware of setrlimit(2), time(7), signal(7), fork(2), execve(2), wait4(2), dup2(2) etc...).
You could be interested in inotify(7) facilities. The long lasting job could run in some batch
script ending with e.g. an echo done > somefile
to create a file, and you would use inotify facilities for synchronization purposes in your web server.
Assuming recent graphical browsers used for your web application, you might consider using Websockets and AJAX techniques: on the web server side, you would use polling techniques or some event loop, and when the job is completed you'll asynchronously send on the websocket some JSON message, with some AJAX javascript code in the browser to handle it and display something nice when that happens (so passive polling in the browser too...)
PS. See also this question. Several (but not all, and not most) points there are relevant for your needs.