Cannot start Apache2 server on RaspberryPi 4 - apache2

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

Related

Can't start Apache : Error : Could not initialize random number generator

My apache server doesn't start, here are my logs
nov. 01 20:34:46 ns3013535.ip-149-202-76.eu systemd[1]: Starting The Apache HTTP Server...
nov. 01 20:34:46 ns3013535.ip-149-202-76.eu apachectl[1333176]: [Tue Nov 01 20:34:46.704027 2022] [:crit] [pid 1333176] (38)Function not implemented: AH00141: Could not initialize random number generator
nov. 01 20:34:46 ns3013535.ip-149-202-76.eu apachectl[1333173]: Action 'start' failed.
nov. 01 20:34:46 ns3013535.ip-149-202-76.eu apachectl[1333173]: The Apache error log may have more information.
nov. 01 20:34:46 ns3013535.ip-149-202-76.eu systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
nov. 01 20:34:46 ns3013535.ip-149-202-76.eu systemd[1]: apache2.service: Failed with result 'exit-code'.
nov. 01 20:34:46 ns3013535.ip-149-202-76.eu systemd[1]: Failed to start The Apache HTTP Server.
i'm on ubuntu 22.04LTS
kernel version 3.14.32-xxxx-grs-ipv6-64
apache2 version: 2.4.52
libapr1 version: 1.7.0-8
i updated all my package but nothing change
i already followed this thread too : How to fix '(38)Function not implemented: AH00141: Could not initialize random number generator' after upgrading Apache from 2.4.18 to 2.4.46?

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

"systemctl status apache2.service" error in starting apache2

root#kudo2:~# 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.
root#kudo2:~# systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2017-10-03 14:22:01 UTC; 3min 33s ago
Process: 17190 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
Oct 03 14:22:01 kudo2 apachectl[17190]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Oct 03 14:22:01 kudo2 apachectl[17190]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Oct 03 14:22:01 kudo2 apachectl[17190]: no listening sockets available, shutting down
Oct 03 14:22:01 kudo2 apachectl[17190]: AH00015: Unable to open logs
Oct 03 14:22:01 kudo2 apachectl[17190]: Action 'start' failed.
Oct 03 14:22:01 kudo2 apachectl[17190]: The Apache error log may have more information.
Oct 03 14:22:01 kudo2 systemd[1]: apache2.service: Control process exited, code=exited status=1
Oct 03 14:22:01 kudo2 systemd[1]: Failed to start The Apache HTTP Server.
Oct 03 14:22:01 kudo2 systemd[1]: apache2.service: Unit entered failed state.
Oct 03 14:22:01 kudo2 systemd[1]: apache2.service: Failed with result 'exit-code'.
root#kudo2:~#
Something else is already using port 80. Try starting apache on a different port or else find out what else is using port 80 and move/kill it.
You could run ss -tlnp|grep -w 80 as a superuser to see which proccess is listening on port 80. This process could be configured to listen on another port. This would free port 80 and allow apache to run.

Nagios Core 4.2.0 Service not running after reboot

I am running Nagios Core 4.2.0 to monitor hosts and services via Check_MK plugin. This is running on a VM. Once I rebooted, I cannot get a PID for Nagios.
root#hostname:/etc/init.d# service nagios status
● nagios.service - Nagios
Loaded: loaded (/etc/systemd/system/nagios.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2017-08-10 09:09:34 CDT; 1min 2s ago
Process: 2369 ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg (code=exited, status=1/FAILURE)
Main PID: 2369 (code=exited, status=1/FAILURE)
Aug 10 09:09:34 hostname systemd[1]: Started Nagios.
Aug 10 09:09:34 hostname systemd[1]: nagios.service: Main process exited, code=exited, status=1/FAILURE
Aug 10 09:09:34 hostname systemd[1]: nagios.service: Unit entered failed state.
Aug 10 09:09:34 hostname systemd[1]: nagios.service: Failed with result 'exit-code'.
Is there a way to get this PID to run? I am not sure how a simple reboot can make this go bad.

Apache2 is not starting after apt upgrade

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.

Resources