First of all I want to apologize for my bad English. I have Apache 2.4.23 on MacOS Sierra. Everything worked fine, but at some point it stopped working well. When I try to open some file or directory on my web server it throws an error:
Forbidden
You don't have permission to access / on this server.
Server unable to read htaccess file, denying access to be safe
Though it must show content of the page. It happens with all of my files and directories. I've already added them to the group _www, in which Apache runs, and make chmod -R 775
but it doesn't help. Also doesn't help chmod -R 777
. May be I run Apache with another user or group? I think, no, because in config set up _www as user and group also. That's what "ps aux | grep httpd
" says:
_www 9877 0,0 0,0 2480792 2040 ?? S 6:43 0:00.01 /usr/sbin/httpd -D FOREGROUND
_www 9864 0,0 0,0 2480792 1612 ?? S 6:43 0:00.00 /usr/sbin/httpd -D FOREGROUND
_www 9863 0,0 0,0 2480792 2020 ?? S 6:43 0:00.01 /usr/sbin/httpd -D FOREGROUND
_www 9862 0,0 0,0 2480792 1628 ?? S 6:43 0:00.00 /usr/sbin/httpd -D FOREGROUND
_www 222 0,0 0,0 2480792 1744 ?? S сб08 0:00.02 /usr/sbin/httpd -D FOREGROUND
root 90 0,0 0,1 2481048 7808 ?? Ss сб08 0:01.40 /usr/sbin/httpd -D FOREGROUND
alankabisov 10122 0,0 0,0 2423384 240 s000 R+ 6:58 0:00.00 grep httpd
As we can see it runs under _www. At this moment I have two questions:
sudo apachectl start
"That's my Apache vhosts config:
<Directory "/Users/alankabisov/Sites">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Virtualhost *:80>
VirtualDocumentRoot "/Users/alankabisov/Sites/%1/"
ServerName sites.dev
ServerAlias *.dev
UseCanonicalName Off
</Virtualhost>
So I can access my sites through *.dev domains. For example abc.dev points to abc folder from web root.
Also I have some strange error in my Apache error log:
[Mon Mar 13 18:45:27.113487 2017] [core:crit] [pid 9877] (13)Permission denied: [client 127.0.0.1:58513] AH00529: /Users/alankabisov/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/Users/alankabisov/' is executable, referer: http://php1.dev/
[Mon Mar 13 18:45:27.297229 2017] [core:crit] [pid 9877] (13)Permission denied: [client 127.0.0.1:58513] AH00529: /Users/alankabisov/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/Users/alankabisov/' is executable
[Mon Mar 13 18:45:27.359012 2017] [core:crit] [pid 9877] (13)Permission denied: [client 127.0.0.1:58513] AH00529: /Users/alankabisov/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/Users/alankabisov/' is executable, referer: http://php1.dev/
I find strange that Apache complains for problems of reading htaccess file that locates in the /Users/alankabisov/ directory, but not in the /Users/alankabisov/Sites as set on my vhosts conf.
Hope you will help me. Thank you.
So, it seems that I've solved the problem. Apache looked for htaccess file in the parent directories of the web root and didn't have access to read in that directory. So I've added this directory to group _www and gave for it read permissions. It helped me. May be the solution is not the best, but it helps.