vagrantのlaravel用boxをwindowsで利用
laravel/homestead環境について誤解していたので導入方法のメモ。
- windows上でlaravelプロジェクトを作成
- gitからHomesteadをクローン、init実行
- Homestead.yamlの編集
- ssh鍵の作成
- vagrant up
- 仮想マシン上でlaravelプロジェクトを作成
1.について、xamppとcomposerをインストールすればできるはず。プロジェクト名は「Laravel」とすれば、名前を変更する必要がない。
先に作成しても、後で(6.で)作成しても問題ない気がします。
2.について、Gitは入れておくとssh鍵作成にも使える。GitはVisualStudioインストール時に入れることもできる。
3.について、1.で作成したプロジェクトを /home/vagrant/Code に配置。
siteの設定は「/home/vagrant/Code/<プロジェクト名>/public」に変更(初期値:Laraval)。
4.について、ssh-keygenで作成。Gitインストール時に入るbashシェル(MINGW)で実行できるはず。
5.について、bashシェル上で実行するか、環境変数のPATHの通るところにsshを配置する。
6.について、仮想マシンにsshで入るか、直接コンソールを表示して、「/home/vagrant/Code」上でlaravelプロジェクトを作成(初期値のままであれば、プロジェクト名は「Laravel」)。
メモしてる最中に、既に書かれている記事がありました。
Vagrantの動作環境(Windows)
Vagrantという仮想環境構築ソフトを使用する際に、最初の導入が上手くいかなかったのでメモ。
Windows 10 Home のノートPCに、Vagrant 1.8.5をインストールして、以下のコマンドを実行。
> vagrant init laravel/homestead
> vagrant up --provider virtualbox
すると、「The box 'laravel/homestead' could not be found」と表示される。
Vagrant Cloudを確認しても、コマンドには問題ないし、原因不明なのでぐぐって調べた。
結果、次のページが該当
「Microsoft Visual C++ 2010 SP1 再頒布可能パッケージ (x86)」をインストールしておく必要があると。
インストール後、正常に動作した。
インストール前のログ:
D:\vm_laravel>vagrant init laravel/homestead
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.D:\vm_laravel>vagrant up --provider virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'laravel/homestead' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
The box 'laravel/homestead' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:URL: ["https://atlas.hashicorp.com/laravel/homestead"]
Error:
インストール後のログ:
D:\vm_laravel>vagrant up --provider virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'laravel/homestead' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'laravel/homestead'
default: URL: https://atlas.hashicorp.com/laravel/homestead
==> default: Adding box 'laravel/homestead' (v0.5.0) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.5.0/providers/virtualbox.box
default: Progress: 100% (Rate: 3677k/s, Estimated time remaining: --:--:--)
==> default: Successfully added box 'laravel/homestead' (v0.5.0) for 'virtualbox'!
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: vm_laravel_default_1473501379857_20109
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Remote connection disconnect. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.0.20
default: VirtualBox Version: 5.1
==> default: Mounting shared folders...
default: /vagrant => D:/vm_laravel
Android Studioのインストール
Android Studioを使ってみようと思い、インストールしようかと。
1年前に書かれてる本とか読みながらやると、微妙に違うので備忘録。
・インストール時にExtraがない
古い本だとExtraから色々選択しますが、最新のインストーラだと項目が存在しません。とりあえず、SDKの4.2あたりを選択しておきます(選択時にSDKが対応するAndroidデバイスの割合が表示されます。95%以上なら安心?)
インストール対象のPCがAMDだったので、警告が出てインストール出来ませんでした。
Intel CPUの場合でも、BIOSで無効になってる場合があるので確認が必要です。
・Android端末ごとの個別のデバイスドライバのインストールは不要?
FJL22のドライバは、富士通のサイトから落としてこなくても勝手に入ってました。
PCを買ったときはそこまで気にしてませんでしたが、Androidのエミュレータを使うならIntel CPUが必要そう。
ま、まぁ実機で確認できるからいいんですけどね(強がり
Androidアプリのバックアップ
Android端末(FJL22、32GB)の空き容量が1GB未満の状態なので、空き容量を稼ぐために不要なアプリを消したいなと。
ただ、念のためセーブデータは残したいので、adbコマンドでバックアップしようと思ってました。
結果的に、adbコマンドでPCにアプリを保存しても、セーブデータが復元されない場合がありました。
※非root端末です。rootってなにそれおいしいの
以下、注意点
・adbコマンドは1.0.32だと正常にバックアップできないため、1.0.31のadbコマンドを準備する
・カレントディレクトリは、使用するadbコマンドが存在する場所にする(異なる場所では上手くいかず、0バイトのファイルになった)
ストアで公開終了してるアプリを残したいって場合には使えますが、当初の目的のセーブデータごと残すことは失敗しました。