Symfony 4项目生产问题



伙计们,我在部署Symfony项目时遇到了一些麻烦:

我运行命令:

composer install --no-dev --optimize-autoloader

我使用了apache包:

composer require symfony/apache-pack

这在带有index.php.的公共文件夹中创建了一个.htaccess

-找不到资产。(公用文件夹中的元素):

GET http://buy-m3.infinityfreeapp.com/css/custom.css 
net::ERR_ABORTED 404 (Not Found)

-数据库连接故障:

Request.CRITICAL: Uncaught PHP Exception DoctrineDBALExceptionConnectionException: 
"An exception occurred in driver: SQLSTATE[HY000] [2002] N
o such file or directory" at /home/vol6_3/epizy.com/epighhg78813/htdocs/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php 
line 112 {"exception":"[object] (Doctrine\DBAL\Exception\ConnectionException(code: 0): An exception occurred in driver: SQLSTATE[HY000] [2002] 
No such file or directory at /home/vol6_3/epizy.com/epghghgh878813/htdocs/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:112)n
[previous exception] [object] (Doctrine\DBAL\Driver\PDO\Exception(code: 2002): SQLSTATE[HY000] [2002] 
No such file or directory at /home/vol6_3/epizy.com/epihghgh13/htdocs/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18)
n[previous exception] [object] (PDOException(code: 2002): 
SQLSTATE[HY000] [2002] No such file or directory at /home/vol6_3/epizy.com/epighgh8813/htdocs/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:38)"} []
  • 转储环境产品:
// This file was generated by running "composer dump-env prod"
return array (
'APP_ENV' => 'prod',
'APP_SECRET' => 'c84117fa77c8ghgghghhgds03',
'DATABASE_URL' => 'mysql:user:password@shost/dnbame',
);

我在应用程序根目录上也添加了一个htacces:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/$1 [QSA,L]
</IfModule>

有人能帮忙吗?感谢

大家好,我可以用很多过程来解决这个问题:首先:composer需要symfony/asset,执行部署symfony应用程序的常见命令,如composer要求symfony/需求检查器,composer dump env prod(确保执行此命令,它会从公共文件夹中创建一个env..php文件,其中包含index.php所需的.env.信息。composer install--no dev--optimize autoloader和APP_env=prod APP_DEBUG=0 php bin/console cache:clear。此外,我不得不使用webpack来管理资产,文档如下:https://symfony.com/doc/current/frontend.html

问候!。

相关内容

  • 没有找到相关文章

最新更新