Search code examples
phpbashapachemacos-sierra

No such file or directory: AH02291: Cannot access directory '/usr/logs/' for main error log AH00014: Configuration check failed


I am trying to install and configure PHP 7.2 on my MacOS Sierra. After installation, I failed to start Apache server and getting following errors.

No such file or directory: AH02291: Cannot access directory '/usr/logs/' for main error log
AH00014: Configuration check failed

I also tried to create '/usr/logs/' directory but it is not permitted. Commands I am using:

$sudo apachectl start
$apachectl configtest

Any help?


Solution

  • Apache needs write permissions for logs:

    On osx /usr is a protected directory, system does not allow creating subdirs in it manually.

    • Create directory /logs sudo mkdir /logs
    • Set permissions sudo chmod 775 /logs
    • Set owner sudo chown {your-apache-user}:{your-apache-group} /logs
    • Optionaly you can add apache user to group of current dir owner (this would be a more universal and cleaner solution) instead of making apache the owner
    • In apache config (dont forget vhosts), change the log directory to the onew directory
    • restart apache

    Much better option: use Vagrant https://www.vagrantup.com/ , that way you wont trash your OS