Ubuntu – Apache2 service is masked


I installed Apache 2 on ubuntu 19.04 desktop and was able to do a test access via localhost. I then discovered that the service was masked. I know how to unmask it, but I do not want to do so until I understand why it was masked and have corrected any error situation. How should I troubleshoot this situation? I am brand new to apache2. The output from systemctl is attached:

gossage@jgossage-XPS-8700:~$ sudo systemctl status apache2
‚óŹ apache2.service
   Loaded: masked (Reason: Unit apache2.service is masked.)
   Active: inactive (dead)

Best Answer

It appears that you had an empty service file or you have a duplicate service file in /etc/systemd/system/. This will usually get masked.

Check if the file /etc/systemd/system/apache2.service exists. If so, remove it and proceed below.

Apache2 service file should exist in /lib/systemd/system/. Please check if the file /lib/systemd/system/apache2.service exists. If yes, check the content against this:

Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target

ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl stop
ExecReload=/usr/sbin/apachectl graceful


If not, create the file and copy and paste the above content to it. Then try to enable the service by running:

sudo systemctl enable apache2

If successful, reboot your system