Laravel / Homestead 403禁止

时间:2016-09-01 23:24:16

标签: php laravel nginx virtualbox homestead

我得到 403 Forbidden | nginx / 1.11.1 错误。我已正确设置所有内容,但我一直收到此错误。我在Stackoverflow和其他网站上涉及其他一些类似的问题,但没有一个给我结果。这是我第一次使用Homestead for Laravel。

IP在/ etc / hosts文件中列为homestead.app

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: /home/prokaryote/Code
      to: /home/vagrant/Code

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public

********* EDIT *****************

以下是终端中Laravel目录的权限。

machine@User:~/Code/Laravel/public/blog$ namei -l ~/Code/Laravel/public/blog
f: /home/prokaryote/Code/Laravel/public/blog
drwxr-xr-x root       root       /
drwxr-xr-x root       root       home
drwxrwx--- prokaryote prokaryote prokaryote
drwxrwxr-x prokaryote prokaryote Code
drwxrwxr-x prokaryote prokaryote Laravel
drwxrwxr-x prokaryote prokaryote public
drwxrwxr-x prokaryote prokaryote blog

以下是Virtualbox机器中Laravel目录的权限。

vagrant@homestead:~$ namei -l ~Code/Laravel/public/blog
f: /home/vagrant/Code/Laravel/public/blog
drwxr-xr-x root       root       /
drwxr-xr-x root       root       home
drwxr-xr-x root       root       vagrant
drwxrwxr-x vagrant    vagrant    Code
drwxrwxr-x vagrant    vagrant    Laravel
drwxrwxr-x vagrant    vagrant    public
drwxrwxr-x vagrant    vagrant    blog

2 个答案:

答案 0 :(得分:2)

您的文件夹可能有误。

在项目目录中打开终端窗口并输入

$currentUserID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$currentUserPrincipal = New-Object System.Security.Principal.WindowsPrincipal($currentUserID)

$adminPrincipal = [System.Security.Principal.WindowsBuiltInRole]::Administrator

# If not already admin start a new process and pass the current session definition to the admin powershell instance.
if(-not ($currentUserPrincipal.IsInRole($adminPrincipal))) {
    $adminProc = New-Object System.Diagnostics.ProcessStartInfo "powershell"
    $adminProc.Arguments = $MyInvocation.MyCommand.Definition
    $adminProc.Verb = "runas"

    [System.Diagnostics.Process]::Start($adminProc)

    #If you don't need to keep the current session open uncomment this line.
    #exit
}

# Any code executed at this point will execute in an admin PS session.
ping google.com

这将打印工作目录,更改yaml文件中的工作目录。

希望它有所帮助。我也是Laravel的新手。

答案 1 :(得分:2)

好的小伙子我已经弄清楚了。我试图访问Laravel的根文件而不是服务器环境中不允许的公用文件夹。这是文件夹层次结构。现在我想到它是有道理的。简单的错误。

示例(层次结构错误):

sites:
    - map: homestead.app
      to: ~/Code/Laravel/public

Laravel (公用文件夹容器) - > 公开(Laravel proj。文件夹) - > Laravel项目(根目录)

示例(正确的层次结构):

sites:
    - map: homestead.app
      to: ~/Code/Laravel(root directory of Laravel)/public(accesible folder)

Laravel (根目录) - > 公开(可访问的文件夹不是root)