I am running into a baffling issue with Apache. For two times already it would just stall, hit the MaxClients setting (33 as witnessed below) and stops accepting new requests.
Apache Timeout 30 sec
KeepAliveTimeout 2 sec
PHP max_execution_time 30 sec
mysql connect_timeout 10 sec (no problems there, kept serving other clients)
Apache version 2.2.22 (Ubuntu)
mod_php
What am I missing here? What would convince Apache to have the processes linger around like that? Is there any way to limit the "wall clock" time for Apache processes? Apache restart is the cure, but I would still prefer to know the underlying issue..
ps auxf, taken 14:30, so processes have been stuck for over 30 minutes!
root 25963 0.0 0.3 273860 12656 ? Ss May04 6:43 /usr/sbin/apache2 -k start
www-data 15120 0.1 1.0 289684 44872 ? S 13:56 0:03 \_ /usr/sbin/apache2 -k start
www-data 15301 0.0 0.9 290644 41624 ? S 13:57 0:01 \_ /usr/sbin/apache2 -k start
www-data 15392 0.1 1.0 290636 43800 ? S 13:57 0:02 \_ /usr/sbin/apache2 -k start
www-data 15570 0.0 0.9 287508 40512 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15575 0.0 0.9 290684 41528 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15576 0.1 1.0 290612 45080 ? S 13:58 0:02 \_ /usr/sbin/apache2 -k start
www-data 15581 0.1 0.9 290684 41420 ? S 13:58 0:02 \_ /usr/sbin/apache2 -k start
www-data 15582 0.0 0.9 288508 40124 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15583 0.1 0.9 288500 40640 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15584 0.0 1.0 290592 43832 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15593 0.1 1.0 289444 41956 ? S 13:58 0:02 \_ /usr/sbin/apache2 -k start
www-data 15669 0.0 1.0 290432 42312 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15754 0.0 1.0 289200 42468 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15788 0.1 1.0 290580 42068 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15789 0.0 0.9 290428 41088 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15790 0.0 0.9 290488 41004 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15792 0.0 0.8 285756 35944 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15793 0.0 0.9 290488 40880 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15794 0.1 1.0 290508 44920 ? S 13:58 0:02 \_ /usr/sbin/apache2 -k start
www-data 15799 0.0 0.8 285796 36540 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15800 0.0 0.9 290432 40940 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15801 0.0 0.8 285604 36128 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15802 0.1 0.9 290556 41548 ? S 13:58 0:02 \_ /usr/sbin/apache2 -k start
www-data 15803 0.0 0.9 290660 41140 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15804 0.1 0.9 288068 40104 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15805 0.0 0.8 284796 33744 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15806 0.0 0.9 290344 40744 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15811 0.0 0.9 290412 41060 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15812 0.1 1.1 291668 47908 ? S 13:58 0:02 \_ /usr/sbin/apache2 -k start
www-data 15813 0.0 0.9 290512 40980 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
www-data 15814 0.0 0.9 289348 40912 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15815 0.0 0.9 290508 40908 ? S 13:58 0:00 \_ /usr/sbin/apache2 -k start
www-data 15816 0.0 0.9 290508 41020 ? S 13:58 0:01 \_ /usr/sbin/apache2 -k start
Interesting question and I've been dealing with a very similar problem. I've been running a site on AWS t2.micro which has only 1 gig of memory. Like you the site would "stall". It would take 30 seconds for the php index page to render. I'm running on Ubuntu 14.04 with Postgres as the database.
I figured out that apache was not really the problem. If I stopped postgres, then apache would serve the pages quickly, albeit without data. But it certainly pointed to postgres was the culprit. Apache processes were waiting for Postgres queries so I would see a lot of Apache2 processes lingering. Feels like a Postgres memory leak, but hard to nail down.
I upgraded to the t2.small instance on AWS which has 2 gigs of memory. So far so good as no problems yet. Keeping fingers crossed.
Related
I have an Ubunto 18.04 LTS running with apache2 and various PHP versions (5.6 up to 8.0).
Apache is configured to run as the same user as my FTP user (let's call him 'test').
ps aux | grep apache2
says this user name for the processes.
Problem: When I run my website on it, which creates a file, then the file is created as user 'www-data', which only works if I give 777 permission to the folder, as the folder has the user 'test' as it's owner.
Question: How can I make apache write files as the user used for the process it runs with?
Output of ps aux | grep apache2:
test#webserver:/var/www$ ps aux | grep apache2
root 11101 0.0 0.9 501228 27696 ? Ss 14:42 0:00 /usr/sbin/apache2 -k start
test 11103 0.0 0.2 159948 6660 ? S 14:42 0:00 /usr/sbin/apache2 -k start
test 11106 0.0 0.5 503824 16896 ? S 14:42 0:00 /usr/sbin/apache2 -k start
test 11107 0.0 0.5 503556 15348 ? S 14:42 0:00 /usr/sbin/apache2 -k start
test 11109 0.0 0.5 503556 15348 ? S 14:42 0:00 /usr/sbin/apache2 -k start
test 11111 0.0 0.5 503556 15348 ? S 14:42 0:00 /usr/sbin/apache2 -k start
test 11112 0.0 0.5 503556 15348 ? S 14:42 0:00 /usr/sbin/apache2 -k start
test 11114 0.0 0.5 503556 15348 ? S 14:42 0:00 /usr/sbin/apache2 -k start
test 11135 0.0 0.0 13144 1024 pts/0 S+ 14:45 0:00 grep --color=auto apache2
I have issues installing HubHub. I keep getting this error
Invalid Configuration – yii\base\InvalidConfigException
The directory is not writable by the Web process:
/var/www/html/humhub/assets
Although the folder is writable by apache:
$ ls -la /var/www/html/humhub/assets
total 0
drwxrwsrwx. 2 francesco apache 6 Jun 26 14:13 .
drwxrwsrwx. 7 francesco apache 197 Jun 26 14:13 ..
My setting:
Server: Red Hat Enterprise Linux release 8.0 (Ootpa) on AWS
HumHub: 1.3.14 (and Yii Framework/2.0.15)
Web server: Apache/2.4.37 (Red Hat Enterprise Linux)
What I tried:
I made sure the folder was writable by following this answer and this similar answer
I even try to set the entire folder humhub as writable with chmod -R 777 humhub
I made sure that all the PHP requirements were satisfied.
Is it possible that the web process is actually not run by apache with this result?
> ps -ef | grep httpd | grep -v grep
root 20227 1 0 05:30 ? 00:00:02 /usr/sbin/httpd -DFOREGROUND
apache 20229 20227 0 05:30 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 20230 20227 0 05:30 ? 00:00:12 /usr/sbin/httpd -DFOREGROUND
apache 20231 20227 0 05:30 ? 00:00:12 /usr/sbin/httpd -DFOREGROUND
apache 20232 20227 0 05:30 ? 00:00:11 /usr/sbin/httpd -DFOREGROUND
apache 20449 20227 0 05:31 ? 00:00:13 /usr/sbin/httpd -DFOREGROUND
I have install apache httpd 2.4.34 on SLES 15, and there are six httpd processes running.
When I send signal SIGTERM to httpd process, all the six httpd process couldn't receive signal SIGTERM (I had gdb attched httpd process to catch signal SIGTERM),
but I find kill 15 11143 return 0 via command strace. But httpd could reiveive signal SIGKILL, it's very strange.
And apache httpd 2.4.34 running on other platform(SLES12, SLES11, RHEL7) could reiveive and handle signal SIGTERM normally.
Does anyone encounter this phenomenon?
+++
# cat /etc/os-release
NAME="SLES"
VERSION="15"
VERSION_ID="15"
PRETTY_NAME="SUSE Linux Enterprise Server 15"
ID="sles"
ID_LIKE="suse"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:15"
#uname -a
Linux linux-iv0h 4.12.14-23-default #1 SMP Tue May 29 21:04:44 UTC 2018 (cd0437b) x86_64 x86_64 x86_64 GNU/Linux
#ps aux|grep httpd
root 11143 0.0 0.6 23612 6380 ? Ss 04:33 0:00 ./httpd
nobody 11144 0.0 0.3 23612 3248 ? S 04:33 0:00 ./httpd
nobody 11145 0.0 0.3 23612 3248 ? S 04:33 0:00 ./httpd
nobody 11146 0.0 0.3 23612 3248 ? S 04:33 0:00 ./httpd
nobody 11147 0.0 0.3 23612 3248 ? S 04:33 0:00 ./httpd
nobody 11148 0.0 0.3 23612 3248 ? S 04:33 0:00 ./httpd
+++
On macOS Sierra, I installed Apache using Homebrew:
$ brew install httpd24
This has caused some weird Apache issues. It seems that the default installation of Apache on macOS Sierra was still active in some way. I now want to completely uninstall httpd24 but am still seeing it in my processes. Here's what I did:
$ brew unlink httpd24
$ brew uninstall httpd24
$ rm -rf /usr/local/etc/apache2/
Running $ ps aux|grep httpd reveals:
blt 51473 0.0 0.0 2613988 844 ?? S 10:48PM 0:00.00 /usr/local/Cellar/httpd24/2.4.23_2/bin/httpd -k start
blt 51447 0.0 0.0 2613988 892 ?? S 10:47PM 0:00.00 /usr/local/Cellar/httpd24/2.4.23_2/bin/httpd -k start
blt 51396 0.0 0.0 2613988 856 ?? S 10:47PM 0:00.00 /usr/local/Cellar/httpd24/2.4.23_2/bin/httpd -k start
blt 51345 0.0 0.0 2613988 844 ?? S 10:47PM 0:00.00 /usr/local/Cellar/httpd24/2.4.23_2/bin/httpd -k start
blt 51285 0.0 0.0 2613988 876 ?? S 10:45PM 0:00.00 /usr/local/Cellar/httpd24/2.4.23_2/bin/httpd -k start
blt 51048 0.0 0.0 2615200 868 ?? S 10:34PM 0:00.00 /usr/sbin/httpd -T
blt 51047 0.0 0.0 2615200 840 ?? S 10:34PM 0:00.00 /usr/sbin/httpd -T
blt 51046 0.0 0.1 2628716 20104 ?? S 10:34PM 0:00.06 /usr/sbin/httpd -T
blt 51045 0.0 0.1 2628716 20084 ?? S 10:34PM 0:00.05 /usr/sbin/httpd -T
blt 51044 0.0 0.1 2628716 20148 ?? S 10:34PM 0:00.04 /usr/sbin/httpd -T
blt 51043 0.0 0.1 2628716 20236 ?? S 10:34PM 0:00.05 /usr/sbin/httpd -T
blt 51041 0.0 0.1 2628716 20668 ?? S 10:34PM 0:00.07 /usr/sbin/httpd -T
blt 51040 0.0 0.4 2644668 59852 ?? S 10:34PM 0:01.05 /usr/sbin/httpd -T
root 47136 0.0 0.1 2615456 18872 ?? Ss 5:34PM 0:00.67 /usr/sbin/httpd -T
root 43442 0.0 0.0 2614244 7172 ?? Ss 4:14PM 0:00.83 /usr/local/Cellar/httpd24/2.4.23_2/bin/httpd -k start
blt 52451 0.0 0.0 2423384 256 s003 R+ 11:06PM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn httpd
The processes with the path /usr/sbin/httpd are the default Apache installation. The ones with the path /usr/local/Cellar/httpd24/2.4.23_2/bin/httpd is the Homebrew installation. This shouldn't even be possible. The directory /usr/local/Cellar/httpd24 doesn't even exist. I have tried manually killing those processes but they eventually come back. I have tried restarting my computer. I have restarted Apache countless times. I have confirmed that the Apache I am interacting with on the command line using $ apachectl is the default installation. I don't know what else to do. Thank you for any help.
I can't remember what exactly I did to resolve this, but I've pieced together a bash alias that might be useful to other people who are using Homebrew PHP but the default Mac OS Apache. It will stop Apache, kill any Homebrew Apache (httpd24) processes, unlink and uninstall Homebrew Apache and restart the remaining default Apache installation. Occasionally I have to use this after installing a new PHP version using Homebrew. See this issue for more information: https://github.com/Homebrew/homebrew-php/issues/3601
alias fix_apache='sudo apachectl stop; sudo pkill -f /usr/local/Cellar/httpd24; sudo pkill -f /usr/sbin/httpd; sudo pkill -f /usr/local/opt/httpd24; brew unlink httpd24; brew uninstall --ignore-dependencies --force httpd24; sudo apachectl start;'
I had the same problem and have followed #maskedjellybean answer, by upgrading the script for httpd, according to #pilot comment (i am using currently version 2.4.48).
Code follows:
alias fix_apache='sudo apachectl stop; sudo pkill -f /usr/local/Cellar/httpd; sudo pkill -f /usr/sbin/httpd; sudo pkill -f /usr/local/opt/httpd; brew unlink httpd; brew uninstall --ignore-dependencies --force httpd; sudo apachectl start;'
It all worked perfectly.
I am running a web server using nginx but i can see apach2 lines when i type
ps aux | grep apache
The result it looks like this :
www-data 3280 0.0 1.1 99708 45204 ? S 14:11 0:09 /usr/sbin/apache2 -k start
www-data 8651 0.0 0.9 99708 36120 ? S 18:32 0:00 /usr/sbin/apache2 -k start
root 9428 0.0 0.0 3408 764 pts/0 R+ 19:04 0:00 grep --color=auto apache
www-data 23048 0.0 0.0 3728 2172 ? S 04:00 0:00 /usr/bin/ruby /usr/lib/collectd/plugins/apache_ps -h 01-6PMO317H3OSIK
www-data 26491 0.0 1.1 101252 46308 ? S 06:30 0:22 /usr/sbin/apache2 -k start
www-data 26492 0.0 1.2 105120 50316 ? S 06:30 0:23 /usr/sbin/apache2 -k start
www-data 26493 0.0 1.1 99708 46660 ? S 06:30 0:24 /usr/sbin/apache2 -k start
www-data 26494 0.0 1.1 103436 47148 ? S 06:30 0:23 /usr/sbin/apache2 -k start
www-data 26495 0.0 1.2 103304 48524 ? S 06:30 0:22 /usr/sbin/apache2 -k start
www-data 26685 0.0 1.1 99708 45236 ? S 06:38 0:23 /usr/sbin/apache2 -k start
www-data 28435 0.0 1.1 99708 43916 ? S 08:06 0:19 /usr/sbin/apache2 -k start
www-data 30950 0.0 1.1 99716 44672 ? S 10:12 0:16 /usr/sbin/apache2 -k start
root 31480 0.0 0.6 97400 26544 ? Ss 2013 1:22 /usr/sbin/apache2 -k start
What is this about ?
Every line with /usr/sbin/apache2 -k start represents the command that started an apache process with the argument -k start to run a new instant of apache
Apache2 comes by default with many distributions, you can remove it if you only want ngix