Solution to "error retrieving pid file" - Termux and apache

Apache errors overview:

(20014) Internal error (specific information not available):

AH00058: Error retrieving pid file var / run / apache2 /

AH00059: Remove it before continuing if it is corrupted.
This mistake seems while summoning apachectl either with start or with stop and here and there happens when running on Previous Install XAMPP apache on android termux.
  • Stop apache first
    apachectl stop
  • Change dir:
    cd /data/data/com.termux/files/usr/var/run/apache2
  • Then delete the file:
  • Or using this script:

    # This script is part of the video,
    # Cómo instalar Apache Web Server en Android: and
    # it's intended to be used on Termux Android 32 bits in order to fix the issue,
    # Before executing this script you must install termux-chroot see de video,
    # Cómo hacer chroot en Termux:
    #!/usr/bin/env bash
    aps=$(pidof httpd)
    [[ -f $pidf ]] && rm -f $pidf
    [[ "$aps" != "" ]] && kill -9 $aps

Github issues:

apache error termux