イントロダクション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やPHP、MySQL、PostgreSQL、Redis、Memcached、Node、他にも素晴らしいLaravelアプリケーションを開発するために必要となるものすべてを含んでいます。Homestead runs on any Windows, Mac, or Linux system, and includes Nginx, PHP, MySQL, PostgreSQL, 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
オプションのソフトウェアOptional Software
インストールと設定Installation & Setup
最初の段階First Steps
Homestead環境を起動する前にVagrantと共に、VirtualBox 6.xか、VMWare、Parallels、Hyper-Vをインストールする必要があります。全ソフトウェア共に簡単に使用できるビジュアルインストーラが、人気のあるオペレーティングシステムすべてに用意されています。Before launching your Homestead environment, you must install VirtualBox 6.x[https://www.virtualbox.org/wiki/Downloads], VMWare[https://www.vmware.com], Parallels[https://www.parallels.com/products/desktop/] or Hyper-V[https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v] 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.
Vagrantの制限のため、Hyper-Vプロバイダはすべてのネットワーク設定を無視します。Because of Vagrant limitations[https://www.vagrantup.com/docs/hyperv/limitations.html], The Hyper-V provider ignores all networking settings.
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.
Note:
Homesteadは定期的に「アルファ版/ベータ版」Boxをテストのためリリースしています。これはvagrant box add
コマンドと干渉してしまいます。vagrant box add
の実行で問題が起きたら、vagrant up
コマンドを実行し、Vagrantが仮想マシンを開始する時点で正しいBoxをダウンロードしてください。{note} Homestead periodically issues "alpha" / "beta" boxes for testing, which may interfere with thevagrant box add
command. If you are having issues runningvagrant box add
, you may run thevagrant up
command and the correct box will be downloaded when Vagrant attempts to start the virtual machine.
HomesteadのインストールInstalling Homestead
ホストマシンへリポジトリをクローンし、Homesteadをインストールできます。自分の「ホーム」ディレクトリの中のHomestead
フォルダへリポジトリをクローンするのことは、自分のLaravel(とPHP)の全プロジェクトをホストしておくHomestead
Boxを用意するのだと考えてください。You may
install Homestead by cloning the repository onto
your host machine. 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:
git clone https://github.com/laravel/homestead.git ~/Homestead
master
ブランチは常に安定しているわけではないため、バージョンタグがついたHomesteadをチェックアウトすべきでしょう。最新の安定バージョンは、GitHubのリリースページで見つかります。もしくは、常に最新の安定バージョンを用意しているrelease
ブランチをチェックアウトしてください。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].
Alternatively, you may checkout the
release
branch which always contains
the latest stable release:
cd ~/Homestead
git checkout release
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
、hyperv
のどれを使用するかを指定します。使用するプロバイダの値を指定してください。The provider
key in
your Homestead.yaml
file indicates
which Vagrant provider should be used:
virtualbox
, vmware_fusion
,
vmware_workstation
,
parallels
or hyperv
. 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/project1
to: /home/vagrant/project1
Note:
Windowsユーザーはパスを~/
記法を使わず、代わりにたとえばC:\Users\user\Code\project1
のように、プロジェクトのフルパスを使ってください。{note} Windows users should not use the~/
path syntax and instead should use the full path to their project, such asC:\Users\user\Code\project1
.
~/code
フォルダへ常に個別プロジェクトをマップする代わりに、別々にマップすべきでしょう。仮想マシンへあるフォルダをマップすると、そのフォルダ中のすべてのファイルによるディスクIOをトラックし続けます。これにより、フォルダの中に莫大なファイルが存在する場合に、パフォーマンスの問題が起きます。You should always map individual
projects to their own folder mapping instead of
mapping your entire ~/code
folder. When
you map a folder the virtual machine must keep track
of all disk IO for every file in the
folder. This leads to performance issues if you have
a large number of files in a folder.
folders:
- map: ~/code/project1
to: /home/vagrant/project1
- map: ~/code/project2
to: /home/vagrant/project2
Note:
Homesteadを使用する場合、.
(カレントディレクトリ)をマウントしないでください。そうすると、Vagrantはカレントフォルダを/vagrant
へマップしない状況が起き、オプションの機能が壊れ、プロビジョン中に予期せぬ結果が起きます。{note} You should never mount.
(the current directory) when using Homestead. This causes Vagrant to not map the current folder to/vagrant
and will break optional features and cause unexpected results while provisioning.
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/project1
to: /home/vagrant/project1
type: "nfs"
Note: vagrant-winnfsdプラグインのインストールを考慮してください。このプラグインは、Homestead下のファイルとディレクトリのユーザー/グループパーミッションを正しく維持します。{note} When using NFS on Windows, you should consider installing the vagrant-winnfsd[https://github.com/winnfsd/vagrant-winnfsd] plug-in. This plug-in will maintain the correct user / group permissions for files and directories within the Homestead box.
Windows上で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/project1
to: /home/vagrant/project1
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.test
to: /home/vagrant/project1/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.
Note:
Homesteadのスクリプトは可能な限り冪等性を保つように組まれています。しかしながら、プロビジョニング中に問題が起きたら、vagrant destroy && vagrant up
によりマシンを壊し、再構築してください。{note} Homestead scripts are built to be as idempotent as possible. However, if you are experiencing issues while provisioning you should destroy and rebuild the machine viavagrant destroy && vagrant up
.
ホスト名の解決Hostname Resolution
Homesteadでは自動的にホストを解決できるように、mDNS
によりホスト名を公開しています。Homestead.yaml
ファイルで、hostname:
homestead
とセットすれば、このホストはhomestead.local
で使用できます。macOS、iOS、LinuxディストリビューションではmDNS
がデフォルトでサポートされています。Windowsでは、Bonjour
Print Services for Windowsをインストールする必要があります。Homestead publishes hostnames
over mDNS
for automatic host
resolution. If you set hostname:
homestead
in your
Homestead.yaml
file, the host will be
available at homestead.local
. MacOS,
iOS, and Linux desktop distributions include
mDNS
support by default. Windows
requires installing Bonjour Print Services for
Windows[https://support.apple.com/kb/DL999?viewlocale=en_US&locale=en_US].
自動ホスト名を一番活用できるのは、Homesteadを「プロジェクトごと」にインストールした場合でしょう。もし、一つのHomesteadインスタンスで複数のサイトをホストしている場合は、hosts
ファイルにWebサイトの「ドメイン」を追加してください。hosts
ファイルはHomesteadへのリクエストをHomestead環境へ転送してくれます。MacとLinuxでは、/etc/hosts
にこのファイルがあります。Windows環境では、C:\Windows\System32\drivers\etc\hosts
です。次の行のように追加してください。Using automatic hostnames works
best for "per project" installations of
Homestead. If you host multiple sites on a single
Homestead instance, you may add the
"domains" for your web 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.test
設定する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.test
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 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.test
のプロジェクトへアクセスしてください。自動ホスト名解決を使わない場合は、/etc/hosts
ファイルにhomestead.test
か、自分で選んだドメインのエントリーを追加する必要があることを忘れないでください。Next, run the vagrant
up
command in your terminal and access
your project at http://homestead.test
in your browser. Remember, you will still need to
add an /etc/hosts
file entry for
homestead.test
or the domain of your
choice if you are not using automatic hostname
resolution[#hostname-resolution].
オプション機能のインストールInstalling Optional Features
オプションのソフトウェアは、Homestead設定ファイルの"features"設定を用い、インストールします。ほとんどの機能は論理値により有効/無効を指定できます。いくつかの機能では複数のオプションができます。Optional software is installed using the "features" setting in your Homestead configuration file. Most features can be enabled or disabled with a boolean value, while some features allow multiple configuration options:
features:
- blackfire:
server_id: "server_id"
server_token: "server_value"
client_id: "client_id"
client_token: "client_value"
- cassandra: true
- chronograf: true
- couchdb: true
- crystal: true
- docker: true
- elasticsearch:
version: 7
- gearman: true
- golang: true
- grafana: true
- influxdb: true
- mariadb: true
- minio: true
- mongodb: true
- mysql8: true
- neo4j: true
- ohmyzsh: true
- openresty: true
- pm2: true
- python: true
- rabbitmq: true
- solr: true
- webdriver: true
MariaDBMariaDB
MariaDBを有効にすると、MySQLを削除してMariaDBをインストールします。MariaDBはMySQLのそのまま置き換え可能な代替機能として動作します。そのため、アプリケーションのデータベース設定では、mysql
データベースドライバをそのまま使ってください。Enabling MariaDB 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.
MongoDBMongoDB
デフォルト状態のMongoDBでは、データベースのユーザー名をhomestead
、パスワードをsecret
に設定します。The default MongoDB installation
will set the database username to
homestead
and the corresponding
password to secret
.
ElasticsearchElasticsearch
デフォルトのインストールでは、homestead
という名前のクラスタが作成されます。Elasticsearchにオペレーティングシステムのメモリの半分以上を割り当ててはいけません。つまり、Elasticsearchに割り当てる量の最低でも2倍以上のメモリをHomesteadマシンに割り当てます。You may specify a supported
version of Elasticsearch, which may be a major
version or an exact version number
(major.minor.patch). The default installation will
create a cluster named 'homestead'. You should never
give Elasticsearch more than half of the operating
system's memory, so make sure your Homestead machine
has at least twice the Elasticsearch
allocation.
Elasticsearchのドキュメントを確認してください。{tip} Check out the Elasticsearch documentation[https://www.elastic.co/guide/en/elasticsearch/reference/current] to learn how to customize your configuration.
">Tip!! 設定のカスタマイズについては、
Neo4jNeo4j
デフォルト状態のNeo4jでは、データベースのユーザー名をhomestead
、パスワードをsecret
として設定します。Neo4jブラウザにアクセスするには、Webブラウザでhttp://homestead.test:7474
にアクセスしてください。Neo4jクライアントのために、7687
(Bolt)、7474
(HTTP)、7473
(HTTPS)ポートが用意されています。The default Neo4j
installation will set the database username to
homestead
and corresponding password to
secret
. To access the Neo4j browser, visit
http://homestead.test:7474
via your web
browser. The ports 7687
(Bolt),
7474
(HTTP), and 7473
(HTTPS) are
ready to serve requests from the Neo4j client.
エイリアスAliases
HomesteadでBashのエイリアスを指定するには、Homesteadディレクトリにある
aliases
ファイルを編集します。You may
add Bash aliases to your Homestead machine by modifying the
aliases
file within your Homestead
directory:
alias c='clear'
alias ..='cd ..'
aliases
ファイルを更新した後に、vagrant reload
--provision
コマンドを使い、Homesteadを再度プロヴィジョニングする必要があります。これにより新しいエイリアスを使うことができます。After you have updated the
aliases
file, you should re-provision the
Homestead machine using the vagrant reload
--provision
command. This will ensure that your
new aliases are available on the machine.
使用方法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とPostgreSQLの両方を設定できます。ホストマシンのデータベースクライアントから、MySQLかPostgreSQLデータベースへ接続するには、127.0.0.1
のポート33060
(MySQL)か、ポート54320
(PostgreSQL)へ接続する必要があります。ユーザー名はhomestead
、パスワードはsecret
です。A homestead
database is
configured for both MySQL and PostgreSQL out of the box. To
connect to your MySQL or PostgreSQL database from your host
machine's database client, you should connect to
127.0.0.1
and port 33060
(MySQL)
or 54320
(PostgreSQL). 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は仮想マシンの内部で動作しているからです。
データベースのバックアップDatabase Backups
Homesteadでは、Vagrant
boxを壊した時点で、自動的にデータベースをバックアップできます。この機能を利用するには、Vagrant2.1.0以上を使用しなくてはなりません。もしくは、古いバージョンのVagrantを使用している場合は、vagrant-triggers
プラグインをインストールしてください。自動データベースバックアップを有効にするには、Homestead.yaml
ファイルに以下の行を追加してください。Homestead can automatically backup your
database when your Vagrant box is destroyed. To utilize this
feature, you must be using Vagrant 2.1.0 or greater. Or, if
you are using an older version of Vagrant, you must install
the vagrant-triggers
plug-in. To enable
automatic database backups, add the following line to your
Homestead.yaml
file:
backup: true
一度設定すれば、Homesteadはvagrant
destroy
コマンドが実行されると、データベースをmysql_backup
、postgres_backup
ディレクトリへエクスポートします。これらのディレクトリは、Homesteadをクローンしたフォルダ中、もしくはプロジェクトごとのインストールを利用している場合は、プロジェクトルートの中で見つけられます。Once configured, Homestead will export
your databases to mysql_backup
and
postgres_backup
directories when the
vagrant destroy
command is executed. These
directories can be found in the folder where you cloned
Homestead or in the root of your project if you are using
the per project
installation[#per-project-installation]
method.
データベーススナップショットDatabase Snapshots
Homesteadでは、MySQLやMariaDBの状態をスナップショットし、Logical MySQL Managerを使いブランチ操作可能です。たとえば、複数のギガバイトデータベースに関わるサイトをイメージしてください。データベースをインポートし、スナップショットを取ります。何か操作し、ローカルにテスト状況を構築した後に、元の状態へ素早くリストアできるのです。Homestead supports freezing the state of MySQL and MariaDB databases and branching between them using Logical MySQL Manager[https://github.com/Lullabot/lmm]. For example, imagine working on a site with a multi-gigabyte database. You can import the database and take a snapshot. After doing some work and creating some test content locally, you may quickly restore back to the original state.
内部では、LVMのコピーオンライト(COW)サポートによる、簡単なスナップショット機能をLMMは使用しています。実践上これが意味するのは、テーブルのある一行を更新すると、その変更はディスクに書き込まれるだけであり、リストア時に大変な時間とディスクスペースを省略できるということです。Under the hood, LMM uses LVM's thin snapshot functionality with copy-on-write support. In practice, this means that changing a single row in a table will only cause the changes you made to be written to disk, saving significant time and disk space during restores.
lmm
はLVMを操作するため、root
で実行する必要があります。実行可能なコマンドを確認するには、Vagrant
Box内でsudo
lmm
を実行してください。コマンドのワークフローは次のようになるでしょう。Since lmm
interacts with
LVM, it must be run as root
. To see all
available commands, run sudo lmm
inside your
Vagrant box. A common workflow looks like the
following:
- デフォルトの
master
lmmブランチへデータベースをインポートする。Import a database into the defaultmaster
lmm branch. - 無変更状態のデータベーススナップショットを
sudo lmm branch prod-YYYY-MM-DD
で保存する。Save a snapshot of the unchanged database usingsudo lmm branch prod-YYYY-MM-DD
. - データベースを変更する。Modify the database.
sudo lmm merge prod-YYYY-MM-DD
を実行し、すべての変更を元に戻す。Runsudo lmm merge prod-YYYY-MM-DD
to undo all changes.sudo lmm delete <branch>
で、不必要なブランチを削除する。Runsudo lmm delete <branch>
to delete unneeded branches.
サイトの追加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,
add the site to your
Homestead.yaml
file:
sites:
- map: homestead.test
to: /home/vagrant/project1/public
- map: another.test
to: /home/vagrant/project2/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.test
192.168.10.10 another.test
サイトを追加したら、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.test
to: /home/vagrant/my-symfony-project/web
type: "symfony2"
指定できるサイトタイプはapache
、apigility
、expressive
、laravel
(デフォルト)、proxy
、silverstripe
、statamic
、symfony2
、symfony4
、zf
です。The available site
types are: apache
,
apigility
,
expressive
,
laravel
(the default),
proxy
,
silverstripe
,
statamic
,
symfony2
,
symfony4
, and
zf
.
サイトパラメータ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.test
to: /home/vagrant/project1/public
params:
- key: FOO
value: BAR
環境変数Environment Variables
グローバルな環境変数は、Homestead.yaml
ファイルで追加指定できます。You can set global
environment variables by adding them to
your Homestead.yaml
file:
variables:
- key: APP_ENV
value: local
- key: FOO
value: bar
Homestead.yaml
を変更したら、vagrant
reload
--provision
を実行し、再プロビジョンするのを忘れないでください。これにより全インストール済みPHPバージョンに対するPHP-FPM設定と、vagrant
ユーザーの環境も更新されます。After updating the
Homestead.yaml
, be sure to
re-provision the machine by running
vagrant reload --provision
.
This will update the PHP-FPM
configuration for all of the installed
PHP versions and also update the
environment for the vagrant
user.
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.test
to: /home/vagrant/project1/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.
Mailhogの設定Configuring Mailhog
Mailhogを使用すると、簡単に送信するメールを捉えることができ、受信者へ実際に届けなくとも内容を調べることができます。これを使用するには、.env
ファイルのメール設定を以下のように更新します。Mailhog allows you to
easily catch your outgoing email and
examine it without actually sending the
mail to its recipients. To get started,
update your .env
file to
use the following mail
settings:
MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Mailhogを設定したら、ダッシュボードへhttp://localhost:8025
でアクセスできます。Once Mailhog has been
configured, you may access the Mailhog
dashboard at
http://localhost:8025
.
Minioの設定Configuring Minio
MinioはAmazon
S3と互換性のあるAPIを持つ、オープンソースなオブジェクトストレージサーバです。Minioをインストールするには、Homestead.yaml
に機能のセクション中から以下の設定オプションを加えてください。Minio is an open
source object storage server with an
Amazon S3 compatible API. To install
Minio, update your
Homestead.yaml
file with
the following configuration option in
the
features[#installing-optional-features]
section:
minio: true
デフォルトのMinioは、9600ポートで使用します。http://localhost:9600/
を閲覧すると、Minioのコントロールパネルへアクセスできます。デフォルトアクセスキーはhomestead
、デフォルトのシークレットキーはsecretkey
です。Minioへアクセスする場合、常にリージョンus-east-1
を使用する必要があります。By default, Minio is
available on port 9600. You may access
the Minio control panel by visiting
http://localhost:9600/
. The
default access key is
homestead
, while the
default secret key is
secretkey
. When accessing
Minio, you should always use region
us-east-1
.
Minioを使用するために、config/filesystems.php
設定ファイルの中の、S3ディスク設定を調整する必要があります。ディスク設定へ、use_path_style_endpoint
オプションを追加し、同時にurl
キーをendpoint
へ変更する必要があります。In order to use Minio
you will need to adjust the S3 disk
configuration in your
config/filesystems.php
configuration file. You will need to add
the use_path_style_endpoint
option to the disk configuration, as
well as change the url
key
to endpoint
:
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'endpoint' => env('AWS_URL'),
'use_path_style_endpoint' => true
]
最後に、.env
ファイルへ以下のオプションを確実に用意してください。Finally, ensure your
.env
file has the following
options:
AWS_ACCESS_KEY_ID=homestead
AWS_SECRET_ACCESS_KEY=secretkey
AWS_DEFAULT_REGION=us-east-1
AWS_URL=http://localhost:9600
バケットをセットアップするには、Homestead設定ファイルにbuckets
ディレクティブを追加してください。To provision buckets,
add a buckets
directive to
your Homestead configuration
file:
buckets:
- name: your-bucket
policy: public
- name: your-private-bucket
policy: none
サポートしているpolicy
の値は、none
、download
、upload
、public
です。Supported
policy
values include:
none
,
download
,
upload
, and
public
.
ポートPorts
以下のポートが、Homestead環境へポートフォワードされています。By default, the following ports are forwarded to your Homestead environment:
追加のフォワードポート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.test
を実行してください。これにより、Homestead.yaml
設定ファイルのhomestead.test
サイトが共有されます。homestead.test
の代わりに他の設定済みサイトを指定できます。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.test
. This
will share the
homestead.test
site from
your Homestead.yaml
configuration file. You may substitute
any of your other configured sites for
homestead.test
:
share homestead.test
コマンド実行後、ログと共有サイトへアクセスする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.test -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
Homestead6から、同一仮想マシン上での複数PHPバージョンをサポートを開始しました。Homestead.yaml
ファイルで、特定のサイトでどのバージョンのPHPを使用するのかを指定できます。利用できるPHPバージョンは、"5.6"、"7.0"、"7.1"、"7.2"、"7.3"、"7.4(デフォルト)"です。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",
"7.1", "7.2",
"7.3", and "7.4"
(the default):
sites:
- map: homestead.test
to: /home/vagrant/project1/public
php: "7.1"
さらに、コマンドラインではサポート済み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
php7.2 artisan list
php7.3 artisan list
php7.4 artisan list
Homestead仮想マシンの中で、以下のコマンドを実行することにより、デフォルトCLIバージョンを変更することも可能です。You may also update the default CLI version by issuing the following commands from within your Homestead virtual machine:
php56
php70
php71
php72
php73
php74
WebサービスWeb Servers
HomesteadはNginxをデフォルトのWebサーバとして利用しています。しかし、サイトタイプとしてapache
が指定されると、Apacheをインストールします。両方のWebサーバを一度にインストールすることもできますが、同時に両方を実行することはできません。flip
シェルコマンドがWebサーバを切り替えるために用意されています。flip
コマンドはどちらのWebサーバが実行中かを自動的に判断し、シャットダウンし、もう一方のWebサーバを起動します。このコマンドを実行するには、HomesteadへSSH接続し、コマンドをターミナルで実行してください。Homestead uses the
Nginx web server by default. However, it
can install Apache if
apache
is specified as a
site type. While both web servers can be
installed at the same time, they cannot
both be running at the same
time. The flip
shell
command is available to ease the process
of switching between web servers. The
flip
command automatically
determines which web server is running,
shuts it off, and then starts the other
server. To use this command, SSH into
your Homestead machine and run the
command in your terminal:
flip
MailMail
Homesteadは、デフォルトで1025
ポートをリッスンする、Postfixメールトランスファーエージェントを用意しています。そのため、localhost
の1025
ポートに対して、smtp
メールドライバーを使用するように、アプリケーションへ指示できます。その結果、すべての送信メールはPostfixにより処理され、Mailhogにより補足されます。送信済みメールを確認するには、Webブラウザでhttp://localhost:8025を開いてください。Homestead includes
the Postfix mail transfer agent, which
is listening on port 1025
by default. So, you may instruct your
application to use the smtp
mail driver on localhost
port 1025
. Then, all sent
mail will be handled by Postfix and
caught by Mailhog. To view your sent
emails, open
http://localhost:8025[http://localhost:8025]
in your web browser.
デバッグとプロファイリングDebugging & Profiling
XdebugによるWebリクエストのデバッグDebugging Web Requests With Xdebug
HomesteadはXdebugを使用するステップデバッグをサポートしています。たとえば、ブラウザからWebページをロードし、実行中のコードのインスペクションと変更ができるようにPHPをIDEに接続します。Homestead includes support for step debugging using Xdebug[https://xdebug.org]. For example, you can load a web page from a browser, and PHP will connect to your IDE to allow inspection and modification of the running code.
デフォルトでXdebugは実行されており、接続を待っています。CLIでXdebugを有効にする必要があれば、Vagrant
boxの中でsudo phpenmod
xdebug
コマンドを実行してください。次に、IDEのインストラクションにしたがい、デバッギングを有効にします。最後に、ブラウザでXdebugを起動する拡張か、bookmarkletを設定してください。By default Xdebug is
already running and ready to accept
connections. If you need to enable
Xdebug on the CLI run the sudo
phpenmod xdebug
command
within your Vagrant box. Next, follow
your IDE's instructions to enable
debugging. Finally, configure your
browser to trigger Xdebug with an
extension or
bookmarklet[https://www.jetbrains.com/phpstorm/marklets/].
Note:
XdebugはPHPの実行を極端に遅くしてしまいます。Xdebugを無効にするには、Vagrant Boxでsudo phpdismod xdebug
を実行し、FPMサービスを再起動します。{note} Xdebug causes PHP to run significantly slower. To disable Xdebug, runsudo phpdismod xdebug
within your Vagrant box and restart the FPM service.
CLIアプリケーションのデバッグDebugging CLI Applications
PHP CLIアプリケーションをデバッグするには、Vagrant
Box内で、xphp
シェルエイリアスを使用してください。To debug a PHP CLI
application, use the xphp
shell alias inside your Vagrant
box:
xphp path/to/script
Xdebugの自動スタートAutostarting Xdebug
Webサーバへのリクエストを生成する機能テストのデバッグの場合、デバッグを開始するためにカスタムヘッダやクッキーを付与するようにテストを変更するよりは、自動的に起動するほうが簡単です。Xdebugを自動的に起動するよう強制するには、Vagrant
Boxの中で以下のように/etc/php/7.x/fpm/conf.d/20-xdebug.ini
を変更してください。When debugging
functional tests that make requests to
the web server, it is easier to
autostart debugging rather than
modifying tests to pass through a custom
header or cookie to trigger debugging.
To force Xdebug to start automatically,
modify
/etc/php/7.x/fpm/conf.d/20-xdebug.ini
inside your Vagrant box and add the
following configuration:
; Homestead.yamlで別のIPアドレスのサブセットを指定している場合は、このアドレスを合わせてください
xdebug.remote_host = 192.168.10.1
xdebug.remote_autostart = 1
BlackfireによるアプリケーションプロファイリングProfiling Applications with Blackfire
BlackfireはWebリクエストとCLIアプリケーションのプロファイリングと、パフォーマンスアサーションの記述を提供するSaaSサービスです。プロファイルデーターをコールグラフとタイムラインで表示するユーザーインターフェイスを提供しています。エンドユーザーにオーバーヘッドをかけずに、開発/ステージング/実働環境で使用できるように構築されています。コードとphp.ini
に対するパフォーマンスと品質、安全性のチェックを提供しています。Blackfire[https://blackfire.io/docs/introduction]
is a SaaS service for profiling web
requests and CLI applications and
writing performance assertions. It
offers an interactive user interface
which displays profile data in
call-graphs and timelines. It is built
for use in development, staging, and
production, with no overhead for end
users. It provides performance, quality,
and security checks on code and
php.ini
configuration
settings.
Blackfire PlayerはBlackfireでプロファイルシナリオを書くために使用する、オープンソースのWebクローリング/テスト/スクラッピングアプリケーションです。The Blackfire Player[https://blackfire.io/docs/player/index] is an open-source Web Crawling, Web Testing and Web Scraping application which can work jointly with Blackfire in order to script profiling scenarios.
Blackfireを有効にするためには、Homestead設定ファイルの"features"設定を使います。To enable Blackfire, use the "features" setting in your Homestead configuration file:
features:
- blackfire:
server_id: "server_id"
server_token: "server_value"
client_id: "client_id"
client_token: "client_value"
Blackfireサーバ設定項目とクライアント設定項目には、ユーザーアカウントが必要です。BlackfireはCLIツールやブラウザー拡張を含んだ、アプリケーションのプロファイルに使用するさまざまなオプションを用意しています。詳細についてはBlackfireのドキュメントをご覧ください。Blackfire server credentials and client credentials require a user account[https://blackfire.io/signup]. Blackfire offers various options to profile an application, including a CLI tool and browser extension. Please review the Blackfire documentation for more details[https://blackfire.io/docs/cookbooks/index].
XHGuiを使用した、PHPパフォーマンスのプロファイリングProfiling PHP Performance Using XHGui
XHGuiはPHPアプリケーションのパフォーマンスを表示してくれるユーザーインターフェイスです。XHGuiを有効にするには、サイト設定にxhgui:
'true'
を追加してください。XHGui[https://www.github.com/perftools/xhgui]
is a user interface for exploring the
performance of your PHP applications. To
enable XHGui, add xhgui:
'true'
to your site
configuration:
sites:
-
map: your-site.test
to: /home/vagrant/your-site/public
type: "apache"
xhgui: 'true'
サイトがすでに存在する場合は、設定を更新した後にvagrant
provision
を必ず実行してください。If the site already
exists, make sure to run vagrant
provision
after updating your
configuration.
Webリクエストをプロファイルするには、リクエストのクエリパラメータにxhgui=on
を付加してください。XHGuiは以降のリクエストでこのクエリリクエスト値を付ける必要がないように、リクエストへ自動的にクッキーを追加します。アプリケーションのプロファイル結果を見るには、http://your-site.test/xhgui
をブラウザで開いてください。To profile a web
request, add xhgui=on
as a
query parameter to a request. XHGui will
automatically attach a cookie to the
response so that subsequent requests do
not need the query string value. You may
view your application profile results by
browsing to
http://your-site.test/xhgui
.
XHGuiを使用してCLIリクエストのプロファイルを取る場合は、コマンドの前にXHGUI=on
を付けてください。To profile a CLI
request using XHGui, prefix the command
with XHGUI=on
:
XHGUI=on path/to/script
CLIプロファイル結果は、Webのプロファイル結果と同じ方法で確認できます。CLI profile results may be viewed in the same way as web profile results.
プロファイルはスクリプトの実行を低下させるため、実際のリクエストの2倍ほどの実時間になることへ注意しましょう。そのため、実際の数字ではなく、常に向上パーセンテージで比較してください。また、デバッガで中断している時間も実行時間に含まれることを認識しておきましょう。Note that the act of profiling slows down script execution, and absolute times may be as much as twice as real-world requests. Therefore, always compare percentage improvements and not absolute numbers. Also, be aware the execution time includes any time spent paused in a debugger.
パフォーマンスのプロファイルは非常にディスクスペースを喰うため、数日で自動的に削除されます。Since performance profiles take up significant disk space, they are deleted automatically after a few days.
ネットワークインターフェイス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の拡張Extending Homestead
Homesteadのルートディレクトリにある、after.sh
スクリプトを使用し、Homesteadを拡張できます。このファイルの中へ、適切な設定や仮想マシンのカスタマイズに必要なシェルコマンドを追加してください。You may extend
Homestead using the
after.sh
script in the root
of your Homestead directory. Within this
file, you may add any shell commands
that are necessary to properly configure
and customize your virtual
machine.
Homesteadをカスタマイズすると、Ubuntuはパッケージのオリジナル設定をそのままにするか、それとも新しい設定ファイルでオーバーライドするかを尋ねます。これを停止するには、Homesteadにより事前に記述された設定の上書きをパッケージインストール時に無視するように、以下のコマンドを使用してください。When customizing Homestead, Ubuntu may ask you if you would like to keep a package's original configuration or overwrite it with a new configuration file. To avoid this, you should use the following command when installing packages to avoid overwriting any configuration previously written by Homestead:
sudo apt-get -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
install your-package
ユーザーによるカスタマイズUser Customizations
チームの設定でHomesteadを使用している場合でも、自分の個人的な開発スタイルに合うようにHomesteadを調整したくなることでしょう。Homestead.yaml
が含まれるHomesteadのルートディレクトリに、user-customizations.sh
を作成してください。このファイルの中で、好きなようにカスタマイズを行なってください。ただし、このuser-customizations.sh
はバージョンコントロールに含めてはいけません。When using Homestead
in a team setting, you may want to tweak
Homestead to better fit your personal
development style. You may create a
user-customizations.sh
file
in the root of your Homestead directory
(The same directory containing your
Homestead.yaml
). Within
this file, you may make any
customization you would like; however,
the user-customizations.sh
should not be version
controlled.
Homesteadの更新Updating Homestead
Homesteadの更新を開始する前に、現在の仮想マシンを削除するために、次のコマンドをHomesteadディレクトリで実行してください。Before you begin updating Homestead ensure you have removed your current virtual machine by running the following command in your Homestead directory:
vagrant destroy
次に、Homesteadのソースコードを更新する必要があります。リポジトリをクローンしている場合は、リポジトリをクローンした元のディレクトリで、以下のコマンドを実行してください。Next, you need to update the Homestead source code. If you cloned the repository you can run the following commands at the location you originally cloned the repository:
git fetch
git pull origin release
上記のコマンドにより、最新のHomesteadコードがGitHubリポジトリよりpullされ、最新のタグをフェッチし、タグ付けされた最新のリリースをチェックアウトします。安定リリースバージョンの最新版は、GitHubリリースページで見つけてください。These commands pull the latest Homestead code from the GitHub repository, fetches the latest tags, and then checks out the latest tagged release. You can find the latest stable release version on the GitHub releases page[https://github.com/laravel/homestead/releases].
プロジェクトのcomposer.json
ファイルによりHomesteadをインストールしている場合は、composer.json
ファイルに"laravel/homestead":
"^10"
が含まれていることを確認し、依存コンポーネントをアップデートしてください。If you have installed
Homestead via your project's
composer.json
file, you
should ensure your
composer.json
file contains
"laravel/homestead":
"^10"
and update
your dependencies:
composer update
次に、Vagrantボックスを更新するために、vagrant box
update
コマンドを実行してください。Then, you should
update the Vagrant box using the
vagrant box update
command:
vagrant box update
最後に、最新のVagrantバージョンを使用するために、Homestead Boxを再生成する必要があります。Homesteadディレクトリで以下のコマンドを実行してください。Finally, you will need to regenerate your Homestead box to utilize the latest Vagrant installation:
vagrant up
プロパイダ固有の設定Provider Specific Settings
VirtualBoxVirtualBox
natdnshostresolver
natdnshostresolver
デフォルトの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'
WindowsでのシンボリックリンクSymbolic Links On Windows
Windowsマシンでシンボリックリンクが正しく動かない場合は、Vagrantfile
に以下のコードブロックを追加する必要があります。If symbolic links are
not working properly on your Windows
machine, you may need to add the
following block to your
Vagrantfile
:
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end