Cannot start Apache, config test fail: "env: apache2ctl: No such file or directory"

15,581

You are missing the apache2ctl script and the symlink for apachectl. For Ubuntu 14.04, both should be in the /usr/sbin/ directory with the following dates (normal installation, upgrades) and permissions:

-rwxr-xr-x 1 root root   6402 Jan  3  2014 /usr/sbin/apache2ctl
lrwxrwxrwx 1 root root     10 Jan 14 17:46 /usr/sbin/apachectl -> apache2ctl

If you have a backup of your system, you should recover. If not, you will need to repair the Apache2 installation.

NOTE ALSO: The /usr/sbin/ directory is a shared directory holding all scripts generally accessible with root privileges. Given that you do not know how the apache2 files went missing, you could have problems beyond this issue or even beyond apache2.

Share:
15,581

Related videos on Youtube

aborted
Author by

aborted

Updated on September 18, 2022

Comments

  • aborted
    aborted over 1 year
    $ apache2 -v
    Server version: Apache/2.4.7 (Ubuntu)
    Server built:   Jan 14 2016 17:45:23
    

    My Ubuntu version is 14.04.

    I was fixing a few things on /etc/apache2/sites-available/000-default.conf and then the next time I restarted Apache, I keep getting this weird error:

    $ sudo service apache2 reload
     * Reloading web server apache2      [fail]                                                                          * 
     * The apache2 configtest failed. Not doing anything.
    Output of config test was:
    env: apache2ctl: No such file or directory
    

    I also reverted all the changes in 000-default.conf, but the issue is not getting resolved.

    I do not understand how I might have caused this issue and also I don't know how to resolve it.

    Help would be highly appreciated.


    Latest Apache error logs:

    [Sun Jun 05 11:50:26.341221 2016] [mpm_worker:notice] [pid 6035:tid 118764177487744] AH00292: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
    [Sun Jun 05 11:50:26.341266 2016] [core:notice] [pid 6035:tid 118764177487744] AH00094: Command line: '/usr/sbin/apache2'
    [Sun Jun 05 12:15:51.071093 2016] [mpm_worker:notice] [pid 6035:tid 118764177487744] AH00295: caught SIGTERM, shutting down
    
    • Colt
      Colt almost 8 years
      What is in the Apache error log?
    • aborted
      aborted almost 8 years
      @Colt I updated the question with the latest logs. The same logs are repeated over and over a couple times in the log file.
    • Colt
      Colt almost 8 years
      and apache2ctl -t ?
    • aborted
      aborted almost 8 years
      Wow! It says The program 'apache2ctl' is currently not installed. You can install it by typing: apt-get install apache2, but it was working earlier as expected? I'm really confused now.
    • Colt
      Colt almost 8 years
      what does sudo ls -la /usr/sbin/apache* return?
    • aborted
      aborted almost 8 years
      @Colt the command above returns this: -rwxr-xr-x 1 root root 637528 Jan 14 18:46 /usr/sbin/apache2
  • aborted
    aborted almost 8 years
    What would be the best way to repair the Apache2 installation?
  • Colt
    Colt almost 8 years
    Given that you do not know what happened to the missing files, or what other files may be messed up, you probably need to consider removing or purging the apache2 package and installing it again. Depending on how you proceed, your configuration and site files may be lost on the server, so make sure you have a backup of all of your files and configured apache2 files.