使用 cPanel 部署 symfony 3
deploying symfony 3 with cPanel
我在 cPanel 中部署 Symfony 3 应用程序 时遇到一些问题。
我在 Heroku 或 Fortrabbit 中部署没有问题。
问题是:
I can't connect to my backend using example.com or example.com/app.php
from my frontend and I have to use example.com/app_dev.php.
这只有效,因为我在后端的 app_dev.php:
中评论了这些行
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '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.');
}
但我认为这不是正确的做法。
Is there anyway to set SYMFONY_ENV=prod in cPanel?
据我所知你不能。这在功能请求列表中:
https://features.cpanel.net/topic/setenv-for-addon-domains-and-subdomains
您可以尝试在您的 cPanel 帐户上编辑 .bash_profile 文件(如果您有 ssh 访问权限,您可以通过 ssh 进行,如果没有,您可以使用 cPanel 中的 FileManager 并尝试添加类似这样的内容:
export SYMFONY_ENV=prod
然后再试一次。
更新:
该文件通常位于 /home/cpanelusername/.bash_profile
我在 cPanel 中部署 Symfony 3 应用程序 时遇到一些问题。
我在 Heroku 或 Fortrabbit 中部署没有问题。
问题是:
I can't connect to my backend using example.com or example.com/app.php from my frontend and I have to use example.com/app_dev.php.
这只有效,因为我在后端的 app_dev.php:
中评论了这些行if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '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.');
}
但我认为这不是正确的做法。
Is there anyway to set SYMFONY_ENV=prod in cPanel?
据我所知你不能。这在功能请求列表中:
https://features.cpanel.net/topic/setenv-for-addon-domains-and-subdomains
您可以尝试在您的 cPanel 帐户上编辑 .bash_profile 文件(如果您有 ssh 访问权限,您可以通过 ssh 进行,如果没有,您可以使用 cPanel 中的 FileManager 并尝试添加类似这样的内容:
export SYMFONY_ENV=prod
然后再试一次。
更新:
该文件通常位于 /home/cpanelusername/.bash_profile