1

Does anyone know what would be causing the following error. I have run update and upgrade prior

pi@raspberrypi:~ $ sudo apt install apache2 -y
sudo: unable to resolve host raspberrypi: Name or service not known
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  apache2-data ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-data ssl-cert
0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 437 kB of archives.
After this operation, 1,591 kB of additional disk space will be used.
Get:1 http://raspbian.melbourneitmirror.net/raspbian buster/main armhf apache2-data all 2.4.38-3+deb10u3 [165 kB]
Get:2 http://raspbian.melbourneitmirror.net/raspbian buster/main armhf apache2 armhf 2.4.38-3+deb10u3 [251 kB]
Get:3 http://raspbian.melbourneitmirror.net/raspbian buster/main armhf ssl-cert all 1.0.39 [20.8 kB]
Fetched 437 kB in 2s (185 kB/s)
Preconfiguring packages ...
Selecting previously unselected package apache2-data.
(Reading database ... 100044 files and directories currently installed.)
Preparing to unpack .../apache2-data_2.4.38-3+deb10u3_all.deb ...
Unpacking apache2-data (2.4.38-3+deb10u3) ...
Selecting previously unselected package apache2.
Preparing to unpack .../apache2_2.4.38-3+deb10u3_armhf.deb ...
Unpacking apache2 (2.4.38-3+deb10u3) ...
Selecting previously unselected package ssl-cert.
Preparing to unpack .../ssl-cert_1.0.39_all.deb ...
Unpacking ssl-cert (1.0.39) ...
Setting up ssl-cert (1.0.39) ...
Setting up apache2-data (2.4.38-3+deb10u3) ...
Setting up apache2 (2.4.38-3+deb10u3) ...
Enabling module mpm_event.
Enabling module authz_core.
Enabling module authz_host.
Enabling module authn_core.
Enabling module auth_basic.
Enabling module access_compat.
Enabling module authn_file.
Enabling module authz_user.
Enabling module alias.
Enabling module dir.
Enabling module autoindex.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module filter.
Enabling module deflate.
Enabling module status.
Enabling module reqtimeout.
Enabling conf charset.
Enabling conf localized-error-pages.
Enabling conf other-vhosts-access-log.
Enabling conf security.
Enabling conf serve-cgi-bin.
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 Wed 2020-05-13 20:32:14 AEST; 28ms ago
     Docs: https://httpd.apache.org/docs/2.4/
  Process: 24065 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

May 13 20:32:14 raspberrypi apachectl[24065]: AH00558: apache2: 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
May 13 20:32:14 raspberrypi apachectl[24065]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
May 13 20:32:14 raspberrypi apachectl[24065]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
May 13 20:32:14 raspberrypi apachectl[24065]: no listening sockets available, shutting down
May 13 20:32:14 raspberrypi apachectl[24065]: AH00015: Unable to open logs
May 13 20:32:14 raspberrypi apachectl[24065]: Action 'start' failed.
May 13 20:32:14 raspberrypi apachectl[24065]: The Apache error log may have more information.
May 13 20:32:14 raspberrypi systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
May 13 20:32:14 raspberrypi systemd[1]: apache2.service: Failed with result 'exit-code'.
May 13 20:32:14 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) ...
3
  • I'm probably missing something, but I can't see any reference to PHP in the log, etc. You're installing apache and that will not start... – Dirk May 13 '20 at 12:53
  • 1
    Not a PHP issue here, you are only installing Apache and there is already a webserver or some process listening to port 80. So Apache cannot start. Run netstat -antup to find out what's listening to that port. You can update your question with the output of that command. – Anonymous May 13 '20 at 14:17
  • may I know what command did you used for installing apache and mod? – Sohan Arafat May 18 '20 at 21:27
1

The very first warning:

sudo: unable to resolve host raspberrypi: Name or service not known

is typically shown with a missing entry in /etc/hosts for localhost names on Raspbian. The error messages from apache2 also indicate problems with local addresses. You should check your /etc/hosts file. Its default entry on Raspbian is:

127.0.0.1   localhost
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

127.0.1.1   raspberrypi

For example the last line is used by sudo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.