Apache2 is not starting after apt upgrade - apache2

I updated Apache2 on my Rapsberry Pi (using: apt install apache2 --only-upgrade) and now it is not starting:
root#pi:/etc/apache2 # service apache2 start
Job for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.
root#pi:/etc/apache2 # systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled)
Active: failed (Result: resources) since Sun 2017-02-05 16:19:48 CET; 28min ago
Feb 05 16:47:44 pi systemd[1]: Starting The Apache HTTP Server...
Feb 05 16:47:44 pi systemd[1]: apache2.service failed to run 'start' task: No such file or directory
Feb 05 16:47:44 pi systemd[1]: Failed to start The Apache HTTP Server.
Version of apache2:
Server version: Apache/2.4.25 (Raspbian)
Server built: 2017-01-25T22:59:26
apache2ctl -t shows:
Syntax OK
I tried disabling all virtual hosts (only default left) but it didn't change anything.
Output of just apache2:
[Mon Feb 06 01:25:09.079790 2017] [core:warn] [pid 2954] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

I had the same issue after upgrading a Dockerfile from 14.04 to 17.04.
The solution for me was to manually add the apache directory in /var/run
So the fix was:
mkdir /var/run/apache2
The DefaultRuntimeDir was set to /var/run/apache2 but the folder was missing.

Related

Cannot start Apache2 server on RaspberryPi 4

I installed Apache2 on Raspberry Pi4 B but it is not starting. If anyone had the same issue, please let me know the solution.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2021-06-07 21:07:32 EEST; 22ms ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 30140 ExecStart=/usr/sbin/apachectl start (code=exited, status=127)
Jun 07 21:07:32 raspberrypi systemd[1]: Starting The Apache HTTP Server...
Jun 07 21:07:32 raspberrypi apachectl[30140]: /usr/sbin/apachectl: 174: /usr/sbin/apachectl: /usr/sbin/apache2: not found
Jun 07 21:07:32 raspberrypi apachectl[30140]: Action 'start' failed.
Jun 07 21:07:32 raspberrypi apachectl[30140]: The Apache error log may have more information.
Jun 07 21:07:32 raspberrypi systemd[1]: apache2.service: Control process exited, code=exited, status=127/n/a
Jun 07 21:07:32 raspberrypi systemd[1]: apache2.service: Failed with result 'exit-code'.
Jun 07 21:07:32 raspberrypi systemd[1]: Failed to start The Apache HTTP Server.
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for systemd (241-7~deb10u4+rpi1) ...
Problem solved with:
sudo apt install --reinstall apache2-bin
sudo service apache2 start

mongod.service active : failed (failed to start mongodb server)

