termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.22k stars 3.04k forks source link

Apache2 service won't stop #3268

Open ghost opened 5 years ago

ghost commented 5 years ago

I can start the server fine. The qualified domain name error is pretty common error when you first test apache. I'm having trouble stopping the service though.

using

apachectl stop
apachectl -k stop
apachectl graceful-stop
apachectl -k graceful-stop

does not kill the server.

~ $ apachectl stop
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
(20014)Internal error (specific information not available): AH00058: Error retrieving pid file var/run/apache2/httpd.pid
AH00059: Remove it before continuing if it is corrupted.

also killall and removing the pid file doesn't kill the server.

killall -9 httpd 
rm ${PREFIX}/var/run/apache2/httpd.pid

cleared cache in browser to double check after running kill commands and nothing happens. the process still runs in the background.

ps aux | grep httpd

also comes back up empty handed.

mlocate also comes up empty handed

whereis apache

this is not okay, especially if in a public network.

also there is no var/www/html as far as i can tell

find ${PREFIX} -type d -name 'www'

returns nothing.

server root is set to $PREFIX which leads to a dead end.

after poking around ${PREFIX}/etc/apache2/httpd.conf, i find document root is set to ${PREFIX}/share/apache2/default-site/htdocs which breaks convention, but considering termux doesn't have the standard heiarchy, this makes sense in a weird way. I would still have left it as ${PREFIX}/var/www, but its not a big deal.

After looking at the error log

[Thu Jan 24 14:30:39.045826 2019] [mpm_worker:notice] [pid 1245540143613296114:tid 2950133044] AH00292: Apache/2.4.37 (Unix) configured -- resuming normal operations
[Thu Jan 24 14:30:39.050164 2019] [core:notice] [pid -4688630529333919578:tid 2950133044] AH00094: Command line: '/data/data/com.termux/files/usr/bin/httpd'
[Thu Jan 24 14:42:23.027754 2019] [mpm_worker:notice] [pid 1245540143613296114:tid 2854847796] AH00292: Apache/2.4.37 (Unix) configured -- resuming normal operations
[Thu Jan 24 14:42:23.033791 2019] [core:notice] [pid -4698130309797904218:tid 2854847796] AH00094: Command line: '/data/data/com.termux/files/usr/bin/httpd'

I found no real helpful clues.

