Php 哈罗库上的拉威尔5.4。禁止你';我没有访问/访问此服务器的权限
我已经在Heroku上部署了我的laravel 5.4应用程序。问题是,我收到以下错误消息: 禁止 您没有访问/访问此服务器的权限 我的程序文件:Php 哈罗库上的拉威尔5.4。禁止你';我没有访问/访问此服务器的权限,php,apache,heroku,laravel-5.4,Php,Apache,Heroku,Laravel 5.4,我已经在Heroku上部署了我的laravel 5.4应用程序。问题是,我收到以下错误消息: 禁止 您没有访问/访问此服务器的权限 我的程序文件: web: vendor/bin/heroku-php-apache2 public/ <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> Rewrite
web: vendor/bin/heroku-php-apache2 public/
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteC
DirectoryIndex index.php
查看日志,我发现它一直在尝试“app/”而不是“/”
我的日志,为便于阅读而剪掉
2017-12-03T14:18:45.747195+00:00 app[web.1]: [Sun Dec 03 14:18:45.746749 2017] [autoindex:error] [pid 122:tid 140692458305280] [client 10.140.221.43:41026] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
My.htaccess:
web: vendor/bin/heroku-php-apache2 public/
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteC
DirectoryIndex index.php
选项-多视图
重新启动发动机
#如果不是文件夹,则重定向尾部斜杠。。。
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)/$/$1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
#句柄授权头
重写
我不知道在哪里我可能会说它来研究'app/'而不是'/'。如果这是导致此错误的原因。
/app
是应用所在的文件系统上的绝对路径。该错误表明您的Procfile
实际上并不包含您声称的内容。您可能还没有将其添加并提交给Git。Apache现在正试图从“根目录”而不是从public/
子目录提供服务。我不知道为什么服务器认为您的根目录位于/app
,但发生此错误是因为Heroku应该从其为您的应用程序提供服务的public/
目录具有权限
要解决此问题,只需将以下内容添加到composer.json的script
部分
"post-install-cmd": [
"php artisan clear-compiled",
"chmod -R 777 public/"
]
请注意public/
目录的权限更改
编辑:
在编写时,请检查您的Procfile
,确保拼写正确,并以大写的p
开头
附言:我知道有些人真的很挑剔,会说许可太宽松了。是的,我同意你的看法。您可以将其更改为其他内容,如775
,让我们开始吧。创建此.htaccess文件并将其放入您的laravel安装文件夹。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
重新启动发动机
重写cond%{REQUEST_URI}^公众的
重写规则^(.*)$public/$1[L]
解决方案如下:在Laravel根文件夹中,创建一个名为Procfile的文件
web: vendor/bin/heroku-php-nginx public/
在Procfile中写入以下行
web: vendor/bin/heroku-php-nginx public/
然后再次部署它!
这里有Src和更多
希望这有帮助=)我今天遇到了同样的问题,并且找到了一个简单的解决方案。我在Heroku上运行Laravel 6应用程序
问题是在我设置HTTPS重定向后开始的,我添加了一个apache配置文件,并使用Heroku Procfile中的-C选项加载它:
web: vendor/bin/heroku-php-apache2 -C apache.conf public/
我收到的错误是:
2020-01-13T03:55:29.272349+00:00 app[web.1]: [Mon Jan 13 03:55:29.271704 2020] [autoindex:error] [pid 127:tid 140227477751552] [client 10.213.231.122:26179] AH01276: Cannot serve directory /app/public/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
和你一样的问题。我发现,当您在Heroku上使用自定义配置启动apache时,它开始查找index.html文件,而不是index.php文件
为了解决这个问题,我在apache配置文件中添加了以下行:
web: vendor/bin/heroku-php-apache2 public/
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteC
DirectoryIndex index.php
这将指示apache查找index.php,并修复该问题。即使我遵循了标记为正确的答案,此错误仍然存在
(甚至我已经运行了heroku运行bash
到ls-l
来查看文件权限)
但我仍然会遇到这个错误,可能是因为我使用的是不同的本地分支,而不是本地主分支,所以我的建议是始终从本地主分支部署,并且当我从另一个分支部署时,我会在将代码推送到heroku时获得此日志
NOTICE: No Procfile, using 'web: heroku-php-apache2'
在Heroku上部署我的Laravel应用程序时,我也遇到了同样的问题。我试图更改我的composer文件中/的权限,但没有帮助。相反,我将以下内容添加到我的htaccess文件中:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
DirectoryIndex.html index.php
将此推送到Heroku解决了问题。解决方案步骤:
将项目克隆到电脑:
heroku git:clone-a你的应用程序名
创建文件名:Procfile
然后保存此程序文件中的以下代码行:web:vendor/bin/heroku-php-apache2 public/
使用commed将项目部署回heroku:
$git add.
$git commit-am“让它变得更好”
$git推送heroku主机
我希望现在运行你的Laravel应用程序没有问题
我使用echo“web:vendor/bin/heroku-php-apache2 public/”>Procfile
命令创建了Procfile
,就像告诉我的那样,但是它在引号内生成了Procfile
命令。这就是为什么,即使我像其他用户建议的那样修改了我的composer.json
文件,我仍然会收到403禁止的错误
伙计们,确保Procfile
中的命令没有被引号括起来。然后,修改composer.json
,就像建议重新部署站点的已批准答案一样。我删除了procfile文件文本周围的引号,该文件可以正常工作我已将以下代码添加到我的composer.json中。我还找到了一个解决方案[即正确命名Procfile。但我仍然收到错误消息,请检查Procfile名称的拼写。确保拼写正确,并以大写的P开头。我还尝试了“chmod-R 777 app/storage”通过添加cmd命令对存储目录具有权限,将显示相同的错误。我也尝试过此解决方案,但错误仍然存在。@trustidkid me Too若要生成此命令,请确保您使用的命令与:[echo web:vendor/bin/heroku-php-apache2 public/>Procfile]完全相同没有任何引号,在项目目录中。引号会导致此错误。谢谢,这项工作