简体   繁体   中英

Running a high performance C program through PHP exec

We are designing a very basic UI for a traffic generator(High performance). It works fine when we run the binary over the shell directly but the performance drops when we do an exec through php script. It slows down terribly.

We have searched and it might be due to the apache environment not creating a thread for the exec.

Is there any way to decrease the processing time or through some other server side scripting?

Thank you.

You can run commands in background using exec. Just append > /dev/null & at end of command. It will execute that command in shell and return immediately without waiting for command to finish.

exec($cmd . " > /dev/null &");

Solution1

You can make changes in php.ini for increasing performance.

Like increase memory_limit to higher value with respect to your RAM

Solution2

You are executing the program as webuser(nobody/apache/ww-data) which is a less preivilged user.That is the problem. You can execute that command as more previlged user / root using sudo. Try sudo in php exec()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM