Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to start The Apache HTTP Server on ubuntu 18.04

I am trying to create a web server on my ubuntu 18.04 so i installed Apache2 but i can't start it. Here's what appeared when i run the systemctl status apache2.service command

apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Sat 2020-02-22 13:58:09 CET; 34s ago
  Process: 2791 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
Feb 22 13:58:09 moemen apachectl[2791]: AH00558: apache2: Could not reliably determine the server's
Feb 22 13:58:09 moemen apachectl[2791]: (98)Address already in use: AH00072: make_sock: could not b
Feb 22 13:58:09 moemen apachectl[2791]: (98)Address already in use: AH00072: make_sock: could not b
Feb 22 13:58:09 moemen apachectl[2791]: no listening sockets available, shutting down
Feb 22 13:58:09 moemen apachectl[2791]: AH00015: Unable to open logs
Feb 22 13:58:09 moemen apachectl[2791]: Action 'start' failed.
Feb 22 13:58:09 moemen apachectl[2791]: The Apache error log may have more information.
Feb 22 13:58:09 moemen systemd[1]: apache2.service: Control process exited, code=exited status=1
Feb 22 13:58:09 moemen systemd[1]: apache2.service: Failed with result 'exit-code'.
Feb 22 13:58:09 moemen systemd[1]: Failed to start The Apache HTTP Server.

I'm new at this can you please help me

like image 535
moe_ Avatar asked Feb 22 '20 13:02

moe_


People also ask

Why my apache2 server is not working?

If your system wasn't able to restart Apache2 you most likely got some form of an error message. In case you got a reply resembling either one of the output examples below, the service is most likely not properly installed on your system or some files are missing. Failed to restart apache2. service: Unit apache.

How do I start Apache HTTP?

You can also start httpd using /sbin/service httpd start. This starts httpd but does not set the environment variables. If you are using the default Listen directive in httpd. conf, which is port 80, you will need to have root privileges to start the apache server.

How do I fix Apache server error?

The simplest way to fix 500 internal server error in Apache is to simply refresh the page. Sometimes you may be requesting a page when the server is being restarted. In such cases, you will get 500 internal error. Sometimes, the server may be overloaded with requests and doesn't have resources to process your request.


3 Answers

I also faced same problem.

First check

$ sudo systemctl status nginx

If nginx is active then stop this with

$ sudo systemctl stop nginx

then again try to start apache2 server in different terminal.

like image 186
Devashish Mishra Avatar answered Nov 18 '22 07:11

Devashish Mishra


first remove apache2

sudo apt-get --purge remove apache2 sudo apt-get autoremove

after that if there files (.conf) /etc/sites-available remove them using

rm example.com.conf

then install again sudo apt-get install apache2

now it will fixed check it now sudo ufw allow 'Apache' sudo systemctl status apache2

like image 44
csanjeewag Avatar answered Nov 18 '22 07:11

csanjeewag


Let me give a more general answer than the first 2. One possible problem with Apache is, when we try to run it, it may fail because port 80 is used by another software:

  • a common case is nginx which is covered by Devashish Mishra
  • in my case it was a server app that I deployed (in node.js, I had to tell pm2 to stop it)
  • in general, you may want to find what uses port 80. This may be done like Chi.C.J.Rajeeva Lochana has suggested: install netstat if you don't have it (sudo apt install net-tools), use it: sudo netstat -antup | grep 80. It will show some lines which may include :::80 or <your IP>:80 which will tell what is listening to the port

Once you've found what listens to the 80 port, you have to decide what to do with it. For instance, if that's nginx and you don't use it, you may go like Devashish Mishra has suggested: just stop it (sudo systemctl stop nginx). Likewise, you can stop or kill (sudo killall -9 program-name) other programs. However, if you need them, you'll also need to further configure Apache and rerun them (the exact steps highly depend on the case).

like image 43
YakovL Avatar answered Nov 18 '22 05:11

YakovL