Plesk

Unable to switch from LiteSpeed to Apache on Plesk server: Apache is not up within 30 secs

Symptoms

Switch from LiteSpeed to Apache fails with the below errors:

Detected Plesk Environment
...
Warning: The unit file, source configuration file or drop-ins of httpd.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[ERROR] Apache is not up within 30 secs. Please check the log file.

Cause

Corrupted Apache service configuration file.

Resolution

For RPM-based distributions (CentOS, RedHat, Cloudlinux, etc):

  1. Connect to the server via SSH.

  2. Create the file /usr/lib/systemd/system/httpd.service with the following content:

    # cat /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

  3. Unmask the httpd service:

    # systemctl unmask httpd

  4. Re-enable it so the required symlinks are created automatically:

    # systemctl disable httpd
    # systemctl enable httpd

  5. Start Apache:

    # systemctl start httpd

For DEB-based distributions (Debian, Ubuntu):

  1. Connect to the server via SSH.

  2. Create the file /lib/systemd/system/apache2.service with the following content:

    # cat /lib/systemd/system/apache2.service
    [Unit]
    Description=The Apache HTTP Server
    After=network.target remote-fs.target nss-lookup.target

    [Service]
    Type=forking
    Environment=APACHE_STARTED_BY_SYSTEMD=true
    ExecStart=/usr/sbin/apachectl start
    ExecStop=/usr/sbin/apachectl stop
    ExecReload=/usr/sbin/apachectl graceful
    PrivateTmp=true
    Restart=on-abort

    [Install]
    WantedBy=multi-user.target

  3. Unmask the apache2 service:

    # systemctl unmask apache2

  4. Re-enabled it so the required symlinks are created automatically:

    # systemctl disable apache2
    # systemctl enable apache2

  5. Start Apache:

    # systemctl start apache2