这是在我的开发机器上运行Linux mint 16(这是基于Ubuntu 13.10)。 我通过安装灯:
apt install lamp-server^
并运行Apache 2.4.6
在安装灯时,我创build了一个info.php文件来运行phpinfo(); 在/ var / www,当然这工作得很好。 在我的开发机器上,我喜欢在我的用户主文件夹中创build一个〜/ public_html。 在那里我创build了我的虚拟主机文件夹。
然后我将public_html文件夹传递给www-data用户:group将myuser添加到www-data组,并为用户和组分配了rwx访问权限:
chmod -R 775 /home/myuser/public_html
现在我的public_html和孩子看起来像
drwxrwxr-x 5 www-data www-data 4096 Apr 1 12:10 public_html
现在我创build了一个/etc/apache2/sites-available/example.local.conf
<VirtualHost *:80> ServerName example.local DocumentRoot "/home/myuser/public_html/example.local.d" <Directory "/home/myuser/public_html/example.local.d"> Options Includes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
然后跑:
a2ensite example.local.conf service apache2 reload // I've also service apache2 restart
然后去example.local我得到一个403
我已经尝试了vhost .conf文件的几个不同的configuration。 在一个我指定的错误日志
在error.log中我得到:
[Tue Apr 01 12:13:06.375465 2014] [core:error] [pid 14208] (13)Permission denied: [client 127.0.0.1:45489] AH00035: access to / denied (filesystem path '/home/myuser/public_html') because search permissions are missing on a component of the path [Tue Apr 01 12:13:06.600588 2014] [core:error] [pid 14208] (13)Permission denied: [client 127.0.0.1:45489] AH00035: access to /favicon.ico denied (filesystem path '/home/myuser/public_html') because search permissions are missing on a component of the path
我该如何解决?
PS这将是为了开发一个Drupal网站,如果这有助于答案。
您的错误消息说:
because search permissions are missing on a component of the path
这意味着父目录不允许Apache遍历它。
要找出哪个目录,依次在每个目录上使用ls -ld ,或者(仅限Linux) 使用namei :
namei -l /home/myuser/public_html
然后您将显示权限,并能够find需要更正权限的目录。 例如,您可能会看到:
f: /home/myuser/public_html drwxr-xr-x root root / drwxr-xr-x root root home drwx------ myuser myuser myuser drwxr-xr-x myuser myuser public_html
在这种情况下, /home/myuser不允许用户以外的任何人进行目录遍历。 所以这可以纠正:
chmod +x /home/myuser
sudo chmod o+x -R /home/myuser/ sudo chmod 777 -R /home/myuser/
这对我有用。