Symfony4 部署到共享主机出现错误 500
Symfony4 deploy to shared hosting getting error 500
我已将我的 symfony4 项目部署到共享主机 (infinityFree)。
但是当我访问我的网站时,我收到 500 内部服务器错误 :
Oops! An Error Occurred
The server returned a "500 Internal Server Error".
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
我的项目在本地开发模式下运行良好。
在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 中作为我拥有的 public 文件夹的兄弟姐妹:
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 ^(.*)/$ / [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
好的,所以问题是我在 .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',
);
希望对您有所帮助
我已将我的 symfony4 项目部署到共享主机 (infinityFree)。 但是当我访问我的网站时,我收到 500 内部服务器错误 :
Oops! An Error Occurred The server returned a "500 Internal Server Error".
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
我的项目在本地开发模式下运行良好。
在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 中作为我拥有的 public 文件夹的兄弟姐妹:
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 ^(.*)/$ / [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
好的,所以问题是我在 .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',
);
希望对您有所帮助