[英]Symfony 3 - Not allowed to access app_dev.php
I just bought some shared hosting (OVH.com - PHP 5.6.21) to host a Symfony 3 project (version 3.1.3). 我刚买了一些共享主机(OVH.com - PHP 5.6.21)来托管一个Symfony 3项目(版本3.1.3)。
When uploading the config.php file of Symfony on the server, it only displays 2 recommandation messages to improve the site speed, but nothing that could prevent the site from working. 在服务器上上传Symfony的config.php文件时,它只显示2个推荐消息以提高站点速度,但没有任何可能阻止该站点工作的消息。 So, the hosting seems good enough to run this project properly.
因此,托管似乎足以正确运行此项目。
I sent all the files and folders on the server, but when I try to reach the app_dev.php page, I have this error message : 我在服务器上发送了所有文件和文件夹,但是当我尝试访问app_dev.php页面时,出现此错误消息:
You are not allowed to access this file. Check app_dev.php for more information.
I know I have to add my IP addresss to the allowed IPs array in the app_dev.php file, so here's what I did (XXX.XXX.XXX.XXX being my IP address) : 我知道我必须将我的IP地址添加到app_dev.php文件中允许的IP数组中,所以这就是我所做的(XXX.XXX.XXX.XXX是我的IP地址):
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'XXX.XXX.XXX.XXX', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
I tried different things to see where the problem could come from : 我尝试了不同的东西,看看问题可能来自哪里:
The var/logs/dev.log file is totally empty, even if the rights are 777. 即使权限为777,var / logs / dev.log文件也是完全空的。
If you have any idea about where the problem might come from, i'd be glad if you could help me. 如果您对问题的来源有任何想法,如果您能帮助我,我会很高兴。
Thanks in advance for your help ! 在此先感谢您的帮助 !
PS : when I try to reach the prod environment (app.php), i get an error 500, but the var/logs/prod.log file contains lines about MySQL errors... so i guess this is fine. PS:当我尝试到达prod环境(app.php)时,我收到错误500,但var / logs / prod.log文件包含有关MySQL错误的行...所以我想这很好。
Reading the code you know exactly what the problem is :) Or at least, it can be one of 2 reasons: 阅读代码你确切知道问题是什么:)或者至少,它可能是以下两个原因之一:
Client-IP
or X-Forwarded-For
header, which may be set by a reverse proxy (like Varnish) installed before your website. Client-IP
或X-Forwarded-For
标头,可以通过安装在您网站之前的反向代理(如Varnish)进行设置。 Regardless the actual cause, it's advisable to NOT open up your app_dev.php front controller on your production server. 无论实际原因如何,建议不要在生产服务器上打开app_dev.php前端控制器。 Development should be done on your local machine.
应在您的本地计算机上进行开发。 Tampering with this check might accidentally open up the development environment to the outside world.
篡改此检查可能会意外地向外界打开开发环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.