Symfony4部署到共享主机时出现错误500

时间:2019-10-02 18:49:10

标签: php symfony cpanel symfony4

我已经将我的symfony4项目部署到共享主机(infinityFree)。 但是当我访问网站时,出现 500 Internal Server Error

  

糟糕!发生错误   服务器返回“ 500内部服务器错误”。

     

有些东西坏了。请让我们知道发生此错误时您正在做什么。我们将尽快修复它。不便之处,敬请谅解。

我的项目在具有开发人员模式的本地计算机上正常工作。

htdocs / var / log / prod.depreciations.log 中:

[2019-09-20 15:01:41] php.INFO: User Deprecated: The "Symfony\Component\Config\Definition\Builder\TreeBuilder::root()" method called for the "liip_imagine" configuration is deprecated since Symfony 4.3 ... etc


[2019-09-20 15:01:41] php.INFO: User Deprecated: A tree builder without a root node is deprecated since Symfony 4.2 ... etc


[2019-09-20 15:01:41] php.INFO: User Deprecated: The "Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser" class is deprecated since Symfony 4.3 ... etc

[2019-09-20 15:01:43] php.INFO: User Deprecated: The spaceless tag in "@LiipImagine/Form/form_div_layout.html.twig" at line 2 is deprecated since Twig 2.7, use the spaceless filter instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The spaceless tag in \"@LiipImagine/Form/form_div_layout.html.twig\" at line 2 is deprecated since Twig 2.7 ... etc

htdocs / var / log /中没有错误日志。 我的项目部署在htdocs中,并且在htaccess中作为我拥有的公用文件夹的同级文件:

php_value display_errors On
php_flag magic_quotes 1
php_flag magic_quotes_gpc 1
php_value mbstring.http_input auto
php_value date.timezone Europe/Paris
DirectoryIndex public/index.php
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    RewriteEngine On
    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ public/index.php [L]
    #Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

在Cpanel中,PHP版本是7.3(默认),并且我没有使用infinityfree进行ssh访问。我已经遵循了本教程  https://symfony.com/doc/current/deployment.html

1 个答案:

答案 0 :(得分:0)

好吧,问题是我在.env.local.php(或.env)中的数据库密码,请确保您输入了 cpanel密码。 ps:在本地项目中运行之前生成.env.local.php:

composer dump-env prod

您将拥有.env.local.php:

 return array (
  'APP_ENV' => 'prod',
  'APP_SECRET' => ' ',
  'DATABASE_URL' => 'mysql://your_username:your_password@your_host/the_db_name',
  'MAILER_URL' => 'null://localhost',
);

希望获得帮助