1

I recently migrated from using Windows 10 to Linux Ubuntu 19.04. I finished installing LAMP through tutorials for 18.04 ubuntu and it worked fine once until I messed it up. Now I can't start apache2 and it gives me this error when I type 'sudo service apache2 start' command on the terminal.

I tried using other methods from the web including purging and reinstalling the related programs but I can't seem to fix this once and for all.

Here's the error message. Hope it helps.

    apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2019-08-24 23:37:56 PST; 9s ago
     Docs: https://httpd.apache.org/docs/2.4/
  Process: 14755 ExecStart=/usr/sbin/apachectl start (code=exited, status=127)

Aug 24 23:37:56 user-E5-575G systemd[1]: Starting The Apache HTTP Server...
Aug 24 23:37:56 user-E5-575G apachectl[14755]: /usr/sbin/apachectl: 174: /usr/sbin/apachectl: /usr/sbin/apache2: not found
Aug 24 23:37:56 user-E5-575G apachectl[14755]: Action 'start' failed.
Aug 24 23:37:56 user-E5-575G apachectl[14755]: The Apache error log may have more information.
Aug 24 23:37:56 user-E5-575G systemd[1]: apache2.service: Control process exited, code=exited, status=127/n/a
Aug 24 23:37:56 user-E5-575G systemd[1]: apache2.service: Failed with result 'exit-code'.
Aug 24 23:37:56 user-E5-575G systemd[1]: Failed to start The Apache HTTP Server.
  • Check logs under the directory /var/log/apache2/ for more info. – Michal Przybylowicz Aug 24 '19 at 16:09
1

You should be careful just purging things, it can really mess up dependencies, especially if you force it.

I can only guess that you probably purged the main package, then some of the dependencies remained, then when you reinstalled it all of the required dependencies weren't reinstalled.

The package that you're specifically missing is apache2-bin, which is a dependency on apache2 that was probably not removed or reinstalled correctly.

So first try just installing that with:

sudo apt-get --reinstall install apache2-bin

If that doesn't work then do:

sudo apt-get purge apache2
sudo apt-get autoremove
sudo apt-get install apache2

If that still doesn't work you can try to do:

sudo apt-get --reinstall install apache2

Always remember to do autoremove after an uninstall or purge to make sure that the orphaned packages are also removed before trying to reinstall it.

Hope that helps.

| improve this answer | |
2

Based on your error message, systemd can't find your apache binary. Maybe it didn't get installed correctly. You should uninstall and reinstall.

sudo apt purge apache2 && sudo apt install apache2

If that doesn't work, is it possible that you installed apache from source in addition from apt? If you did, the default install location would be /usr/bin/ you'll need to update the systemd scripts to go there.

| improve this answer | |

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.