Articles in this section

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

Plesk for Linux kb: technical

Applicable to:

  • Plesk for Linux

Symptoms

    • Plesk runs on RHEL-based OS (CentOS/RHEL/CloudLinux).

    • The following message appear on Plesk homepage or on attempt to start Apache at Tools & Settings > Services Management :

      PLESK_ERROR: Warning: start service httpd failed /usr/local/psa/admin/sbin/pleskrc execution failed: Failed to start httpd.service: Unit not found. Unit httpd.service could not be found.

If you get similar case Litespeed would like to investigate how this happened. Contact Olga Matvienko. Thread on Support-tl: RE: Issue with LiteSpeed making Apache down after extension deactivation

  • Apache does not start via Plesk > Tools & Settings > Services Management or via SSH:

    PLESK_ERROR: Unable to start service: Unable to manage service by apache_control_adapter: ('start', 'web'). Error: INFO: [Wed Apr 14 09:50:54 EEST 2021]: Service: apache, Action: start Trying to start service httpd... attempt to start service httpd - service doesn't exist (missing unit file or not executable control script) ***** problem report ***** Warning: start service httpd failed /usr/local/psa/admin/sbin/pleskrc execution failed: Unit httpd.service could not be found.


    # systemctl start httpd
    Failed to restart httpd.service: Unit not found.

  • Apache syntax has no errors:

    # httpd -t
    Syntax OK

  • Verification of Apache packages shows that the symlink to httpd.service was modified:

    # yum list installed | grep httpd
    httpd.x86_64 2.4.6-93.el7.centos @base
    httpd-tools.x86_64 2.4.6-93.el7.centos @base

    # rpm -V httpd.x86_64
    .......T. c /etc/httpd/conf.modules.d/00-base.conf
    .......T. c /etc/httpd/conf.modules.d/00-dav.conf
    S.5....T. c /etc/httpd/conf.modules.d/00-mpm.conf
    .......T. c /etc/httpd/conf.modules.d/00-proxy.conf
    S.5....T. c /etc/httpd/conf/httpd.conf
    S.5....T. c /etc/logrotate.d/httpd
    ....L.... /usr/lib/systemd/system/httpd.service
    S.5....T. /usr/lib64/httpd/modules/mod_proxy.so
    S.5....T. /usr/lib64/httpd/modules/mod_proxy_fcgi.so
    SM5....TP /usr/sbin/suexec

  • LiteSpeed was previously activated on the server but now it is disabled at Extension Catalog > My Extensions:
    ______.JPG

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.

      Try this one first and if it didn't help proceed further

      # yum reinstall httpd

    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

      CONFIG_TEXT: [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

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.