You have two other options. You could try running the script as a cron job. It would then run from the command line, bypasing apache. Or you could translate into perl and run from the CLI before considering C/C++
Perl is a good transition language. It has a C syntax and shares some function names. It may also lend itself better to being run from the CLI than PHP.
On my sites, I use perl for background tasks and restrict PHP to foreground, web-based tasks.
You would still need to do some rewritting and translating -- but perl shortern the code-compile-run-debug cycle to code-run-debug. Over the life of a project this is a considerable savings in time.
In both cases, CLI perl and PHP, you can code and test on Windows and run on Linux. To make this easier, you can do this make porting quicker:
While not answering your question, I hope these thoughts are helpful.