Linux – Cannot start Apache, config test fail: “env: apache2ctl: No such file or directory”

apache-2.4linuxUbuntuubuntu-14.04

$ 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

Best Answer

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.

Related Topic