0

I am running Debian 8 Jessie and I have Apache 2.4.25-3+deb9u3 running under my login userid. When I login via SSH to the server and then log out, apache terminates. This also happens on Debian 9 Stretch. It didn't work this way when I was running on Debian 7 Wheezy (I think it was apache 2.2). I could log in and out all the time and Apache would still be running.

I looked at logind.conf and KillUserProcesses is set to no.

I would like apache2 to never stop running unless I manually stop it. Any ideas?

Jim Cook
  • 1
  • 1
  • "running under my login userid" how? did you background or `disown` it? – thrig Jan 11 '18 at 16:27
  • I don't understand your question. In /etc/apache2/envars I set APACHE_RUN_USER to my userid, and APACHE_RUN_GROUP to the group my ID is in. – Jim Cook Jan 11 '18 at 17:36
  • what command did you use to start apache? – thrig Jan 11 '18 at 17:41
  • It autostarts at boot. I think the /etc/init.d/apache2 script starts it. – Jim Cook Jan 11 '18 at 21:03
  • hmm, there should be no relation between your SSH session and the init-system started apache, especially if they are different user accounts – thrig Jan 11 '18 at 23:49
  • They are not different user accounts. ps -ef | grep apache shows the processes are using my userid. – Jim Cook Jan 12 '18 at 22:20
  • Found the solution. I needed to edit /etc/apache2/apache2.conf and provide this value: Mutex posixsem – Jim Cook Jan 21 '18 at 20:10

1 Answers1

1

Ideally Apache should run under its own user, like www-data. Is there a reason why you are running it as yourself?

Anyway, if you absolutely need to run it from your own user you should start it with nohup at the end on the command . This way when you logout the system won't send a hup (hang up) signal to that process when you logout.

From the man pages:

nohup(1) - Linux man page

Name

nohup - run a command immune to hangups, with output to a non-tty
Synopsis

nohup COMMAND [ARG]...
nohup OPTION
Description

Run COMMAND, ignoring hangup signals.

--help
display this help and exit
--version
output version information and exit
If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it to standard output. To save output to FILE, use 'nohup COMMAND > FILE'.

NOTE: your shell may have its own version of nohup, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.
Tux
  • 158
  • 7
  • How do you nohup when apache is a service. It is restarted like this: sudo service apache2 restart . I set it up with my own user id so I didn't have any file permissions issues between apache and my user. I guess I could use groups to solve the permissions issue. – Jim Cook Jan 11 '18 at 17:25