Applicable to:
- Plesk for Linux
Symptoms
-
It is not possible to start or restart Apache web server, all websites are down:
# service httpd start
Starting httpd: [FAILED]Or:
# systemctl start apache2.service
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details. -
The following error can be found in the
/var/log/httpd/error_log
file (/var/log/apache2/error.log
in Debian and Ubuntu):CONFIG_TEXT: [error] (24)Too many open files: Init: Can't open server certificate file /usr/local/psa/var/certificates/cert8bV9dbI
'import site' failed; use -v for tracebackOr:
CONFIG_TEXT: AH00015: Unable to open logs
-
The following error is shown when trying to start Apache using the
strace
utility (in Debian and Ubuntu, Apache binary is/usr/sbin/apache2
):# strace -q -vttT -s4096 /usr/sbin/httpd -e debug -k start
...
open("/var/www/vhosts/system/example.com/logs/access_ssl_log", O_WRONLY|O_CREAT|O_APPEND|O_CLOEXEC, 0666) = -1 EMFILE (Too many open files) <0.000011>
write(408, "[Wed Sep 13 21:27:55.156566 2017] [log_config:error] [pid 22172:tid 140081010858112] (24)Too many open files: AH00649: could not open transfer log file /var/www/vhosts/system/example.com/logs/access_ssl_log.\n", 235) = 235 <0.000034>
write(2, "AH00015: Unable to open logs\n", 29) = 29 <0.000022>
Cause
The maximum allowed number of file descriptors is not enough for Apache web server.
Resolution
Click on a section to expand
-
Connect to the server via SSH
- Set desired open files limit to for both Apache and Nginx, using the following shell utility
# /usr/local/psa/admin/sbin/websrv_ulimits --set 32768 --no-restart
- Restart Apache and nginx services at Plesk > Tools & Settings > Services Management to apply changes.
Another solution is to increase open file limit manually:
-
Create the directory
/lib/systemd/system/httpd.service.d/
directory (apache2.service.d
in Debian and Ubuntu):# mkdir /lib/systemd/system/httpd.service.d/
-
In this directory, create
limit_nofile.conf
file in it with the following content:# cat /lib/systemd/system/httpd.service.d/limit_nofile.conf
[Service]
LimitNOFILE=65536 -
Reload systemd unit files and start Apache (in Debian and Ubuntu, service is called
apache2.service
):# systemctl daemon-reload
# systemctl start httpd.serviceNote: If the issue still persists on the Debian-like systems, increase limits through APACHE_ULIMIT_MAX_FILES environment variable as it is described below for SysVinit OSes.
-
For Debian and Ubuntu:
-
Connect to the server via SSH
-
Put the
APACHE_ULIMIT_MAX_FILES='ulimit -n 131072'
line into the/etc/apache2/envvars
file:# grep ULIMIT /etc/apache2/envvars
APACHE_ULIMIT_MAX_FILES='ulimit -n 131072' -
Restart the Apache service:
# service apache2 restart
-
-
For RHEL-based operating systems:
-
Connect to the server via SSH
-
Comment the following section in the
/usr/sbin/apachectl
file:CONFIG_TEXT: #ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
#-------------------- --------------------
#|||||||||||||||||||| END CONFIGURATION SECTION ||||||||||||||||||||
#Set the maximum number of file descriptors allowed per child process.
#if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
#$ULIMIT_MAX_FILES
#fi -
After the commented section, add
ulimit -n 131072
line:CONFIG_TEXT: ..........
#$ULIMIT_MAX_FILES
#fi
ulimit -n 131072 -
Add the
ulimit -n 131072
line into the/etc/sysconfig/httpd
file:# grep -i ulimit /etc/sysconfig/httpd
ulimit -n 131072 -
Restart the Apache service:
# service httpd restart
-
Comments
0 comments
Please sign in to leave a comment.