イントロダクションIntroduction
ローカル開発環境を含め、PHP開発全体を愉快なものにしようとLaravelは努力しています。Vagrantは、仮想マシンの管理と事前設定を行う、簡単でエレガントな手段を提供しています。Laravel strives to make the entire PHP development experience delightful, including your local development environment. Vagrant[https://www.vagrantup.com] provides a simple, elegant way to manage and provision Virtual Machines.
Laravel Homestead(入植農地、「ホームステード」)はパッケージを事前に済ませた、Laravel公式の"box"で、PHPやWebサーバ、その他のサーバソフトウェアをローカルマシンにインストールする必要なく、素晴らしい開発環境を準備できます。オペレーティングシステムでごちゃごちゃになる心配はもうありません! Vagrant boxは完全に使い捨てできます。何かの調子が悪くなれば壊して、数分のうちにそのboxを再生成できます!Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!
Homesteadは、Windows、Mac、Linuxシステムで実行でき、Nginx Webサーバ、PHP7.1、MySQL、Postgres、Redis、Memcached、Nodeやその他、素晴らしいLaravelアプリケーションを開発するために必要な、クールなツールを全部含んでいます。Homestead runs on any Windows, Mac, or Linux system, and includes the Nginx web server, PHP 7.1, MySQL, Postgres, Redis, Memcached, Node, and all of the other goodies you need to develop amazing Laravel applications.
Note: {note} If you are using Windows, you may need to enable hardware virtualization (VT-x). It can usually be enabled via your BIOS. If you are using Hyper-V on a UEFI system you may additionally need to disable Hyper-V in order to access VT-x.
Windowsを使用している場合は、ハードウェア仮想化(VT-x)を有効にする必要があります。通常、BIOSにより有効にできます。UEFI system上のHyper-Vを使用している場合は、VT-xへアクセスするため、さらにHyper-Vを無効にする必要があります。
含まれるソフトウェアIncluded Software
- Ubuntu 16.04Ubuntu 16.04
- GitGit
- PHP 7.1PHP 7.1
- NginxNginx
- MySQLMySQL
- MariaDBMariaDB
- Sqlite3Sqlite3
- PostgresPostgres
- ComposerComposer
- Node (Yarn、Bower、Bower、Grunt、Gulpを含む)Node (With Yarn, Bower, Grunt, and Gulp)
- RedisRedis
- MemcachedMemcached
- BeanstalkdBeanstalkd
- MailhogMailhog
- ngrokngrok
インストールと設定Installation & Setup
最初の段階First Steps
Homestead環境を起動する前に、VirtualBox 5.1とVMWare、もしくはParallels、それとVagrantをインストールする必要があります。全ソフトウェア共に簡単に使用できるビジュアルインストーラが、人気のあるオペレーティングシステム全部に用意されています。Before launching your Homestead environment, you must install VirtualBox 5.1[https://www.virtualbox.org/wiki/Downloads], VMWare[https://www.vmware.com], or Parallels[http://www.parallels.com/products/desktop/] as well as Vagrant[https://www.vagrantup.com/downloads.html]. All of these software packages provide easy-to-use visual installers for all popular operating systems.
VMwareプロバイダを使用するには、VMware Fusion/WorkstationとVMware Vagrantプラグインを購入する必要があります。無料ではありませんが、VMwareが提供する共有フォルダーは最初からよりスピーディーです。To use the VMware provider, you will need to purchase both VMware Fusion / Workstation and the VMware Vagrant plug-in[https://www.vagrantup.com/vmware]. Though it is not free, VMware can provide faster shared folder performance out of the box.
Parallelsプロバイダを使用するには、Parallels Vagrantプラグインをインストールする必要があります。これは無料です。To use the Parallels provider, you will need to install Parallels Vagrant plug-in[https://github.com/Parallels/vagrant-parallels]. It is free of charge.
Homestead Vagrant BoxのインストールInstalling The Homestead Vagrant Box
VirtualBox/VMwareとVagrantをインストールし終えたら、laravel/homestead
boxをVagrantへ追加するため次のコマンドを端末で実行する必要があります。boxをダウンロードし終えるまで、接続速度にもよりますが数分かかるでしょう。Once
VirtualBox
/
VMware
and
Vagrant
have
been
installed,
you
should
add
the
laravel/homestead
box
to
your
Vagrant
installation
using
the
following
command
in
your
terminal.
It
will
take
a
few
minutes
to
download
the
box,
depending
on
your
Internet
connection
speed:
vagrant box add laravel/homestead
このコマンドが失敗する場合、Vagrantを更新する必要があります。If this command fails, make sure your Vagrant installation is up to date.
HomesteadのインストールInstalling Homestead
リポジトリーをクローンするだけでHomesteadをインストールできます。自分の「ホーム」ディレクトリの中のHomestead
フォルダーへリポジトリーをクローンするのことは、自分のLaravel(とPHP)の全プロジェクトをホストしておくHomestead
Boxを用意するのだと考えてください。You
may
install
Homestead
by
simply
cloning
the
repository.
Consider
cloning
the
repository
into
a
Homestead
folder
within
your
"home"
directory,
as
the
Homestead
box
will
serve
as
the
host
to
all
of
your
Laravel
projects:
cd ~
git clone https://github.com/laravel/homestead.git Homestead
master
ブランチは常に安定しているわけではないため、バージョンタグがついたHomesteadをチェックアウトすべきでしょう。最新の安定バージョンは、GitHubのリリースページで見つかります。You
should
check
out
a
tagged
version
of
Homestead
since
the
master
branch
may
not
always
be
stable.
You
can
find
the
latest
stable
version
on
the
GitHub
Release
Page[https://github.com/laravel/homestead/releases]:
cd Homestead
// クローンしたいリリースバージョン
git checkout v5.4.0
Homesteadリポジトリをクローンしたら、Homestead.yaml
設定ファイルを生成するために、bash
init.sh
コマンドをHomesteadディレクトリで実行します。Once
you
have
cloned
the
Homestead
repository,
run
the
bash
init.sh
command
from
the
Homestead
directory
to
create
the
Homestead.yaml
configuration
file.
The
Homestead.yaml
file
will
be
placed
in
the
Homestead
directory:
// Mac / Linux...
bash init.sh
// Windows...
init.bat
Homestead設定Configuring Homestead
プロバイダの設定Setting Your Provider
Homestead.yaml
ファイル中のprovider
キーは、Vagrantのプロバイダとして、virtualbox
、vmware_fusion
、vmware_workstation
、parallels
のどれを使用するかを指定します。使用するプロバイダの値を指定してください。The
provider
key
in
your
Homestead.yaml
file
indicates
which
Vagrant
provider
should
be
used:
virtualbox
,
vmware_fusion
,
vmware_workstation
,
or
parallels
.
You
may
set
this
to
the
provider
you
prefer:
provider: virtualbox
共有フォルダーの設定Configuring Shared Folders
Homestead.yaml
ファイルのfolders
プロパティーには、Homestead環境と共有したい全フォルダーがリストされています。これらのフォルダーの中のファイルが変更されると、ローカルマシンとHomestead環境との間で同期されます。必要なだけ共有フォルダーを設定してください!The
folders
property
of
the
Homestead.yaml
file
lists
all
of
the
folders
you
wish
to
share
with
your
Homestead
environment.
As
files
within
these
folders
are
changed,
they
will
be
kept
in
sync
between
your
local
machine
and
the
Homestead
environment.
You
may
configure
as
many
shared
folders
as
necessary:
folders:
- map: ~/Code
to: /home/vagrant/Code
NFSを有効にするには、同期するフォルダーにフラッグを指定するだけです。To enable NFS[https://www.vagrantup.com/docs/synced-folders/nfs.html], you only need to add a simple flag to your synced folder configuration:
folders:
- map: ~/Code
to: /home/vagrant/Code
type: "nfs"
Note: vagrant-bindfsプラグインのインストールを考慮してください。このプラグインは、Homestead下のファイルとディレクトリのユーザー/グループパーミッションを正しく維持します。{note} When using NFS, you should consider installing the vagrant-bindfs[https://github.com/gael-ian/vagrant-bindfs] plug-in. This plug-in will maintain the correct user / group permissions for files and directories within the Homestead box.
NFSを使用する場合は、
さらに、Vagrantの同期フォルダでサポートされている任意のオプションを、options
キーの下に列挙して渡すことができます。You
may
also
pass
any
options
supported
by
Vagrant's
Synced
Folders[https://www.vagrantup.com/docs/synced-folders/basic_usage.html]
by
listing
them
under
the
options
key:
folders:
- map: ~/Code
to: /home/vagrant/Code
type: "rsync"
options:
rsync__args: ["--verbose", "--archive", "--delete", "-zz"]
rsync__exclude: ["node_modules"]
Nginxサイトの設定Configuring Nginx Sites
Nginxには詳しくない?
問題ありません。sites
プロパティーでHomestead環境上のフォルダーと「ドメイン」を簡単にマップできます。サイト設定のサンプルは、Homestead.yaml
ファイルに含まれています。これも必要に応じ、Homestead環境へサイトを好きなだけ追加してください。便利に使えるように、Homesteadは皆さんが作業する全てのLaravelプロジェクトの仮想環境を提供します。Not
familiar
with
Nginx?
No
problem.
The
sites
property
allows
you
to
easily
map
a
"domain"
to
a
folder
on
your
Homestead
environment.
A
sample
site
configuration
is
included
in
the
Homestead.yaml
file.
Again,
you
may
add
as
many
sites
to
your
Homestead
environment
as
necessary.
Homestead
can
serve
as
a
convenient,
virtualized
environment
for
every
Laravel
project
you
are
working
on:
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
sites
プロパティをHomestead
boxのプロビジョニング後に変更した場合、仮想マシンのNginx設定を更新するため、vagrant
reload
--provision
を再実行する必要があります。If
you
change
the
sites
property
after
provisioning
the
Homestead
box,
you
should
re-run
vagrant
reload
--provision
to
update
the
Nginx
configuration
on
the
virtual
machine.
hostsファイルThe Hosts File
Nginxサイトの"domains"に追加したサイトをあなたのコンピューターのhosts
ファイルにも追加してください。hosts
ファイルはローカルドメインへのリクエストをHomestead環境へ転送してくれます。MacとLinuxでは、/etc/hosts
にこのファイルがあります。Windows環境では、C:\Windows\System32\drivers\etc\hosts
です。次の行のように追加してください。You
must
add
the
"domains"
for
your
Nginx
sites
to
the
hosts
file
on
your
machine.
The
hosts
file
will
redirect
requests
for
your
Homestead
sites
into
your
Homestead
machine.
On
Mac
and
Linux,
this
file
is
located
at
/etc/hosts
.
On
Windows,
it
is
located
at
C:\Windows\System32\drivers\etc\hosts
.
The
lines
you
add
to
this
file
will
look
like
the
following:
192.168.10.10 homestead.app
設定するIPアドレスにはHomestead.yaml
ファイルの中の値を確実に指定してください。ドメインをhosts
ファイルへ追加したら、Webブラウザーでサイトにアクセスできます。Make
sure
the
IP
address
listed
is
the
one
set
in
your
Homestead.yaml
file.
Once
you
have
added
the
domain
to
your
hosts
file
and
launched
the
Vagrant
box
you
will
be
able
to
access
the
site
via
your
web
browser:
http://homestead.app
Vagrant Boxの実行Launching The Vagrant Box
Homestead.yaml
のリンクを編集終えたら、Homesteadディレクトリでvagrant
up
コマンドを実行してください。Vagrantは仮想マシンを起動し、共有フォルダーとNginxサイトを自動的に設定します。Once
you
have
edited
the
Homestead.yaml
to
your
liking,
run
the
vagrant
up
command
from
your
Homestead
directory.
Vagrant
will
boot
the
virtual
machine
and
automatically
configure
your
shared
folders
and
Nginx
sites.
仮想マシンを破壊するには、vagrant
destroy
--force
コマンドを使用します。To
destroy
the
machine,
you
may
use
the
vagrant
destroy
--force
command.
プロジェクトごとにインストールPer Project Installation
Homesteadをグローバルにインストールし、全プロジェクトで同じHomestead
Boxを共有する代わりに、Homesteadインスタンスを管理下のプロジェクトごとに設定することもできます。プロジェクトごとにHomesteadをインストールする利点は、Vagrantfile
をプロジェクトに用意すれば、プロジェクトに参加している他の人達も、vagrant
up
だけで仕事にとりかかれることです。Instead
of
installing
Homestead
globally
and
sharing
the
same
Homestead
box
across
all
of
your
projects,
you
may
instead
configure
a
Homestead
instance
for
each
project
you
manage.
Installing
Homestead
per
project
may
be
beneficial
if
you
wish
to
ship
a
Vagrantfile
with
your
project,
allowing
others
working
on
the
project
to
simply
vagrant
up
.
Homesteadをプロジェクトに直接インストールするには、Composerを使います。To install Homestead directly into your project, require it using Composer:
composer require laravel/homestead --dev
Homesteadがインストールできたら、Vagrantfile
とHomestead.yaml
ファイルをプロジェクトルートへ生成するためにmake
コマンドを使ってください。make
コマンドはHomestead.yaml
ファイルのsites
とfolders
ディレクティブを自動的に設定します。Once
Homestead
has
been
installed,
use
the
make
command
to
generate
the
Vagrantfile
and
Homestead.yaml
file
in
your
project
root.
The
make
command
will
automatically
configure
the
sites
and
folders
directives
in
the
Homestead.yaml
file.
Mac / Linux:Mac / Linux:
php vendor/bin/homestead make
Windows:Windows:
vendor\bin\homestead make
次にvagrant
up
コマンドを端末で実行し、ブラウザでhttp://homestead.app
のプロジェクトへアクセスしてください。/etc/hosts
ファイルにhomestead.app
か選んだドメインのエントリーを追加する必要はあることを覚えておきましょう。Next,
run
the
vagrant
up
command
in
your
terminal
and
access
your
project
at
http://homestead.app
in
your
browser.
Remember,
you
will
still
need
to
add
an
/etc/hosts
file
entry
for
homestead.app
or
the
domain
of
your
choice.
MariaDBのインストールInstalling MariaDB
MySQLの代わりにMariaDBを使用したい場合は、mariadb
オプションをHomestead.yaml
ファイルへ追加してください。このオプションはMySQLを削除し、MariaDBをインストールします。MariaDBはMySQLとそのまま置き換えられる代用ソフトウェアですので、mysql
データベースドライバをそのままアプリケーションで使用できます。If
you
prefer
to
use
MariaDB
instead
of
MySQL,
you
may
add
the
mariadb
option
to
your
Homestead.yaml
file.
This
option
will
remove
MySQL
and
install
MariaDB.
MariaDB
serves
as
a
drop-in
replacement
for
MySQL
so
you
should
still
use
the
mysql
database
driver
in
your
application's
database
configuration:
box: laravel/homestead
ip: "192.168.20.20"
memory: 2048
cpus: 4
provider: virtualbox
mariadb: true
使用方法Daily Usage
HomesteadへグローバルにアクセスするAccessing Homestead Globally
MacとLinuxシステムでは、Bashプロファイルへ簡単なBash関数を追加すれば実現できます。Windowsでは、PATH
に「バッチ」ファイルを追加すれば、行えます。以下のスクリプトはシステムのどこからでも、どんなVagrantコマンドでも実行できるようにし、自動的にHomesteadをインストール済みのディレクトリで実行します。Sometimes
you
may
want
to
vagrant
up
your
Homestead
machine
from
anywhere
on
your
filesystem.
You
can
do
this
on
Mac
/
Linux
systems
by
adding
a
Bash
function
to
your
Bash
profile.
On
Windows,
you
may
accomplish
this
by
adding
a
"batch"
file
to
your
PATH
.
These
scripts
will
allow
you
to
run
any
Vagrant
command
from
anywhere
on
your
system
and
will
automatically
point
that
command
to
your
Homestead
installation:
Mac / LinuxMac / Linux
function homestead() {
( cd ~/Homestead && vagrant $* )
}
エイリアス中の~/Homestead
パスを実際にHomesteadをインストール場所を示すように調整してください。関数がインストールできたら、システムのどこからでもhomestead
up
やhomestead
ssh
のように実行できます。Make
sure
to
tweak
the
~/Homestead
path
in
the
function
to
the
location
of
your
actual
Homestead
installation.
Once
the
function
is
installed,
you
may
run
commands
like
homestead
up
or
homestead
ssh
from
anywhere
on
your
system.
WindowsWindows
以下の内容のhomestead.bat
バッチファイルを、マシン上に作成してください。Create
a
homestead.bat
batch
file
anywhere
on
your
machine
with
the
following
contents:
@echo off
set cwd=�%
set homesteadVagrant=C:\Homestead
cd /d %homesteadVagrant% && vagrant %*
cd /d %cwd%
set cwd=
set homesteadVagrant=
スクリプト例中のC:\Homestead
パスは、実際にHomesteadをインストールした場所を指すように調整してください。ファイルを作成したら、PATH
へファイルの場所を追加します。これでhomestead
up
やhomestead
ssh
のようなコマンドをシステムのどこからでも実行できます。Make
sure
to
tweak
the
example
C:\Homestead
path
in
the
script
to
the
actual
location
of
your
Homestead
installation.
After
creating
the
file,
add
the
file
location
to
your
PATH
.
You
may
then
run
commands
like
homestead
up
or
homestead
ssh
from
anywhere
on
your
system.
SSH接続Connecting Via SSH
Homesteadディレクトリでvagrant
ssh
端末コマンドを実行すれば、仮想マシンにSSHで接続できます。You
can
SSH
into
your
virtual
machine
by
issuing
the
vagrant
ssh
terminal
command
from
your
Homestead
directory.
しかし、Homesteadマシンには頻繁にSSHでアクセスする必要があると思いますから、ホストマシンから素早くHomestead boxへSSH接続できるように、上記の「関数」を追加することを検討してください。But, since you will probably need to SSH into your Homestead machine frequently, consider adding the "function" described above to your host machine to quickly SSH into the Homestead box.
データベースへの接続Connecting To Databases
homestead
のデータベースは、最初からMySQLとPostgresのために設定されています。より便利に使えるように、初めからフレームワークはこれらのデータベースを使用するように、Laravelの.env
ファイルで設定してあります。A
homestead
database
is
configured
for
both
MySQL
and
Postgres
out
of
the
box.
For
even
more
convenience,
Laravel's
.env
file
configures
the
framework
to
use
this
database
out
of
the
box.
MySQLかPostgresデータベースへ、ホストマシンからデータベースクライアントで接続するには、127.0.0.1
の33060
(MySQL)番ポートか、54320
(Postgres)番ポートへ接続してください。ユーザー名とパスワードは、両方共にhomestead
/secret
です。To
connect
to
your
MySQL
or
Postgres
database
from
your
host
machine's
database
client,
you
should
connect
to
127.0.0.1
and
port
33060
(MySQL)
or
54320
(Postgres).
The
username
and
password
for
both
databases
is
homestead
/
secret
.
Note: {note} You should only use these non-standard ports when connecting to the databases from your host machine. You will use the default 3306 and 5432 ports in your Laravel database configuration file since Laravel is running within the virtual machine.
ホストマシンからデータベースへ接続するには、標準的ではないポートだけを使用してください。Laravelのデータベース設定ファイル中では、デフォルトの3306と5432ポートを使用することができます。Laravelは仮想マシンの内部で動作しているからです。
サイトの追加Adding Additional Sites
Homestead環境をプロビジョニングし、実働した後に、LaravelアプリケーションをNginxサイトへ追加したいこともあるでしょう。希望するだけのLaravelアプリケーションを一つのHomestead環境上で実行することができます。新しいサイトを追加するには、Homestead.yaml
ファイルへ追加するだけです。Once
your
Homestead
environment
is
provisioned
and
running,
you
may
want
to
add
additional
Nginx
sites
for
your
Laravel
applications.
You
can
run
as
many
Laravel
installations
as
you
wish
on
a
single
Homestead
environment.
To
add
an
additional
site,
simply
add
the
site
to
your
Homestead.yaml
file:
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: another.app
to: /home/vagrant/Code/another/public
Vagrantが"hosts"ファイルを自動的に管理しない場合は、新しいサイトを追加する必要があります。If Vagrant is not automatically managing your "hosts" file, you may need to add the new site to that file as well:
192.168.10.10 homestead.app
192.168.10.10 another.app
サイトを追加したら、vagrant
reload
--provision
コマンドをHomesteadディレクトリで実行します。Once
the
site
has
been
added,
run
the
vagrant
reload
--provision
command
from
your
Homestead
directory.
サイトタイプSite Types
Laravelベースではないプロジェクトも簡単に実行できるようにするため、Homesteadは様々なタイプのサイトをサポートしています。たとえば、symfony2
サイトタイプを使えば、HomesteadにSymfonyアプリケーションを簡単に追加できます。Homestead
supports
several
types
of
sites
which
allow
you
to
easily
run
projects
that
are
not
based
on
Laravel.
For
example,
we
may
easily
add
a
Symfony
application
to
Homestead
using
the
symfony2
site
type:
sites:
- map: symfony2.app
to: /home/vagrant/Code/Symfony/public
type: symfony2
指定できるサイトタイプはapache
、laravel
(デフォルト)、proxy
、silverstripe
、statamic
、symfony2
、symfony4
です。The
available
site
types
are:
apache
,
laravel
(the
default),
proxy
,
silverstripe
,
statamic
,
symfony2
,
and
symfony4
.
サイトパラメータSite Parameters
params
サイトディレクティブを使用し、Nginxのfastcgi_param
値を追加できます。例として、値にBAR
を持つFOO
パラメータを追加してみましょう。You
may
add
additional
Nginx
fastcgi_param
values
to
your
site
via
the
params
site
directive.
For
example,
we'll
add
a
FOO
parameter
with
a
value
of
BAR
:
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
params:
- key: FOO
value: BAR
Cronスケジュール設定Configuring Cron Schedules
schedule:run
Artisanコマンドだけを毎分実行することにより、Cronジョブのスケジュールを簡単に行う方法をLaravelは提供しています。schedule:run
コマンドはApp\Console\Kernel
クラスの定義を調べ、どのジョブを実行すべきかを決定します。Laravel
provides
a
convenient
way
to
schedule
Cron
jobs[/docs/{{version}}/scheduling]
by
scheduling
a
single
schedule:run
Artisan
command
to
be
run
every
minute.
The
schedule:run
command
will
examine
the
job
schedule
defined
in
your
App\Console\Kernel
class
to
determine
which
jobs
should
be
run.
Homesteadサイトでschedule:run
コマンドを実行したい場合は、サイトを定義するときにschedule
オプションをtrue
に設定してください。If
you
would
like
the
schedule:run
command
to
be
run
for
a
Homestead
site,
you
may
set
the
schedule
option
to
true
when
defining
the
site:
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
schedule: true
こうしたサイト用のCronジョブは、仮想マシンの/etc/cron.d
フォルダーの中に定義されます。The
Cron
job
for
the
site
will
be
defined
in
the
/etc/cron.d
folder
of
the
virtual
machine.
ポートPorts
以下のポートが、Homestead環境へポートフォワードされています。By default, the following ports are forwarded to your Homestead environment:
- SSH: 2222 → フォワード先 22SSH: 2222 → Forwards To 22
- HTTP: 8000 → フォワード先 80HTTP: 8000 → Forwards To 80
- HTTPS: 44300 → フォワード先 443HTTPS: 44300 → Forwards To 443
- MySQL: 33060 → フォワード先 3306MySQL: 33060 → Forwards To 3306
- Postgres: 54320 → フォワード先 5432Postgres: 54320 → Forwards To 5432
- Mailhog: 8025 → フォワード先 8025Mailhog: 8025 → Forwards To 8025
追加のフォワードポートForwarding Additional Ports
ご希望ならば追加のポートをVagrant Boxへフォワードすることもできます。プロトコルを指定することもできます。If you wish, you may forward additional ports to the Vagrant box, as well as specify their protocol:
ports:
- send: 50000
to: 5000
- send: 7777
to: 777
protocol: udp
環境の共有Sharing Your Environment
共同作業者やクライアントと、現在作業中の内容を共有したい場合もあるでしょう。Vagrantには、vagrant
share
により、これをサポートする方法が組み込み済みです。しかし、この方法はHomestead.yaml
ファイルに複数サイトを設定している場合には動作しません。Sometimes
you
may
wish
to
share
what
you're
currently
working
on
with
coworkers
or
a
client.
Vagrant
has
a
built-in
way
to
support
this
via
vagrant
share
;
however,
this
will
not
work
if
you
have
multiple
sites
configured
in
your
Homestead.yaml
file.
この問題を解決するため、Homesteadは独自のshare
コマンドを持っています。使用を開始するには、vagrant
ssh
によりHomesteadマシンとSSH接続し、share
homestead.app
を実行してください。これにより、Homestead.yaml
設定ファイルのhomestead.app
サイトが共有されます。もちろん、homestead.app
の代わりに他の設定済みサイトを指定できます。To
solve
this
problem,
Homestead
includes
its
own
share
command.
To
get
started,
SSH
into
your
Homestead
machine
via
vagrant
ssh
and
run
share
homestead.app
.
This
will
share
the
homestead.app
site
from
your
Homestead.yaml
configuration
file.
Of
course,
you
may
substitute
any
of
your
other
configured
sites
for
homestead.app
:
share homestead.app
コマンド実行後、ログと共有サイトへアクセスするURLを含んだ、Ngrokスクリーンが現れます。カスタムリージョン、サブドメイン、その他のNgrok実行オプションをカスタマイズしたい場合は、share
コマンドへ追加してください。After
running
the
command,
you
will
see
an
Ngrok
screen
appear
which
contains
the
activity
log
and
the
publicly
accessible
URLs
for
the
shared
site.
If
you
would
like
to
specify
a
custom
region,
subdomain,
or
other
Ngrok
runtime
option,
you
may
add
them
to
your
share
command:
share homestead.app -region=eu -subdomain=laravel
Note:
Vagrantは本質的に安全なものではなく、share
コマンドによりインターネット上に自分の仮想マシンを晒すことになることを覚えておいてください。{note} Remember, Vagrant is inherently insecure and you are exposing your virtual machine to the Internet when running theshare
command.
複数のPHPバージョンMultiple PHP Versions
Note: {note} This feature is only compatible with Nginx.
この機能は、Nginx使用時のみ利用できます。
Homestead6から、同一仮想マシン上での複数PHPバージョンをサポートを開始しました。Homestead.yaml
ファイルで、特定のサイトでどのバージョンのPHPを使用するのかを指定できます。利用できるPHPバージョンは、"5.6"、"7.0"、"7.1"です。Homestead
6
introduced
support
for
multiple
versions
of
PHP
on
the
same
virtual
machine.
You
may
specify
which
version
of
PHP
to
use
for
a
given
site
within
your
Homestead.yaml
file.
The
available
PHP
versions
are:
"5.6",
"7.0",
and
"7.1":
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
php: "5.6"
さらに、コマンドラインではサポート済みPHPバージョンをすべて利用できます。In addition, you may use any of the supported PHP versions via the CLI:
php5.6 artisan list
php7.0 artisan list
php7.1 artisan list
ネットワークインターフェイスNetwork Interfaces
Homestead.yaml
ファイルのnetwork
プロパティは、Homestead環境のネットワークインターフェイスを設定します。多くのインターフェイスを必要に応じ設定可能です。The
networks
property
of
the
Homestead.yaml
configures
network
interfaces
for
your
Homestead
environment.
You
may
configure
as
many
interfaces
as
necessary:
networks:
- type: "private_network"
ip: "192.168.10.20"
ブリッジインターフェイスを有効にするには、bridge
項目を設定し、ネットワークタイプをpublic_network
へ変更します。To
enable
a
bridged[https://www.vagrantup.com/docs/networking/public_network.html]
interface,
configure
a
bridge
setting
and
change
the
network
type
to
public_network
:
networks:
- type: "public_network"
ip: "192.168.10.20"
bridge: "en1: Wi-Fi (AirPort)"
DHCPを有効にするには、設定からip
オプションを取り除いてください。To
enable
DHCP[https://www.vagrantup.com/docs/networking/public_network.html],
just
remove
the
ip
option
from
your
configuration:
networks:
- type: "public_network"
bridge: "en1: Wi-Fi (AirPort)"
Homesteadの更新Updating Homestead
2つの簡単な手順で、Homesteadをアップデートできます。最初にvagrant
box
update
コマンドを使い、Vagrant
boxを更新してください。You
can
update
Homestead
in
two
simple
steps.
First,
you
should
update
the
Vagrant
box
using
the
vagrant
box
update
command:
vagrant box update
次に、Homesteadのソースコードを更新する必要があります。リポジトリをクローンしている場合は、リポジトリをクローンしたもともとの場所で、git
pull
origin
master
を単に実行するするだけです。Next,
you
need
to
update
the
Homestead
source
code.
If
you
cloned
the
repository
you
can
simply
git
pull
origin
master
at
the
location
you
originally
cloned
the
repository.
composer.json
ファイルにより、Homesteadをインストールしている場合は、composer.json
ファイルに"laravel/homestead":
"^4"
が含まれていることを確認し、依存パッケージを更新してください。If
you
have
installed
Homestead
via
your
project's
composer.json
file,
you
should
ensure
your
composer.json
file
contains
"laravel/homestead":
"^4"
and
update
your
dependencies:
composer update
旧バージョンOld Versions
複数PHPバージョンのドキュメントを確認してください。{tip} If you need an older version of PHP check the documentation on multiple PHP versions[#multiple-php-versions] before attempting to use an old version of Homestead.
">Tip!! 古いバージョンのPHPを使用したい場合は、Homesteadの古いバージョンを試して見る前に、
Homestead.yaml
ファイルに以下の行を付け加えることで、Homesteadが使用するboxのバージョンを簡単にオーバーライドできます。You
can
easily
override
the
version
of
the
box
that
Homestead
uses
by
adding
the
following
line
to
your
Homestead.yaml
file:
version: 0.6.0
一例:An example:
box: laravel/homestead
version: 0.6.0
ip: "192.168.20.20"
memory: 2048
cpus: 4
provider: virtualbox
古いバージョンのHomestead boxを使用する場合は、互換性のあるバージョンのHomesteadソースコードへ合わせる必要があります。下図はサポートされているboxのバージョンを表し、使用すべきHomesteadソースコードのバージョンとPHPバージョンです。When you use an older version of the Homestead box you need to match that with a compatible version of the Homestead source code. Below is a chart which shows the supported box versions, which version of Homestead source code to use, and the version of PHP provided:
HomesteadバージョンHomestead Version | BoxバージョンBox Version | |
---|---|---|
PHP 7.0PHP 7.0 | 3.1.03.1.0 | 0.6.00.6.0 |
PHP 7.1PHP 7.1 | 4.0.04.0.0 | 1.0.01.0.0 |
プロパイダ固有の設定Provider Specific Settings
VirtualBoxVirtualBox
デフォルトのHomestead設定は、natdnshostresolver
設定をon
にしています。これにより、HomesteadはホストのオペレーティングシステムのDNS設定を利用します。この動作をオーバーライドしたい場合は、Homestead.yaml
へ以下の行を追加してください。By
default,
Homestead
configures
the
natdnshostresolver
setting
to
on
.
This
allows
Homestead
to
use
your
host
operating
system's
DNS
settings.
If
you
would
like
to
override
this
behavior,
add
the
following
lines
to
your
Homestead.yaml
file:
provider: virtualbox
natdnshostresolver: off