Apache Increase FD limit

On CentOS 7 sevrer running apache, when try to install plugin in WordPress admin area, i get error

Installazione fallita: Il download non è andato a buon fine. cURL error 35: Process open FD table is full

This is due to Apache File Descriptor Limits.

To see current Limits, use following PHP script

FD Soft Limit: " . exec('ulimit -Sn');
echo "
FD Hard Limit: " . exec('ulimit -Hn');

To see system wide limits, use following commands

sysctl fs.file-nr
sysctl fs.file-max

Normally this will be high value. You need to increse limit for user running Apache. On CentOS 7, the username is “apache”. To increase limit for this user, edit

vi /etc/security/limits.conf

Add following lines

apache soft nofile 10240
apache hard nofile 900000

To verify, we need to login as user Apache, and verify limits, for this, lets enable SSH or bash terminal for user apache. By default no SSH login allowed for this user.

chsh --shell /bin/bash apache

Now change to user, verify the limits

su - apache
ulimit -Hn
ulimit -Sn

Exit back to root, disable shell for user apache with command.

chsh --shell /sbin/nologin apache

We need to edit service file for Apache. Default service file look like following.

[root@centos-s-1vcpu-1gb-blr1-01 ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target
[root@centos-s-1vcpu-1gb-blr1-01 ~]# 

Find

[Service]

Add below

LimitNOFILE=65535
LimitNPROC=65535

Method 2

create file

mkdir -p /etc/systemd/system/httpd.service.d/
vi /etc/systemd/system/httpd.service.d/limits.conf

Add

[Service]
LimitNOFILE=65535
LimitNPROC=65535

Reload service file with

systemctl daemon-reload

Restart Apache

systemctl restart httpd

See Apache

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *