No such file or directory: AH02291: Cannot access directory '/usr/logs/' for main error log AH00014: Configuration check failed
Solution 1
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
Solution 2
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!
WasimSafdar
I am iOS/Android software consultant working in Denmark. I love to create applications and programming is my passion. My skills are in Objective C, Swift, Xcode, Java, Android Studio, Git, Github, Agile tools, Integrating RESTFUL Web services, sqlite3 and third party API's. Moreover, I also have experience in Image processing, Data modelling and Database management and using Agile developmental tools.
Updated on June 15, 2022Comments
-
WasimSafdar almost 2 years
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?
-
WasimSafdar over 6 yearsWhen I tried to create directory, I get following error. "mkdir: /usr/logs: Operation not permitted"
-
Auris over 6 yearsuse
sudo
before the command. This is system owned directory so you need elevated privilege to write -
Auris over 6 yearshmmm... check if the directory /usr/logs already exists? if it does, you will need to add apache user to the dir owner group
-
WasimSafdar over 6 yearsIt does not exists
-
Auris over 6 yearsIn that case create a new directory, lets say /logs. then change apache config to use that directory. Don't forget to change owner of directory and access permissions so that apache can write there