I just started learning mongodb everything was going well until I tried stoping the server using sudo systemctl stop mongod and restarting it usingsudo systemctl start mongod.
now its showing:-
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2021-01-16 12:39:04 IST; 3s ago
Docs: https://docs.mongodb.org/manual
Process: 357998 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 357998 (code=exited, status=1/FAILURE)
Jan 16 12:39:04 prabal-computer systemd[1]: Started MongoDB Database Server.
Jan 16 12:39:04 prabal-computer mongod[357998]: {"t":{"$date":"2021-01-16T07:09:04.669Z"},"s":"F", "c":"CONTROL", "id":20574, "ctx":"main">
Jan 16 12:39:04 prabal-computer systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAILURE
Jan 16 12:39:04 prabal-computer systemd[1]: mongod.service: Failed with result 'exit-code'.
lines 1-11/11 (END)
whenever I am trying to start and see the status using sudo systemctl status mongod,this error appears.
note: I have already tried reinstalling the mongodb

Zabbix agent can't connect to Zabbix5.0 server

I installed zabbix agent on Ubuntu 18.04 server. I changed the IP address and hostname pointing to the Zabbix server in zabbix_agentd.config file in /etc. And Restart Zabbix agent. Seems like the server is running, but the agent is not conneting to the server. How can I fix it?
/etc/zabbix# sudo systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-07-29 15:26:30 NZST; 5s ago
Process: 16401 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 16403 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 16406 (zabbix_agentd)
Tasks: 6 (limit: 2325)
CGroup: /system.slice/zabbix-agent.service
├─16406 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─16407 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─16408 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─16409 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─16410 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
└─16411 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
Jul 29 15:26:29 UbuntuServe-001 systemd[1]: Starting Zabbix Agent...
Jul 29 15:26:30 UbuntuServe-001 systemd[1]: zabbix-agent.service: Can't open PID file /run/zabbix/zabbix_agentd.pid (yet?) after start: No such file or directory
Jul 29 15:26:30 UbuntuServe-001 systemd[1]: Started Zabbix Agent.
Can't open PID file /run/zabbix/zabbix_agentd.pid (yet?) after start: No such file or directory
The /run/zabbix directory does not exists. Remove the PIDFILE= line from config file, and zabbxi will create the pid file in temporary directory. Alternatively, create /run/zabbix directory and chown it to zabbix user.

Apache2 server not wotking

For some reason my apache2 has stopped working.
I have tried uninstalling it, the problem still remains the same.
Here's some commands and their results that I have tried which might help you:-
"sudo systemctl status apache2":-
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset:
Active: failed (Result: exit-code) since Sun 2020-06-21 12:56:28 IST; 7min ag
Docs: https://httpd.apache.org/docs/2.4/
Jun 21 12:56:21 kabir systemd[1]: Starting The Apache HTTP Server...
Jun 21 12:56:28 kabir apachectl[1086]: AH00558: apache2: Could not reliably dete
Jun 21 12:56:28 kabir apachectl[1086]: (98)Address already in use: AH00072: make
Jun 21 12:56:28 kabir apachectl[1086]: no listening sockets available, shutting
Jun 21 12:56:28 kabir apachectl[1086]: AH00015: Unable to open logs
Jun 21 12:56:28 kabir apachectl[1086]: Action 'start' failed.
Jun 21 12:56:28 kabir apachectl[1086]: The Apache error log may have more inform
Jun 21 12:56:28 kabir systemd[1]: apache2.service: Control process exited, code=
Jun 21 12:56:28 kabir systemd[1]: apache2.service: Failed with result 'exit-code
Jun 21 12:56:28 kabir systemd[1]: Failed to start The Apache HTTP Server.
"sudo systemctl restart apache2":-
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
netstat -an | grep ":80"
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 192.168.43.128:33944 117.18.237.29:80 TIME_WAIT
tcp 0 0 192.168.43.128:33864 117.18.237.29:80 ESTABLISHED
tcp 0 0 192.168.43.128:34524 23.217.53.84:80 ESTABLISHED
tcp 0 0 192.168.43.128:54364 172.217.166.163:80 ESTABLISHED
tcp 0 0 192.168.43.128:54206 172.217.166.163:80 TIME_WAIT
tcp 0 0 192.168.43.128:33946 117.18.237.29:80 ESTABLISHED
tcp 0 0 192.168.43.128:34522 23.217.53.84:80 ESTABLISHED
tcp6 0 0 :::80 :::* LISTEN
"sudo apachectl start":-
Invoking 'systemctl start apache2'.
Use 'systemctl status apache2' for more info.
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
Action 'start' failed.
The Apache error log may have more information.
Check your configuration as the error would indicate that you already have a listen directive to the same port.
sudo vim /etc/apache2/ports.conf [On Debian/Ubuntu]
sudo vim /etc/httpd/conf/httpd.conf [On RHEL/CentOS]
Check that you don't have a listen on the port you need.

Error accessing cgi script inside Docker container, Operation not permitted: Couldn't bind unix domain socket

I'm using Apache::Test to test an Apache handler that I'm writing. My build environment is a Docker container, created from this Dockerfile:
FROM google/debian:wheezy
RUN apt-get -y install make gcc build-essential
RUN apt-get -y install sudo
RUN apt-get -y install apache2-threaded-dev
RUN apt-get -y install libapache2-mod-perl2 libgd-gd2-perl libgd-tools
RUN apt-get -y install libtest-harness-perl
RUN apt-get -y install libtap-formatter-junit-perl libjson-perl
I build the container and run it via:
docker run -i -t --rm -v $PWD:/opt/51d device-detection:latest /opt/51d/entry.sh
Apache::Test doesn't allow the httpd server to start as root and my container is running as root, so the entry.sh script creates a user for the test to use by doing:
#!/bin/bash
adduser --disabled-password --gecos '' r
adduser r sudo
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
su -m r -c /opt/51d/build
And build looks like:
perl Makefile.PL && make && make test && sudo make install
Apache::Test provides a test harness called t/TEST. I can start the Apache server just fine with:
t/TEST -start-httpd
And I can access the index.html page just fine with:
wget http://localhost:8529/index.html
However, when I attempt to access a CGI script, I get:
[Thu Apr 02 23:12:11 2015] [error] (1)Operation not permitted: Couldn't bind unix domain socket /opt/51d/CDK-51DegreesFilter/t/logs/cgisock.267
[Thu Apr 02 23:12:11 2015] [notice] Apache/2.2.22 (Debian) mod_perl/2.0.7 Perl/v5.14.2 configured -- resuming normal operations
[Thu Apr 02 23:12:11 2015] [info] Server built: Dec 23 2014 22:48:32
[Thu Apr 02 23:12:11 2015] [debug] worker.c(1757): AcceptMutex: sysvsem (default: sysvsem)
[Thu Apr 02 23:12:11 2015] [crit] cgid daemon failed to initialize
[Thu Apr 02 23:12:30 2015] [error] [client 127.0.0.1] (2)No such file or directory: unable to connect to cgi daemon after multiple tries: /opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi
The /opt/51d/CDK-51DegreesFilter/t/logs/ directory is wide open:
ls -ld t/logs/
drwxrwxrwx 1 r staff 136 Apr 2 23:24 t/logs/
=====
Made some progress by moving the location of the ScriptSock directory
<IfModule mod_cgid.c>
ScriptSock /tmp/cgisock
</IfModule>
New error message is:
[Sat Apr 04 04:04:23 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Sat Apr 04 04:04:23 2015] [notice] Apache/2.2.22 (Debian) mod_perl/2.0.7 Perl/v5.14.2 configured -- resuming normal operations
[Sat Apr 04 04:04:23 2015] [info] Server built: Dec 23 2014 22:48:32
[Sat Apr 04 04:04:23 2015] [debug] worker.c(1757): AcceptMutex: sysvsem (default: sysvsem)
[Sat Apr 04 04:04:49 2015] [error] (2)No such file or directory: exec of '/opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi' failed
[Sat Apr 04 04:04:49 2015] [error] [client 127.0.0.1] Premature end of script headers: index.cgi
[Sat Apr 04 04:06:14 2015] [error] (2)No such file or directory: exec of '/opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi' failed
[Sat Apr 04 04:06:14 2015] [error] [client 127.0.0.1] Premature end of script headers: index.cgi
=====
Fixed the exec error as the location of the perl binary is different. Updated that and all is well.
t/TEST
[warning] setting ulimit to allow core files ulimit -c unlimited; /usr/bin/perl /opt/51d/CDK-51DegreesFilter/t/TEST
/usr/sbin/apache2 -d /opt/51d/CDK-51DegreesFilter/t -f /opt/51d/CDK-51DegreesFilter/t/conf/httpd.conf -D APACHE2 -D PERL_USEITHREADS
using Apache/2.2.22 (worker MPM)
waiting 60 seconds for server to start: ..
waiting 60 seconds for server to start: ok (waited 1 secs)
server localhost:8529 started
t/CDK-51DegreesFilter.t .. ok
All tests successful.
Files=1, Tests=6, 0 wallclock secs ( 0.02 usr 0.02 sys + 0.34 cusr 0.08 csys = 0.46 CPU)
Result: PASS
[warning] server localhost:8529 shutdown
[warning] port 8529 still in use...
done
I had similar issue today.. Using valid scriptsock resolved my issue..
<IfModule cgid_module>
#
# ScriptSock: On threaded servers, designate the path to the UNIX
# socket used to communicate with the CGI daemon of mod_cgid.
#
Scriptsock /usr/local/apache2/cgisock
</IfModule>

Resources