How to completely uninstall Homebrew Apache httpd24? - apache

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.

Related

How can I make apache write files as the user it is run as?

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

The directory is not writable by the Web process: /var/www/html/mywebsite/frontend/web/assets

I'm trying to initialize Yii2 apps and after i run the command php init and all files generated by yii i try to view from n=my browser but keep getting error, i have search on google and on stackflow for possible solution with no luck, what i've tried so far, i run the command chmod 0777 web/assets i also do ps -ef | grep apache | grep -v grep and i got the below
apache 4074 4073 0 20:38 ? 00:00:01 /usr/sbin/httpd -DFOREGROUND
apache 4075 4073 0 20:38 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4076 4073 0 20:38 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4077 4073 0 20:38 ? 00:00:01 /usr/sbin/httpd -DFOREGROUND
apache 4078 4073 0 20:38 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4083 4073 0 20:38 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
the i proceed doing sudo chgrp apache ./assets and then sudo chmod g+w ./assets/ it all not working i guess this is a kind of server problem, any help on this will be appreciated thanks
maybe the directory owner has conflict with your php user,
run this command to get your apache user:
ps -ef | grep apache | grep -v grep
then you can see {apache_user}, run below command in your frontend/web directory:
sudo chgrp {apache_user} ./assets
sudo chmod g+w ./assets/
but if it doesn't work, give me about your operation system information

Apache httpd 2.4.34 couldn't receive signal SIGTERM on SuSE 15

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
+++

what does this line mean on my ps aux ../apache2 -k start

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

SSH Remote Command Hangs

Does anyone know why this command,
ssh -v user#address "exec ssh-agent bash"
...would hang on this output?
debug1: Sending command: exec ssh-agent bash
I'm trying to automatically setup a set of remote machines so they can SSH into each other without passwords. Have already scp'd over the relevant private key file. Need to run ssh-add on each instance. But first, I need to start the ssh-agent. But the command above hangs. Starting the agent manually on each instance is not really an option.
Running "ps ux" on the remote machine manually confirms that the ssh-agent is running:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ubuntu 746 0.0 0.2 8844 1380 ? S 02:45 0:00 sshd: ubuntu#notty
ubuntu 747 0.0 0.1 4532 1096 ? Ss 02:45 0:00 bash
ubuntu 748 0.0 0.0 3360 204 ? Ss 02:45 0:00 ssh-agent bash
ubuntu 779 0.0 0.2 8844 1376 ? S 02:51 0:00 sshd: ubuntu#pts/0
ubuntu 781 5.3 0.8 8260 5244 pts/0 Ss 02:51 0:00 -bash
ubuntu 813 0.0 0.1 4284 1076 pts/0 R+ 02:52 0:00 ps ux
Any help is appreciated.
What you see is the expected behavior. SSH is waiting for bash to finish execution. If you omit the "bash" as the argument to ssh-agent, then ssh-agent goes in the background like you expect it to.
So, perhaps you meant to run:
ssh -v user#address "ssh-agent"
looking at pstree output shows more clearly what is happening.
|-+= 09556 root /usr/libexec/launchproxy /usr/sbin/sshd -i
| \-+= 09557 root /usr/sbin/sshd -i
| \-+- 09560 root /usr/sbin/sshd -i
| \-+= 09561 root bash
| \--= 09562 root ssh-agent bash