【问题标题】:Laravel Forge won't deploy with gitLaravel Forge 不会使用 git 部署
【发布时间】:2016-09-22 06:08:43
【问题描述】:

我正在使用 Laravel Forge 将 PHP 站点部署到 Ubuntu 16.04 x64 服务器。我通过 git 部署了站点,站点已启动并运行。

但是,当我尝试通过 git 和 Forge 部署新更改时,我收到以下错误:

> php artisan optimize
Generating optimized class loader


  [PDOException]                             
  SQLSTATE[HY000] [2002] Connection refused  

在以下命令结束时,我在本地计算机上收到相同的 [PDOException] 错误:

composer install --no-interaction

php artisan clear-compiled

php artisan optimize

php artisan migrate

这是我的 Laravel .env 文件:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=MYPASSWORD

这是我的 config/database.php 文件:

   'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', 'MYPASSWORD'),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => false,
            'engine' => null,

当我尝试连接到 Sequel Pro 上的远程数据库时,我可以通过 SSH 登录,但随后出现以下错误:

debug1: channel 1: new [port listener]
debug1: Local connections to LOCALHOST:53986 forwarded to remote address 188.166.19.36:3306
debug1: Local forwarding listening on ::1 port 53986.
debug1: channel 2: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 53986.
debug1: channel 3: new [port listener]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Connection to port 53985 forwarding to 127.0.0.1 port 3306 requested.
debug1: channel 4: new [direct-tcpip]
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
channel 4: open failed: connect failed: Connection refused
debug1: channel 4: free: direct-tcpip: listening port 53985 for 127.0.0.1 port 3306, connect from 127.0.0.1 port 53988 to 127.0.0.1 port 53985, nchannels 5
debug1: Connection to port 53986 forwarding to 188.166.19.36 port 3306 requested.
debug1: channel 4: new [direct-tcpip]
channel 4: open failed: connect failed: Connection refused
debug1: channel 4: free: direct-tcpip: listening port 53986 for 188.166.19.36 port 3306, connect from 127.0.0.1 port 53989 to 127.0.0.1 port 53986, nchannels 5

git、数据库和 Forge 出了点问题,但我想不通。

感谢您的帮助。

【问题讨论】:

  • 我认为您应该更改 DB_HOST 变量(这是您的本地主机地址
  • 谢谢,请看下面我的回复。

标签: php git laravel ubuntu forge


【解决方案1】:

试试这个

DB_HOST=188.166.19.36 // i think this is the host ip if not change it to the right address

不要忘记输入您的密码和端口(如果那不是默认设置)

在你的本地机器中你也应该改变它

【讨论】:

  • 感谢您的回复。我尝试按照您的建议更改 DB_Host,但仍然出现错误。但我注意到我的部署工作正常,只是我收到了这个错误。现在我可以继续,这只是一些 laravel 问题...
  • 我认为问题可能是我没有数据库,而 forge 认为我有?对此有什么想法吗?谢谢。
  • 您的应用需要数据库吗?
  • 我不知道 laravel 5 有没有。我不认为我正在使用它,因为它只是一个带有页面的简单站点。我认为 forge 建立了一个数据库。无论如何,它都会向我发送凭据。
  • 如果你有不需要数据库的页面,我猜你需要从伪造面板更改环境变量
猜你喜欢
  • 1970-01-01
  • 2019-10-05
  • 2016-04-29
  • 2014-10-25
  • 2016-01-09
  • 2016-09-08
  • 2022-12-14
  • 1970-01-01
  • 2015-12-07
相关资源
最近更新 更多