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?
Apache needs write permissions for logs:
On osx /usr is a protected directory, system does not allow creating subdirs in it manually.
sudo mkdir /logs
sudo chmod 775 /logs
sudo chown {your-apache-user}:{your-apache-group} /logs
Much better option: use Vagrant https://www.vagrantup.com/ , that way you wont trash your OS
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With