A
A
Alan Kabisov2017-03-13 19:06:43
PHP
Alan Kabisov, 2017-03-13 19:06:43

Why doesn't Apache have access to directories?

It costs Apache 2.4.23 on MacOS Sierra. Everything seemed to work fine, but at some point it stopped, although I didn’t really touch anything. The problem is the following: when accessing directories with php scripts or html files, it displays an error:

Forbidden

You don't have permission to access / on this server.
Server unable to read htaccess file, denying access to be safe

Although the index file should open. This applies to all directories. I add directories and files to the _www group under which Apache is running and set their permissions to 775, but it doesn't help. At some point, setting rights to 777 changed the situation, which is also strange. It does not work with a group, but it works like that. Is Apache running under the wrong user? I run it through "sudo apachectl start", the command "ps aux | grep httpd" produces the following:
_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
>
It can be seen that it is running under _www (this group is also registered in the config), but I have two questions here:
1) Why are several Apache instances running?
2) Why is one under the root? I suspect it is because I run it with sudo.
The virtual host config looks like this:
<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>

That is, when accessing the *.dev domain, the * folder is accessed from the root directory of the web server.
The logs "/var/log/apache2/error_log" contain the following messages:
[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 it strange that it complains about the problem of reading the htaccess file from the /Users/alankabisov/ directory, and not /Users/alankabisov/Sites, as it is written in the config. Help, what could be the problem? I don't even know what to try anymore.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alan Kabisov, 2017-03-13
@wzrd

Apparently, Apache went through the directories to the Sites folder and looked for the htaccess file in them, and since it did not have read access to the parent directory of the Sites folder, it threw an error. I decided that I set a group for the parent folder _www and set read permissions for it. It seems to have helped. It's strange how it used to work. Well, the solution may not be the most elegant, alternatives are welcome. Until then, I'll make this a decision.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question