【发布时间】:2017-07-06 01:08:06
【问题描述】:
我正在尝试运行一个 php 应用程序,但不断得到 p>
“禁止您无权访问此服务器上的/文件夹。”
我的 httpd.conf 中有 Require all granted 未注释,我也尝试使用
sudo chown -R $USER:$STAFF ~/Sites/secondPHPApp
和
sudo chmod -R 755 ~/Sites/
我在那个文件中有我的 phpadmin。我可以从浏览器访问 phpadmin 并获得 IT WORKS 默认页面,但由于权限问题而无法访问我的应用程序文件夹。
这是我在 httpd-vhosts.conf 中的虚拟主机设置(注意:我在实际文件中确实有一个实际的电子邮件和用户名。):
<VirtualHost *:80>
ServerName test.com
ServerAlias www.test.com
ServerAdmin email
DocumentRoot “/Users/username/Sites/secondPHPApp”
</VirtualHost>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
ls -al ~/Sites 的结果:
total 32
drwxr-xr-x 6 755 staff 204 Feb 16 11:00 .
drwxr-xr-x+ 51 LonnieMcGill staff 1734 Feb 15 14:33 ..
-rwxr-xr-x@ 1 755 staff 6148 Feb 16 10:47 .DS_Store
-rwxr-xr-x 1 755 staff 20 Feb 15 09:53 index.php
drwxr-xr-x@ 112 755 staff 3808 Feb 15 13:34 phpmyadmin
lrwxr-xr-x 1 755 staff 60 Feb 16 11:00 secondPHPApp -> /Users/LonnieMcGill/Desktop/Project Folder/php/secondPHPApp/
ls -al ~/Sites/secondPHPApp 的结果:
lrwxr-xr-x 1 755 staff 60 Feb 16 11:00 /Users/LonnieMcGill/Sites/secondPHPApp -> /Users/LonnieMcGill/Desktop/Project Folder/php/secondPHPApp/
ls -al ~/Sites/secondPHPApp/index.html 的结果:
-rw-r--r-- 1 LonnieMcGill staff 360 Feb 16 11:02 /Users/LonnieMcGill/Sites/secondPHPApp/index.html
【问题讨论】:
-
您的文件夹中有索引文件吗?否则,如果您的 apache 不允许列出文件,它将显示该错误消息。
-
尝试在您的
~/Sites/secondPHPApp中添加index.html -
我尝试访问的文件夹中有一个 index.html 文件。
-
您能告诉我们您的
vhost配置文件吗?另外,你在浏览器中输入了什么? localhost 还是别的什么? -
我正在输入 localhost/secondPHPApp 我也尝试过 localhost/secondPHPApp/index.html
标签: php apache permissions