Assuming a Linux operating system (on the web server), you might consider installing the
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.
PS. See also this question. Several (but not all, and not most) points there are relevant for your needs.