How to kill these PHP process safely?

I have installed php5 in ubuntu and WordPress. It can run after installed. But after few days I've found there are lots of process and occupied a lot of memories. I try to use

ps -aux | grep www-data

and found about 30 processes like this.

www-data  5066  0.0  0.0 131664   780 ?        S    16:20   0:00 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf

I tried to

kill -9 pid

and it didn't work, more process appears again. So could you tell me how to kill them safely and I don't want to my vps' memory occupied by it.


Solution 1:

and it didn't work, more process appears again

Really? While I'd expect more processes to appear the one you killed should go away.

If you want to stop all of these then shutdown the daemon, I don't know how it's configured on your machine, but here I'd do....

/etc/init.d/php-fpm stop

But htat's not the way to fix the problem of "I've found there are lots of process and occupied a lot of memories". You should start by doing proper traffic analysis and profiling the code.