Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 410
WasimSafdar Avatar asked Oct 26 '17 10:10

WasimSafdar


2 Answers

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

like image 140
Auris Avatar answered Sep 25 '22 13:09

Auris


A complete and satisfactory solution is also given at https://support.plesk.com/hc/en-us/articles/214527565-Unable-to-start-Apache-when-Apache-logs-directory-is-missing-No-such-file-or-directory-Unable-to-open-logs:

If the error message is

Starting httpd: (2)No such file or directory: httpd: could not open error log file /etc/httpd/logs/error_log.
Unable to open logs

or

httpd[26817]: AH00526: Syntax error on line 43 of /etc/httpd/conf.d/mod_security.conf: httpd[26817]: ModSecurity: Failed to open debug log file: /var/log/httpd/modsec_debug.log

or

[error] (2)No such file or directory: mod_jk: could not open JkLog file /var/log/httpd/mod_jk.log Configuration Failed

or even

apachectl[1891]: (2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for main error log
apachectl[1891]: (2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost defined at /etc/apache2/sites-enabled/000-default.conf:1

Then running (as root):

mkdir /var/log/httpd
chmod 700 /var/log/httpd/
service httpd start

or

mkdir /var/log/apache2
chmod 750 /var/log/apache2
chown root:adm /var/log/apache2
 service apache2 start

should do it!

like image 41
Clément Avatar answered Sep 23 '22 13:09

Clément