because apachectl is a wrapper for httpd, i looked at the shell script to see if there was anything special about it aside from config options which led to lynx (haven't looked at it yet though).

i decided to run the stop commands using httpd -k directly, but that didnt do anything either.

  1. Android warning/error log: logcat -d "*:W".
    ~ $ logcat -d "*:W"
    --------- beginning of main
    01-24 15:11:38.267  3743  3743 W IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
    01-24 15:11:38.268  3743  3743 W IInputConnectionWrapper: finishComposingText on inactive InputConnection
    01-24 15:14:51.821  3743  3743 W IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
    01-24 15:14:51.822  3743  3743 W IInputConnectionWrapper: finishComposingText on inactive InputConnection
    01-24 15:25:04.064  3743  3743 E ViewDragHelper: Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because  ViewDragHelper did not receive all the events in the event stream.
    01-24 15:25:04.065  3743  3743 E ViewDragHelper: Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because  ViewDragHelper did not receive all the events in the event stream.
    01-24 15:25:04.065  3743  3743 E ViewDragHelper: Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because  ViewDragHelper did not receive all the events in the event stream.
    01-24 15:25:04.065  3743  3743 E ViewDragHelper: Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because  ViewDragHelper did not receive all the events in the event stream.
    01-24 15:25:24.120  3743  3743 W IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
    01-24 15:25:24.121  3743  3743 W IInputConnectionWrapper: finishComposingText on inactive InputConnection
  2. Output of strace: strace -fv -s 2048 -o strace.log {program name}.
    ~ $ strace -fv -s 2048 -o strace.log httpd
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
    (20014)Internal error (specific information not available): AH00058: Error retrieving pid file var/run/apache2/httpd.pid
    AH00059: Remove it before continuing if it is corrupted.
  3. If program write it's own log files, you may need to attach them.
    [Thu Jan 24 14:30:39.045826 2019] [mpm_worker:notice] [pid 1245540143613296114:tid 2950133044] AH00292: Apache/2.4.37 (Unix) configured -- resuming normal operations
    [Thu Jan 24 14:30:39.050164 2019] [core:notice] [pid -4688630529333919578:tid 2950133044] AH00094: Command line: '/data/data/com.termux/files/usr/bin/httpd'
    [Thu Jan 24 14:42:23.027754 2019] [mpm_worker:notice] [pid 1245540143613296114:tid 2854847796] AH00292: Apache/2.4.37 (Unix) configured -- resuming normal operations
    [Thu Jan 24 14:42:23.033791 2019] [core:notice] [pid -4698130309797904218:tid 2854847796] AH00094: Command line: '/data/data/com.termux/files/usr/bin/httpd'

UPDATE: After some trial and error, ps aux returned the httpd PIDs and I was able to use kill -SIGINT {PID} to end the process.

Its still weird that ps aux didn't pick up on this until last minute though. Maybe something to do with the terminal session.

I created new terminal sessions to open files with less to check them out and on the last tty i decided to give a try again and this time it showed up.

After clearing the browser cache, I was able to verify that the httpd service had ended. I stil have no idea why the processes wouldn't show up after starting apache though.

gakowalski commented 5 years ago

Same problem here with stopping Apache. I'm killing the service with pkill -f httpd.

Sharaf5 commented 4 years ago

Same issue but it didn't stop and even deleting termux and clearing data leaves apache running

Grimler91 commented 4 years ago

I've added a termux-services script for httpd so it is now possible to start and stop httpd with sv up httpd and sv down httpd (after running pkg upgrade; apt install termux-services)

Sharaf5 commented 4 years ago

@Grimler91 it didn't help me itself but thanks… it have given me the idea to solve it

the problem was that the apachectl couldn't rebind to the specified port this is a problem running apache with no superuser previlages i fixed that with this

netstat -tulpn
# get PID

kill -TERM {PID}

apachectl -k start

Thanks alot

tomty89 commented 4 years ago

Can you do strace httpd -X &> process.log in one session and then strace httpd -k stop &> killing.log in another? Assuming it won't be killed, just Ctrl-C in the former. Report back with the files attached.

You may also want to check (and compare it with the pid in pgrep -a httpd) $PREFIX/var/run/apache2/httpd.pid after starting it (but before killing it).

Malo973 commented 4 years ago

Hello, thanks you for your research and your help in finding a solution. after long research and testing I will share with you my solution on termux (debian):

1) echo "ServerName localhost" >> /data/data/com.termux/files/usr/etc/apache2/httpd.conf

pour l'erreur : * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

commande apache normalement (erreur!):

apachectl start    -------(for the firt time)
apachectl stop    -------(erreur)
apachectl restart ------- (erreur)
apachectl -t -D DUMP_INCLUDES

Usuellement (work) : Arrêt apache avec killall (pkg install psmisc) : killall -9 httpd redémarrage complet apache: killall -9 httpd ; rm ${PREFIX}/var/run/apache2/httpd.pid ; apachectl -k start

marche aussi si android redémarre sans avoir stoppé apache. killall -9 httpd ; rm ${PREFIX}/var/run/apache2/httpd.pid ; apachectl -k start

autre solution : netstat by @Grimler91 @AbdelazizSharaf001 redémarrage apache: netstat -tulpn -- to get PID

kill -TERM {PID} ---To kill PID associé a httpd et a son port 8080 apachectl -k start

$ netstat -tulpn
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:24800           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:18016           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:25000           0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:5037          0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:5555            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8470            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:18011           0.0.0.0:*               LISTEN      -
tcp6       0      0 :::8080                 :::*                    LISTEN      10042/httpd
tcp6       0      0 :::9527                 :::*                    LISTEN      -
tcp6       0      0 :::18014                :::*                    LISTEN      -
udp        0      0 0.0.0.0:22469           0.0.0.0:*                           -
udp6     576      0 :::18012                :::*                                -
udp6       0      0 :::9528                 :::*                                -

everything worked for me!

https://parzibyte.me/blog/en/2019/04/28/install-apache-php-7-android-termux/

sorry for my french-english thanks for your contribution cordially

theaungmyatmoe commented 3 years ago

Kill MariaDB

killall -9 mysqld_safe || killall -9 mysql

Kill Apache HTTPD

killall -9 httpd
ghost commented 3 years ago

killall -9 mysqld_safe || kill all -9 mysql

Nothing related to this issue and also command part kill all -9 mysql has typo.

theaungmyatmoe commented 3 years ago

killall -9 mysqld_safe || kill all -9 mysql

Nothing related to this issue and also command part kill all -9 mysql has typo.

Sorry ,Fixed.

stale[bot] commented 2 years ago

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

twaik commented 1 week ago

Is it still reproducible?