Limit max number of php or apache processes per user

mathx

Active Member
Jan 16, 2017
26
3
3
Toronto
cPanel Access Level
DataCenter Provider
Amazed this isnt a topic I could find at all with 10 google searches on the forums.

Everyone knows xmlrpc.php is being hammered by botnets looking for ways into wordpress. Even with the file removed, we were getting heavily loaded by 404s being returned to the hacker. Luckily they were coming from one IP so we could firewall this time. Not so lucky if we get hit by a botnet with only one hit per IP.

Ulimit doesnt seem to work for users' limits on # of processes total in the system, I figure because suexec is used by apache to execute as the user and isnt inheriting the ulimits.

Is there a way to limit the # of php/apache processes per user?
 

mathx

Active Member
Jan 16, 2017
26
3
3
Toronto
cPanel Access Level
DataCenter Provider
I worded my query wrong -- there is a general problem with any php that is being run that requires a username and password - even custom code. Botnets or hackers just keep hitting the login.php or equivalent in WP, Joomla, etc as well as custom code --

We'd prefer to just limit the # of apache processes per user so the load doesnt climb beyond when email is delivered and the system is sluggish. 10 should be more than enough to serve many requests.

So we need the generic solution, not the specific one for wordpress.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,243
463

mathx

Active Member
Jan 16, 2017
26
3
3
Toronto
cPanel Access Level
DataCenter Provider
or just use the darn hack of checking every 15 seconds to make sure there arent too many processes for a user, and killing the most recent/oldest/most cpu/some criteria. a short script works. kinda not elegant though.

but easier than a whole OS reinstall.
 

Anoop P Alias

Well-Known Member
Mar 31, 2015
103
16
18
Kochi,Kerala,India
cPanel Access Level
Root Administrator
You can set an upper limit or max php process if you use PHP-FPM SAPI . But your idea is generally not good and when you are under attack,your entire website and real users will also get affected. The best way to deal with this is to use a nginx frontned and use config like Module ngx_http_limit_conn_module . You can limit the request to a particular URL like /xmlrpc.php for example with this without affecting other parts of your website.