Plesk

Unable to start Apache in Plesk: Failed to restart httpd.service: Unit not found

Symptoms

Cause

LiteSpeed was not fully deactivated. The file /usr/lib/systemd/system/httpd.service is a symlink to a non-existent LiteSpeed service /usr/lib/systemd/system/lshttpd.service:

# ls -lah /usr/lib/systemd/system/http*
lrwxrwxrwx 1 root root 39 /usr/lib/systemd/system/httpd.service -> /usr/lib/systemd/system/lshttpd.service

Resolution

    1. Log in to Plesk.

    2. Remove the Litespeed extension via Extension Catalog > My Extensions > LiteSpeed > More > Remove.

    3. Connect to the server via SSH.

    4. Find the old Apache and LiteSpeed .service files:

      # ls -lah /usr/lib/systemd/system/http*
      lrwxrwxrwx 1 root root 39 /usr/lib/systemd/system/httpd.service -> /usr/lib/systemd/system/lshttpd.service

      # ls -lah /usr/lib/systemd/system/lshttpd*
      lrwxrwxrwx 1 root root 39 /usr/lib/systemd/system/lshttpd.service

    5. Remove the old httpd.service files and lshttpd.service files:

      # rm -rf /usr/lib/systemd/system/httpd.service*
      # rm -rf /usr/lib/systemd/system/lshttpd.service*

    6. Create a new file /usr/lib/systemd/system/httpd.service and add the following content:

      # vi /usr/lib/systemd/system/httpd.service

      [Unit]
      Description=The Apache HTTP Server
      After=network.target remote-fs.target nss-lookup.target
      Documentation=man:httpd(8)
      Documentation=man:apachectl(8)
      [Service]
      Type=notify
      EnvironmentFile=/etc/sysconfig/httpd
      ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
      ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
      ExecStop=/bin/kill -WINCH ${MAINPID}
      # We want systemd to give httpd some time to finish gracefully, but still want
      # it to kill httpd after TimeoutStopSec if something went wrong during the
      # graceful stop. Normally, Systemd sends SIGTERM signal right after the
      # ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
      # httpd time to finish.
      KillSignal=SIGCONT
      PrivateTmp=true
      [Install]
      WantedBy=multi-user.target

    7. Start Apache service:

      # systemctl start httpd

Exit mobile version