【发布时间】: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