個人的に「PHPフレームワーク Laravel Webアプリケーション開発 バージョン5.5 LTS対応」でHomesteadの開発環境を構築していてすんなり行かなかった箇所。
この記事はとりあえず動く状態にする為に私が実行した手順を残しているだけです。
正しい方法とは言えないかも知れません。
p7. Homesteadのダウンロードでエラー
$ vagrant box add laravel/homestead
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
vagrant box add した際のエラー解決(OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54)
~/.vagrant.d/tmp/
以下を削除。
$ rm ~/.vagrant.d/tmp/*
p13. Vagrantの起動でエラー
$ vagrant up
Check your Homestead.yaml (or Homestead.json) file, the path to your private key does not exist.
秘密鍵(private key)が無いと言われているっぽいので、作成。
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
ファイルの場所とパスフレーズを聞かれたけどとりあえず全部未入力で出来た。
このあたりは別途調べる(多分)
/Users/xxx/.ssh
ディレクトリにid_rsa
id_rsa.pub
が作成される。
ファイルの場所をHomestead.yaml
に設定すればいいっぽい。
特に触っていないならそのままでいいはず。
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
p35. マイグレーションの実行が出来ない
$ php artisan migrate
In Connection.php line 664:
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = homestead and table_n
ame = migrations)
In Connector.php line 67:
SQLSTATE[HY000] [2002] Connection refused
頑張ってずっとローカルで実行してた。
vagrant ssh
で仮想環境に接続しての仮想環境内のsampleappディレクトリで実行したらできた。
仮想環境にしかDBは作成していないから考えてみれば当たり前か(?)。
Homestead仮想マシンを使用している場合は、仮想マシン内からこのコマンドを実行する必要があります。
余談、127.0.0.1とlocalhost
127.0.0.1
と localhost
は接続するのは同じlocalhostでも
接続の方法(?)が変わるらしいです。この辺りはあとで調べる(多分)。
127.0.0.1
で接続出来ない時はlocalhost
に直して試して見てもいいかも。
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
127.0.0.1
を localhost
に変更
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_SOCKET=/var/run/mysqld/mysqld.sock
$ mysqladmin version
mysqladmin Ver 8.42 Distrib 5.7.27, for Linux on x86_64
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.7.27-0ubuntu0.18.04.1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 2 hours 2 min 40 sec
Threads: 1 Questions: 53 Slow queries: 0 Opens: 111 Flush tables: 1 Open tables: 102 Queries per second avg: 0.007
UNIX socket の /var/run/mysqld/mysqld.sock
をDB_SOCKETに設定。