Hi,
I have Debian 6,Apache 2.2.16. On this run two page first.net - many visit user, - much less page visit. When restart apache2,that run both page ok, but after few minutes/hours cant load page second.net. In /log/apache2/ is: mod_fcgid: can't apply process slot for /var/www/webuser/php5-wrap In log /log/apache2/first.net is it certainly but less(given the number of user). When is error? What is wrong?

cat /var/www/webuser/php5-wrap

#!/bin/sh
PHP_FCGI_CHILDREN=1
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php5-cgi

cat /etc/apache2/mods-enabled/fcgid.conf

<IfModule mod_fcgid.c>
  AddHandler    fcgid-script .fcgi
  FcgidConnectTimeout 45
IPCConnectTimeout 100
MaxRequestsPerProcess 1000
MaxProcessCount 2
DefaultMinClassProcessCount 0
FcgidMaxRequestsPerProcess 0
</IfModule>

Dani AI

Generated

Likely diagnosis: mod_fcgid is running out of FastCGI process slots for that PHP wrapper — the module refuses to spawn more processes when its configured pool (global and per‑script limits) is exhausted, so you see the “can’t apply process slot” errors and intermittent failures. (stackoverflow.com)

Quick checks to run (do these before changing config so you know current behaviour):

# look for recent fcgid errors
sudo grep -i fcgid /var/log/apache2/error.log | tail -n 100

# count running php-cgi/php processes
ps -ef | egrep 'php-cgi|php-fpm' | sed -n '1,200p'
pgrep -a php-cgi

# if mod_status enabled: see busy workers
curl -s http://localhost/server-status?auto

# check system limits (systemd/cgroups or pid limits)
cat /sys/fs/cgroup/pids/*/pids.max 2>/dev/null || ulimit -a

If process counts regularly reach or exceed the fcgid limits, the module will skip spawn requests. (stackoverflow.com)

Practical fixes (in order):

  • Remove/disable PHP process forking in your wrapper (don’t use PHP_FCGI_CHILDREN with mod_fcgid). mod_fcgid expects to manage one request per spawned process; letting PHP spawn its own children causes counting and lifecycle problems. (httpd.apache.org)
  • Tune mod_fcgid limits (global and per‑class): increase FcgidMaxProcesses and FcgidMaxProcessesPerClass to values appropriate for your CPU/RAM, and set FcgidMaxRequestsPerProcess <= PHP_FCGI_MAX_REQUESTS. Use FcgidIdleTimeout / FcgidProcessLifeTime to reclaim long‑idle workers. (httpd.apache.org)
  • Check system limits (cgroups/DefaultTasksMax, pids.max or CloudLinux/LVE); low pid/task limits can prevent spawning even if fcgid allows it. (support.plesk.com)

If load is consistently high, consider moving to PHP‑FPM + mod_proxy_fcgi (or nginx + php‑fpm) which scales better for heavy traffic than per‑vhost fcgid wrappers. (httpd.apache.org)

Notes: as suggested, start by measuring (process counts, slow requests, mod_status) and then change one setting at a time while monitoring logs and load.

Check how many processes Apache has running. It may be that some scripts are not shutting down after the connection has dropped, or the connections are not being dropped from the client(s), resulting in an exhaustion of resources. I think you can set a connection time-out so that connections are automatically dropped after some period of inactivity. You should also be able to increase the number of allowed connections in the Apache configuration files. I'm just getting started in a new job where this is information I need to learn, but I am not there yet, so this is as far as I can take you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.