2

Ubuntu virtual machine with Apache 2.4.7

I'm getting these errors:

apache2: Syntax error on line 216 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/conf-enabled/servername.conf: No such file or directory Action 'configtest' failed.

Note: When I run apachectl configtest, it says Syntax OK

But there is such a file! In fact, Apache found it all by itself. Line 216, mentioned above, is IncludeOptional conf-enabled/*.conf. So I guess it formed a shell expansion and got the list of conf files and then decided one of them didn't exist. Why?

As everyone knows, in /etc/apache2/conf-enabled are a bunch of symlinks to files in /etc/apache2/conf-available, created with a2enconf.

In my case, servername.conf in conf-available is itself a symlink, pointing to one of a set of my own configuration files (for apache and other services) for setting up virtual machines. For some reason, even though Apache is finding the symlink, it is reporting it doesn't exist. I don't see why it's a problem, since there is another symlink there that phpMyAdmin uses to link to its config files and causes no error.

One difference between the phpMyAdmin file and mine is that my file (and all of its parent directories) has 777 permissions. It is in a shared folder mounted from outside the virtual machine (shared with the Windows 8.1 host).

Does Apache have a problem with 777 permissions in config files?

Edit: Here's ls -l output asked for in a comment.

vagrant@vagrant-ubuntu-trusty-64:/vagrant/data$ ls -l /etc/apache2/conf-enabled/servername.conf lrwxrwxrwx 1 root root 33 Jun 29 2016 /etc/apache2/conf-enabled/servername.conf -> ../conf-available/servername.conf

And here's the symlink of the symlink:

vagrant@vagrant-ubuntu-trusty-64:/etc/apache2/conf-available$ ls -l servername.conf lrwxrwxrwx 1 root root 31 Jun 29 2016 servername.conf -> /vagrant/config/servername.conf

And here's the regular file:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/config$ ls -l servername.conf -rwxrwxrwx 1 vagrant vagrant 24 Jun 29 2016 servername.conf

  • ls -l /etc/apache2/conf-enabled/servername.conf? And then ls -l whatever servername.conf points to? I don't understand how servername.conf could point to "a set" of configuration files. – AlexP Jan 7 at 22:44
  • @AlexP my mistake, I meant to say that it pointed to one of a set of configuration files. So, in conf-enabled, a symlink points to another symlink in conf-available, which points to the regular file in my own configuration directory. – Buttle Butkus Jan 7 at 22:53
  • And ls -l /vagrant/config/servername.conf? Please follow the symlink chain to the end. Remember that permissions and ownership on symlinks do not count, only the permissions and ownership on the final resolved file matter. – AlexP Jan 8 at 0:41
  • @AlexP I've added the details of the regular file at the end of the chain. – Buttle Butkus Jan 8 at 2:00
  • OK, final test; try to read that file as www-data (assuming that Apache HTTP Server runs as www-data): sudo -u www-data cat etc/apache2/conf-enabled/servername.conf. – AlexP Jan 8 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.