<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vagrant | 午後ひと</title>
	<atom:link href="https://gogohito.com/category/itg/vagrant/feed/" rel="self" type="application/rss+xml" />
	<link>https://gogohito.com</link>
	<description>ふとした時に幸せな気持ちにしたい</description>
	<lastBuildDate>Mon, 19 Oct 2020 09:08:58 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>VCCWのMailCatcherでメール送信テストする方法</title>
		<link>https://gogohito.com/vccw-mail/</link>
					<comments>https://gogohito.com/vccw-mail/#respond</comments>
		
		<dc:creator><![CDATA[午後ひと]]></dc:creator>
		<pubDate>Wed, 20 May 2020 18:44:51 +0000</pubDate>
				<category><![CDATA[vagrant]]></category>
		<guid isPermaLink="false">https://gogohito.com/?p=2038</guid>

					<description><![CDATA[WordPressのローカル環境VCCWで、メール送信のテストを行う時は、MailChatcherという疑似SMTPサーバ（メールサーバ）を使用します。 VCCWの環境の中には、既にインストールされているのでその使い方と [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">WordPressのローカル環境VCCWで、メール送信のテストを行う時は、MailChatcherという疑似SMTPサーバ（メールサーバ）を使用します。</p>



<p class="wp-block-paragraph">VCCWの環境の中には、既にインストールされているのでその使い方と疑似的に送信したメールの確認方法を説明します。</p>



<br>



<p class="wp-block-paragraph"></p>


<div class="blogcard-type bct-related">
<div class="blogcard-shortcode-wrap paragraph"><a href="https://gogohito.com/wp-vccw/" title="VirtualBoxとVagrantとVCCWでローカルにWordPress環境を作成する方法" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img decoding="async" width="160" height="90" src="https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-160x90.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-160x90.png 160w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-300x169.png 300w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-1024x576.png 1024w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-768x432.png 768w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-1536x864.png 1536w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-2048x1152.png 2048w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-120x68.png 120w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-320x180.png 320w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-248x140.png 248w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">VirtualBoxとVagrantとVCCWでローカルにWordPress環境を作成する方法</div><div class="blogcard-snippet internal-blogcard-snippet">VirtualBoxとVagrantとVCCWを使用してWordPressのローカル環境をWindows10上に作成する手順の説明です。数多くあるWordPressの設定やプラグインのインストール、動作検証を手軽に行えるようにローカル環境を作ります。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img decoding="async" src="https://www.google.com/s2/favicons?domain=https://gogohito.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">gogohito.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2020.05.01</div></div></div></div></a></div>
</div>


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc1">MailCatcherとは</span></h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">MailCatcherとは、疑似SMTPサーバ（メールサーバ）として動作し、メール送信をしたかのように見せかけて動きます。</p>



<p class="wp-block-paragraph">このMailCatcherに対してメール送信することで、その送信したメールを確認することができます。</p>



<p class="wp-block-paragraph">メールアドレスなどは、自分の好きなメールアドレスを使用することができ、実際に、メールが送信されることがないので、メール送信アプリの開発時や、メールが送信される設定などの確認するときに便利です。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc2">MailCatcherの設定</span></h2>



<p class="wp-block-paragraph">VCCWには、既にMailCatcherがインストールされています。</p>



<p class="wp-block-paragraph">また、特に設定は必要ありません。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc3">MailCatcherを使ってメール送信テスト</span></h2>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc4">MailCatcherの起動</span></h3>



<p class="wp-block-paragraph">VCCWのローカル環境を起動し、ログインします。</p>



<pre class="wp-block-code"><code>vagrant up

vagrant ssh</code></pre>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">ログインできたら、MailChatcherが起動しているか確認します。</p>



<pre class="wp-block-code"><code>ps -ef | grep mailcatcher</code></pre>



<p class="wp-block-paragraph">このコマンドを実行したら、実行されているプロセスが表示されます。<br>※プロセスリストから、mailcatherでフィルタリングした内容が表示されます。</p>



<pre class="wp-block-code"><code>vagrant   2193     1  0 17:51 ?        00:00:00 /usr/bin/ruby2.4 /usr/local/bin/mailcatcher --http-ip 192.168.33.10
vagrant   2197  2164  0 17:52 pts/0    00:00:00 grep mailcatcher</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">もし、既にMailCatcherが起動されている場合は、1行目のようなプロセスが表示されます。</p>



<p class="wp-block-paragraph">起動されていなければ、2行目だけが表示されます。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">起動されていなければMailCatcherの起動をします。</p>



<p class="wp-block-paragraph">起動コマンドは、</p>



<p class="wp-block-paragraph"><span class="bold-blue">mailcatcher &#8211;http-ip VCCW環境のIPアドレス</span></p>



<p class="wp-block-paragraph">です。</p>



<pre class="wp-block-code"><code>mailcatcher --http-ip 192.168.33.10</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">VCCW環境のIPアドレスは、VCCW環境を構築するときに設定したIPアドレスになります。</p>



<div class="wp-block-cocoon-blocks-caption-box-1 caption-box block-box has-border-color has-orange-border-color"><div class="caption-box-label block-box-label box-label fab-info-circle"><span class="caption-box-label-text block-box-label-text box-label-text">VCCW環境のIPアドレス</span></div><div class="caption-box-content block-box-content box-content">
<p class="wp-block-paragraph">VCCW環境のIPアドレスは、site.ymlの中にipアドレスを指定していますのでそれを使います。<br>※IPアドレスを変更している場合は、変更したIPアドレスを使用します。</p>



<p class="wp-block-paragraph">デフォルトで使用している場合は、<span class="bold">192.168.33.10</span>を使っていると思います。</p>



<div class="blogcard-type bct-related">
<div class="blogcard-shortcode-wrap paragraph"><a href="https://gogohito.com/wp-vccw/" title="VirtualBoxとVagrantとVCCWでローカルにWordPress環境を作成する方法" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img decoding="async" width="160" height="90" src="https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-160x90.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-160x90.png 160w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-300x169.png 300w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-1024x576.png 1024w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-768x432.png 768w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-1536x864.png 1536w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-2048x1152.png 2048w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-120x68.png 120w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-320x180.png 320w, https://gogohito.com/wp-content/uploads/2020/06/vagrant-vccw-248x140.png 248w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">VirtualBoxとVagrantとVCCWでローカルにWordPress環境を作成する方法</div><div class="blogcard-snippet internal-blogcard-snippet">VirtualBoxとVagrantとVCCWを使用してWordPressのローカル環境をWindows10上に作成する手順の説明です。数多くあるWordPressの設定やプラグインのインストール、動作検証を手軽に行えるようにローカル環境を作ります。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img decoding="async" src="https://www.google.com/s2/favicons?domain=https://gogohito.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">gogohito.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2020.05.01</div></div></div></div></a></div>
</div>
</div></div>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">これで、メール送信テストをする環境が整いました。</p>



<br>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc5">送信したメールの確認</span></h3>



<p class="wp-block-paragraph">メール送信のテストをするために、MailCatcherにメールを送信します。</p>



<p class="wp-block-paragraph">VCCW環境にあるWordPressで問い合わせページを作成し、メール送信してみました。</p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">送信した結果のメールは次のURLで確認します。</p>



<pre class="wp-block-code"><code>http:&#47;&#47;192.168.33.10:1080</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">WEBメールのように送信したメールが確認できます。</p>



<figure class="wp-block-image size-large is-style-default waku"><img fetchpriority="high" decoding="async" width="1024" height="385" src="https://gogohito.com/wp-content/uploads/2020/05/mail-test-1-1024x385.jpg" alt="" class="wp-image-2050" srcset="https://gogohito.com/wp-content/uploads/2020/05/mail-test-1-1024x385.jpg 1024w, https://gogohito.com/wp-content/uploads/2020/05/mail-test-1-300x113.jpg 300w, https://gogohito.com/wp-content/uploads/2020/05/mail-test-1-768x289.jpg 768w, https://gogohito.com/wp-content/uploads/2020/05/mail-test-1.jpg 1367w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc6">MailCatcherの停止</span></h3>



<p class="wp-block-paragraph">MailCatcherの停止するには、プロセスをkillすることで停止させます。</p>



<p class="wp-block-paragraph">プロセスIDが必要なため、プロセスIDを調べます。</p>



<pre class="wp-block-code"><code>ps -ef | grep mailcatcher

vagrant   2193     1  0 17:51 ?        00:00:00 /usr/bin/ruby2.4 /usr/local/bin/mailcatcher --http-ip 192.168.33.10
vagrant   2197  2164  0 17:52 pts/0    00:00:00 grep mailcatcher</code></pre>



<p class="wp-block-paragraph">2行目の「2193」がプロセスIDとなります。</p>



<p class="wp-block-paragraph">このプロセスIDを使用して、停止させます。</p>



<pre class="wp-block-code"><code>kill 2193</code></pre>



<p class="wp-block-paragraph">これで停止することができました。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc7">まとめ</span></h2>



<p class="wp-block-paragraph">以外に、メールの送信部分というのは、動きが見えにくいので実際にメール送信することなく、メール送信のテストができるのは非常に便利です。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">MailCatcherを使って、便利にメール送信テストを行いましょう。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://gogohito.com/vccw-mail/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>vagrantとVCCW環境にjpegtran、optipng、gifsicleのインストール方法</title>
		<link>https://gogohito.com/gui-opt/</link>
					<comments>https://gogohito.com/gui-opt/#respond</comments>
		
		<dc:creator><![CDATA[午後ひと]]></dc:creator>
		<pubDate>Thu, 14 May 2020 23:18:19 +0000</pubDate>
				<category><![CDATA[vagrant]]></category>
		<guid isPermaLink="false">https://gogohito.com/?p=1928</guid>

					<description><![CDATA[WordPressのローカル環境を作成し、「EWWW Image Optimizer」プラグインを使用すると、作成した環境によっては、jpegtran、optipng、gifsicleの画像操作用のコマンドが必要になる場 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">WordPressのローカル環境を作成し、「EWWW Image Optimizer」プラグインを使用すると、作成した環境によっては、jpegtran、optipng、gifsicleの画像操作用のコマンドが必要になる場合があります。</p>



<p class="wp-block-paragraph">レンタルサーバには、ほとんどの場合、インストールされていますが、インストールされていない場合は、レンタルサーバに問い合わせてみてください。</p>



<p class="wp-block-paragraph">※Xserverでは、インストールされていました。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">vagrantで作成したVCCW環境で、「EWWW Image Optimizer」プラグインを使用しようとしたところ、jpegtranコマンド、optipngコマンド、gifsicleコマンドがないというエラーが発生したのでそれを解消するため、これらのコマンドをインストールします。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc1">jpegtran、optipng、gifsicleコマンドの説明</span></h2>



<p class="wp-block-paragraph">それぞれのコマンドは、画像のメタ情報を削除するコマンドです</p>



<h5 class="wp-block-heading">jpegtranで画像の最適化</h5>



<p class="wp-block-paragraph">jpegtranコマンドは、JPEG 画像に付属している EXIF 情報等のメタ情報を削除とハフマンテーブルの最適化を行うことができます。</p>



<p class="wp-block-paragraph">メタ情報を削除しても画像の劣化は発生させません。</p>



<p class="wp-block-paragraph"></p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-border-color has-red-border-color"><div class="label-box-label block-box-label box-label"><span class="label-box-label-text block-box-label-text box-label-text"><span class="bold-red"><span class="fz-22px">注意！！</span></span></span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph">Exif情報が画像に設定してある状態で、インターネットに公開してしまうと、写真を撮った場所や時間などの情報が<span class="bold-red">知らない間に</span>読み取られてしまいます。</p>



<p class="wp-block-paragraph">インターネットなどに公開する場合は、これらの情報は削除しておいたほうが安全です。</p>
</div></div>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<h5 class="wp-block-heading">optipngで画像の最適化</h5>



<p class="wp-block-paragraph">optipngコマンドは、PNG画像の再圧縮を行い画像サイズを削減するコマンドです。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<h5 class="wp-block-heading">gifsicleでGIFの最適化</h5>



<p class="wp-block-paragraph">gifsicleコマンドでは、GIFファイルのループの設定やコマ送りの設定を変更し、最適化を行います。</p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc2">jpegtran、optipng、gifsicleのインストール方法</span></h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">vagrantで作成されたVCCWの環境にインストールされるOSはUbuntu 16.04 Xenial64でしたので、</p>



<p class="wp-block-paragraph">インストールコマンドである「apt」コマンドを使ってインストールします。<br>※「apt-get」コマンドでもインストール可能です。</p>



<br>



<div class="wp-block-cocoon-blocks-caption-box-1 caption-box block-box has-border-color has-orange-border-color"><div class="caption-box-label block-box-label box-label fab-exclamation-circle"><span class="caption-box-label-text block-box-label-text box-label-text">aptコマンド</span></div><div class="caption-box-content block-box-content box-content">
<p class="wp-block-paragraph">「apt」コマンドは、「apt-get」コマンドと「apt-cache」コマンドを統合したコマンドです。</p>
</div></div>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">それぞれのコマンドをインストールしていきます。</p>



<p class="wp-block-paragraph">まずは、optipngコマンドをインストールします。</p>



<br>



<pre class="wp-block-code"><code>sudo apt install optipng</code></pre>



<br>



<p class="wp-block-paragraph">optipngコマンドがインストールされました。</p>



<br>



<pre class="wp-block-code"><code>Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  optipng
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 82.7 kB of archives.
After this operation, 188 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 optipng amd64 0.7.6-1ubuntu0.16.04.1 &#91;82.7 kB]
Fetched 82.7 kB in 1s (60.3 kB/s)
Selecting previously unselected package optipng.
(Reading database ... 52537 files and directories currently installed.)
Preparing to unpack .../optipng_0.7.6-1ubuntu0.16.04.1_amd64.deb ...
Unpacking optipng (0.7.6-1ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up optipng (0.7.6-1ubuntu0.16.04.1) ...
</code></pre>



<br>



<p class="wp-block-paragraph">続いてgifsicleコマンドをインストールします。</p>



<br>



<pre class="wp-block-code"><code>sudo apt install gifsicle</code></pre>



<br>



<p class="wp-block-paragraph">gifsicleコマンドがインストールされました。</p>



<br>



<pre class="wp-block-code"><code>Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  gifsicle
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 131 kB of archives.
After this operation, 398 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe amd64 gifsicle amd64 1.88-1 &#91;131 kB]
Fetched 131 kB in 1s (82.9 kB/s)
Selecting previously unselected package gifsicle.
(Reading database ... 52551 files and directories currently installed.)
Preparing to unpack .../gifsicle_1.88-1_amd64.deb ...
Unpacking gifsicle (1.88-1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up gifsicle (1.88-1) ...</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">libjpeg-progsパッケージのインストールを行います。</p>



<p class="wp-block-paragraph">このパッケージをインストールすることで、jpegtranコマンドがインストールされます。</p>



<br>



<pre class="wp-block-code"><code>sudo apt install libjpeg-progs</code></pre>



<br>



<p class="wp-block-paragraph">途中で、<br>「After this operation, 475 kB of additional disk space will be used.<br>　Do you want to continue? [Y/n]<br>と確認されますが、Yで続行してください。</p>



<br>



<pre class="wp-block-code"><code>Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libjpeg9
The following NEW packages will be installed:
  libjpeg-progs libjpeg9
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 183 kB of archives.
After this operation, 475 kB of additional disk space will be used.
Do you want to continue? &#91;Y/n] y　　　←　ここで確認が入ります。
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libjpeg9 amd64 1:9b-1ubuntu1 &#91;113 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libjpeg-progs amd64 1:9b-1ubuntu1 &#91;70.9 kB]
Fetched 183 kB in 1s (94.4 kB/s)
Selecting previously unselected package libjpeg9:amd64.
(Reading database ... 52561 files and directories currently installed.)
Preparing to unpack .../libjpeg9_1%3a9b-1ubuntu1_amd64.deb ...
Unpacking libjpeg9:amd64 (1:9b-1ubuntu1) ...
Selecting previously unselected package libjpeg-progs.
Preparing to unpack .../libjpeg-progs_1%3a9b-1ubuntu1_amd64.deb ...
Unpacking libjpeg-progs (1:9b-1ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libjpeg9:amd64 (1:9b-1ubuntu1) ...
Setting up libjpeg-progs (1:9b-1ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...</code></pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">インストールが完了したら</p>



<h2 class="wp-block-heading"><span id="toc3">まとめ</span></h2>



<p class="wp-block-paragraph">これで3つのコマンドのインストールが完了しました。</p>



<p class="wp-block-paragraph">インストール後には、正しくコマンドがインストールされているか動作確認しておきましょう。</p>



<p class="wp-block-paragraph">それぞれのコマンドで、command not foundのエラーが出ないか確認してください。</p>



<pre class="wp-block-code"><code>jpegtran -h

optipng -h

gifsicle -h

</code></pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://gogohito.com/gui-opt/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>仮想環境ツールvagrantのインストールと使い方</title>
		<link>https://gogohito.com/vag-inst/</link>
					<comments>https://gogohito.com/vag-inst/#respond</comments>
		
		<dc:creator><![CDATA[午後ひと]]></dc:creator>
		<pubDate>Thu, 30 Apr 2020 08:26:19 +0000</pubDate>
				<category><![CDATA[vagrant]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<guid isPermaLink="false">https://gogohito.com/?p=1497</guid>

					<description><![CDATA[WordPressでBlogを作り始めたら、プラグインが多くありのでどういう設定をしたら、どういう動作をするのかを調べることをしてみたい。 ただ、レンタルサーバの本番環境でガシガシ試していた。 しかし、記事が増えてくると [&#8230;]]]></description>
			<br />
<b>Warning</b>:  Undefined variable $tag in <b>/home/gogohito/gogohito.com/public_html/wp-content/themes/cocoon-child-master/functions.php</b> on line <b>79</b><br />
<br />
<b>Warning</b>:  Undefined variable $tag in <b>/home/gogohito/gogohito.com/public_html/wp-content/themes/cocoon-child-master/functions.php</b> on line <b>79</b><br />
<br />
<b>Warning</b>:  Undefined variable $tag in <b>/home/gogohito/gogohito.com/public_html/wp-content/themes/cocoon-child-master/functions.php</b> on line <b>79</b><br />
<br />
<b>Warning</b>:  Undefined variable $tag in <b>/home/gogohito/gogohito.com/public_html/wp-content/themes/cocoon-child-master/functions.php</b> on line <b>56</b><br />
<br />
<b>Warning</b>:  Undefined variable $tag in <b>/home/gogohito/gogohito.com/public_html/wp-content/themes/cocoon-child-master/functions.php</b> on line <b>79</b><br />
<br />
<b>Warning</b>:  Undefined variable $tag in <b>/home/gogohito/gogohito.com/public_html/wp-content/themes/cocoon-child-master/functions.php</b> on line <b>79</b><br />
<br />
<b>Warning</b>:  Undefined variable $tag in <b>/home/gogohito/gogohito.com/public_html/wp-content/themes/cocoon-child-master/functions.php</b> on line <b>79</b><br />
<br />
<b>Warning</b>:  Undefined variable $tag in <b>/home/gogohito/gogohito.com/public_html/wp-content/themes/cocoon-child-master/functions.php</b> on line <b>56</b><br />
							<content:encoded><![CDATA[
<p class="wp-block-paragraph">WordPressでBlogを作り始めたら、プラグインが多くありのでどういう設定をしたら、どういう動作をするのかを調べることをしてみたい。</p>



<p class="wp-block-paragraph">ただ、レンタルサーバの本番環境でガシガシ試していた。</p>



<p class="wp-block-paragraph">しかし、記事が増えてくるともし壊れてしまったら・・・。</p>



<br>



<p class="wp-block-paragraph">そう思って、簡単に仮想環境が構築できる<span class="bold-blue">vagrant</span>をインストールし、ローカル環境を準備することにしました。</p>



<br>



<p class="wp-block-paragraph">現在使っているのが、Windows 10 Proなのでこの環境にインストールします。</p>



<br>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc1">vagrantとは</span></h2>



<p class="wp-block-paragraph">vagrantとは、VirtualBoxやVMWaereなどの仮想化ソフトと合わせて使用することで、仮想環境を簡単に構築したり、破棄したりできるソフトウェアです。</p>



<p class="wp-block-paragraph">また、Boxという形式で仮想環境を共有することができます。</p>



<p class="wp-block-paragraph">このVagrantは、Windowsのほかに、MACやLinuxで動作させることができます。</p>



<p class="wp-block-paragraph"><a rel="nofollow noopener" target="_blank" href="https://www.vagrantup.com/" data-type="URL" data-id="https://www.vagrantup.com/">Vagrantの公式ページはこちらです。</a></p>



<br>



<p class="wp-block-paragraph">この仮想環境を共有するというのは、CentOSの仮想環境が欲しいと思ったら、<a rel="nofollow noopener" target="_blank" href="https://app.vagrantup.com/boxes/search">Vagrant Cloud</a>から検索することができます。</p>



<p class="wp-block-paragraph">ここに共有されているBoxという仮想環境をダウンロードし、ローカルのvagrant環境に設定すれば、あら不思議、簡単に仮想環境ができてしまいます。</p>



<p class="wp-block-paragraph">とても便利な環境になります。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">もし、この仮想環境を共有する機能がなかった場合は、仮想環境をOSのインストールから初めて、すべての環境を一から構築する必要があります。</p>



<p class="wp-block-paragraph">しかし、vagrantを使用することで、これらの手順をすっ飛ばして仮想環境を構築することができます。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-1 sbs-stn sbp-l sbis-cb cf block-box"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://gogohito.com/wp-content/uploads/2020/03/1585551174.52051_165.png" alt="" class="speech-icon-image"/></figure><div class="speech-name"></div></div><div class="speech-balloon">
<p class="wp-block-paragraph">とても簡単で、素晴らしい。</p>
</div></div>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc2">事前準備</span></h2>



<p class="wp-block-paragraph">今回は、Windows 10 Proの環境にインストールします。</p>



<p class="wp-block-paragraph">また、Vagrantは、仮想化ソフトとしてVirtualBoxやVMWareなどのソフトが必要です。</p>



<p class="wp-block-paragraph">どちらでも構わないですが、VirtualBoxを既に準備してあるのでこちらを使います。</p>



<p class="wp-block-paragraph">VirtualBoxをインストールしていない方は、<a href="https://gogohito.com/vbox-inst/" target="_blank">Windows10にVirtualBox（Ver6.1)をインストールする方法</a>を参考に準備してください。</p>



<br>



<div class="wp-block-cocoon-blocks-caption-box-1 caption-box block-box has-border-color has-amber-border-color"><div class="caption-box-label block-box-label box-label"><span class="caption-box-label-text block-box-label-text box-label-text">今回のインストール環境</span></div><div class="caption-box-content block-box-content box-content">
<ul class="wp-block-list"><li>OS<br>Windows 10 Pro （64bit）</li><li>仮想ソフト<br>VirtualBox v6.1</li><li>Vagrant<br>ver 2.2.7<br></li></ul>
</div></div>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc3">vagrantのインストール</span></h2>



<p class="wp-block-paragraph">vagrantのインストールは、インストールする環境にあったインストーラを入手し、ウィーザードに沿ってインストールするだけなので非常に簡単にインストールできます。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc4">Vagrantのダウンロード</span></h3>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><a rel="nofollow noopener" target="_blank" href="https://www.vagrantup.com/" data-type="URL" data-id="https://www.vagrantup.com/">Vagrantの公式ページ</a>からインストールするファイルをダウンロードします。</p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">「Download 2.2.7」を選択してvagrantのダウンロードページへ遷移します。</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default waku"><img loading="lazy" decoding="async" width="1024" height="528" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-1-1024x528.jpg" alt="" class="wp-image-1501" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-1-1024x528.jpg 1024w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-1-300x155.jpg 300w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-1-768x396.jpg 768w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-1-1536x792.jpg 1536w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-1.jpg 1551w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">ダウンロードページで、インストールする環境のインストーラを入手します。</p>



<p class="wp-block-paragraph">今回は、Windows環境にインストールしますので「Windows　64bit」を選択します。</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default waku"><img loading="lazy" decoding="async" width="983" height="881" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-2.jpg" alt="" class="wp-image-1502" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-2.jpg 983w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-2-300x269.jpg 300w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-2-768x688.jpg 768w" sizes="(max-width: 983px) 100vw, 983px" /></figure>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc5">インストール</span></h3>



<p class="wp-block-paragraph">Windowsの64bit用なので「vagrant_2.2.7_x86_64.msi」というファイルがダウンロードされています。</p>



<p class="wp-block-paragraph">入手したインストーラを実行します。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Windowsからセキュリティ警告が表示されますので「詳細情報」を押します。</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="534" height="500" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-3.jpg" alt="" class="wp-image-1503" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-3.jpg 534w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-3-300x281.jpg 300w" sizes="(max-width: 534px) 100vw, 534px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">実行しようとしているソフトウェアを実行してい良いか確認されますので「実行」を押してインストールを進めてください。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="534" height="500" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-4.jpg" alt="" class="wp-image-1504" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-4.jpg 534w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-4-300x281.jpg 300w" sizes="(max-width: 534px) 100vw, 534px" /></figure>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">インストーラのウィザードに従って、インストールを進めます。</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="495" height="387" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-5.jpg" alt="" class="wp-image-1505" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-5.jpg 495w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-5-300x235.jpg 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph">「Next」を押します。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">「ライセンス」の確認をして「Next」を押します。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="495" height="387" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-6.jpg" alt="" class="wp-image-1506" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-6.jpg 495w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-6-300x235.jpg 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">インストールする場所を指定し、「Next」を押します。</p>



<p class="wp-block-paragraph">※通常は、デフォルトのままで問題ありません。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="495" height="387" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-7.jpg" alt="" class="wp-image-1507" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-7.jpg 495w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-7-300x235.jpg 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">「Install」を押しインストールを開始します。</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="495" height="387" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-8.jpg" alt="" class="wp-image-1508" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-8.jpg 495w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-8-300x235.jpg 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">インストールが開始されます。</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="495" height="387" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-9.jpg" alt="" class="wp-image-1509" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-9.jpg 495w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-9-300x235.jpg 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">セットアップが完了したら「Finish」を押します。</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="495" height="387" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-10.jpg" alt="" class="wp-image-1510" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-10.jpg 495w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-10-300x235.jpg 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">インストールをしている中で、WindowsDefendefからのセキュリティ警告が表示されます。</p>



<p class="wp-block-paragraph">これは「アクセスを許可する」を押します。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="615" height="435" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-plug-inst-2.jpg" alt="" class="wp-image-1512" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-plug-inst-2.jpg 615w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-plug-inst-2-300x212.jpg 300w" sizes="(max-width: 615px) 100vw, 615px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">再起動の確認がありますので、「Yes」を押して再起動してください。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="362" height="167" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-11.jpg" alt="" class="wp-image-1511" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-11.jpg 362w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-11-300x138.jpg 300w" sizes="(max-width: 362px) 100vw, 362px" /></figure>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">再起動後、コマンドプロンプト、または、PowerShellからvagrantコマンドでバージョン確認をしてください。</p>



<p class="wp-block-paragraph">インストールされたバージョンが表示されれば、インストール完了です。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="203" height="101" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-inst-12.jpg" alt="" class="wp-image-1513"/></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc6">Vagrantで仮想環境構築</span></h2>



<p class="wp-block-paragraph">インストールが完了したら、実際にSentOSの環境を構築してみます。</p>



<p class="wp-block-paragraph">どのぐらい簡単に構築できるかが体感できると思います。</p>



<p class="wp-block-paragraph">※仮想環境を配置する場所に、VirtualBoxを使用しますので、インストールしていない方は、<a href="https://gogohito.com/vbox-inst/" target="_blank">Windows10にVirtualBox（Ver6.1)をインストールする方法</a>を参考に準備してください。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">vagrantで、仮想環境を作成するには、次の3つの手順で行います。</p>



<div class="box1-yellow">
<div class="box-title">Vagrantの仮想環境構築手順</div>
<div class="ptimeline-wrap"><ul class="ptimeline yellow  "><li class="ptimeline-item"><div class="ptimeline-label">STEP1</div><div class="ptimeline-title">作業フォルダの作成</div><div class="ptimeline-main"></p>
<p>Vagrantの環境を構築するための任意のフォルダを作成します。</div><div class="ptimeline-marker "></div></li><li class="ptimeline-item"><div class="ptimeline-label">STEP2</div><div class="ptimeline-title">設定情報ファイル（Vagrantfile）の作成</div><div class="ptimeline-main"></p>
<p>設定情報ファイルを作成し、4項目指定します。</p>
<ul>
<li>仮想環境のOS</li>
<li>IPアドレス</li>
<li>ホストとなる仮想ソフトウェア</li>
<li>メモリサイズ</li>
</ul>
<p></div><div class="ptimeline-marker "></div></li><li class="ptimeline-item"><div class="ptimeline-label">STEP3</div><div class="ptimeline-title">Vagrantの起動</div><div class="ptimeline-main"></p>
<p>Vagrantを起動します。</p>
<p></div><div class="ptimeline-marker "></div></li></ul></div>
</div>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">これで、仮想環境ができてしまいます。</p>



<p class="wp-block-paragraph">※テスト的に構築するので、実際に構築するときはもう少し詳細な設定が必要になります。</p>



<br>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc7">Vagrantのフォルダの作成</span></h3>



<p class="wp-block-paragraph">vagrantの作業場所として、任意の場所にフォルダを作成します。</p>



<p class="wp-block-paragraph">このフォルダには、構築する仮想環境の設定情報ファイル（Vagrantfile）を格納します。</p>



<p class="wp-block-paragraph">PowerShellかコマンドラインを起動して下のコマンドを実行します。</p>



<pre class="wp-block-code"><code>mkdir \vagrant\test
cd \vagrant\test</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">テストで仮想環境を構築するので、「\vagrant\test」というフォルダを作成し、ここに仮想環境を構築してみます。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc8">設定情報ファイル（Vagrantfile）の作成</span></h3>



<p class="wp-block-paragraph">次に、vagrantが仮想環境を構築するために、設定情報ファイル（Vagrantfile）を作成します。</p>



<p class="wp-block-paragraph">ひな形は、vagrantがコマンドで作成してくれます。</p>



<pre class="wp-block-code"><code>vagrant init</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">コマンドプロンプトで実行すると「Vagrantfile」が作成されます。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="561" height="312" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-1.jpg" alt="" class="wp-image-1516" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-1.jpg 561w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-1-300x167.jpg 300w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-1-120x68.jpg 120w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-1-160x90.jpg 160w" sizes="(max-width: 561px) 100vw, 561px" /></figure>



<br>



<p class="wp-block-paragraph">このVagrantfileファイルを開いて編集します。</p>



<p class="wp-block-paragraph"></p>



<div class="wp-block-cocoon-blocks-caption-box-1 caption-box block-box has-border-color has-light-green-border-color"><div class="caption-box-label block-box-label box-label"><span class="caption-box-label-text block-box-label-text box-label-text">Vagrantfile</span></div><div class="caption-box-content block-box-content box-content">
<pre class="wp-block-code"><code># -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "centos/7"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
   config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
   config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
     vb.memory = "1024"
   end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: &lt;&lt;-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end
</code></pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">このファイルは、vagrant initで作成したものを編集していきます。</p>



<div class="wp-block-cocoon-blocks-caption-box-1 caption-box block-box has-border-color has-light-green-border-color"><div class="caption-box-label block-box-label box-label"><span class="caption-box-label-text block-box-label-text box-label-text">指定内容</span></div><div class="caption-box-content block-box-content box-content">
<ul class="wp-block-list"><li>config.vm.box <br>「centos/7」を指定し、CentOS ver.7の仮想環境を構築します。</li><li>ip:<br>IPアドレスは、192.168.33.10です。これは、デフォルトでこの設定になっています。<br>変更の必要があれば、変更します。</li><li>config.vm.provider<br>仮想化ソフトウェアとして、VirtualBoxを使用しますので、「virtualbox」を指定します。</li><li>vb.memory<br>メモリは、1024MBで作ります</li></ul>



<p class="wp-block-paragraph"></p>
</div></div>



<p class="wp-block-paragraph"></p>
</div></div>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc9">Vagrantの起動</span></h3>



<p class="wp-block-paragraph">作成したVagrantfileから、Vagrantの仮想環境のセットアップと起動を行います。</p>



<pre class="wp-block-code"><code>vagrant up</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">このコマンドで、起動するべき仮想環境が作成されていない場合は、仮想化ソフトウェア（VirtualBox）に環境構築して、起動します。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-1 sbs-stn sbp-l sbis-cb cf block-box"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://gogohito.com/wp-content/uploads/2020/03/1585551174.52051_165.png" alt="" class="speech-icon-image"/></figure><div class="speech-name"></div></div><div class="speech-balloon">
<p class="wp-block-paragraph">なんて便利なんでしょう。</p>
</div></div>



<p class="wp-block-paragraph">初回は、環境がないので起動に時間がかかりますが、2回目以降はすぐに起動します。</p>



<p class="wp-block-paragraph">コマンドの実行が終わったら、VirtualBoxに仮想環境が登録されているか確認します。</p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-code"><code>D:\vagrant\test>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'centos/7'
    default: URL: https://vagrantcloud.com/centos/7
==> default: Adding box 'centos/7' (v1905.1) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1905.1/providers/virtualbox.box
    default: Download redirected to host: cloud.centos.org
    default:
==> default: Successfully added box 'centos/7' (v1905.1) for 'virtualbox'!
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: test_default_1588150175428_83970
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
    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: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/d/vagrant/test/ => /vagrant

D:\vagrant\test>
</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">Vagrantのコマンドが終了したら、VirtualBoxを起動します。<br>「test」という仮想環境がVirtualBoxに登録されていることが確認できます。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="777" height="455" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-2.jpg" alt="" class="wp-image-1521" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-2.jpg 777w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-2-300x176.jpg 300w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-2-768x450.jpg 768w" sizes="(max-width: 777px) 100vw, 777px" /></figure>



<br>



<p class="wp-block-paragraph">構築されたCentOS7の仮想環境にコマンドプロンプトからログインしてみます。</p>



<pre class="wp-block-code"><code>vagrant ssh</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="420" height="116" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-3.jpg" alt="" class="wp-image-1522" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-3.jpg 420w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-3-300x83.jpg 300w" sizes="(max-width: 420px) 100vw, 420px" /></figure>



<p class="wp-block-paragraph">無事にログインすることができました。</p>



<p class="wp-block-paragraph">これで、CentOS ７の環境がローカルに構築できてしまいました。</p>



<p class="wp-block-paragraph">非常に簡単です。</p>



<br>



<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><span id="toc10">環境の停止</span></h3>



<p class="wp-block-paragraph">続いて、仮想環境を停止します。</p>



<BR>



<pre class="wp-block-code"><code>vagrant halt</code></pre>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="419" height="108" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-4.jpg" alt="" class="wp-image-1523" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-4.jpg 419w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-4-300x77.jpg 300w" sizes="(max-width: 419px) 100vw, 419px" /></figure>



<br>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">停止した様子を、VirtualBoxにからも確認できます。</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="777" height="455" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-5.jpg" alt="" class="wp-image-1524" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-5.jpg 777w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-5-300x176.jpg 300w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-5-768x450.jpg 768w" sizes="(max-width: 777px) 100vw, 777px" /></figure>



<br>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc11">Vagrantの仮想環境を削除</span></h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">不要になった場合や、一度構築しなおしたい場合に仮想環境を削除します。</p>



<p class="wp-block-paragraph">削除するのは、あくまでも<span class="bold-red">Vagrantで構築した仮想環境</span>のみです。</p>



<p class="wp-block-paragraph">Vagrant 自身が削除されるわけではありません。<br></p>


<div class="box1-yellow">
<div class="box-title">Vagrantで構築した仮想環境の削除</div>
<div class="ptimeline-wrap"><ul class="ptimeline yellow  "><li class="ptimeline-item"><div class="ptimeline-label">STEP1</div><div class="ptimeline-title">Box情報の削除</div><div class="ptimeline-main"></p>
<p>Vagrantに登録されている仮想環境情報リストから削除します。</p>
<p> </p>
<p>実行コマンド：vagrant box remove centos/7 &#8211;provider virtualbox</p>
<p> </p>
<p></div><div class="ptimeline-marker "></div></li><li class="ptimeline-item"><div class="ptimeline-label">STEP2</div><div class="ptimeline-title">破棄するBoxのIDを確認</div><div class="ptimeline-main"></p>
<p>破棄するBoxのIDを確認します。</p>
<p> </p>
<p>実行コマンド：vagrant global-status</p>
<p> </p>
<p></div><div class="ptimeline-marker "></div></li><li class="ptimeline-item"><div class="ptimeline-label">STEP3</div><div class="ptimeline-title">仮想環境の破棄</div><div class="ptimeline-main"></p>
<p>STEP2で確認したIDをもとに仮想環境を破棄します。</p>
<p> </p>
<p>実行コマンド：vagrant destroy <span class="bold-blue">a9b93cf</span></p>
<p>※この例では、BoxのIDが「<span class="bold-blue">a9b93cf</span>」となっています。</p>
<p></div><div class="ptimeline-marker "></div></li></ul></div>
</div>


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="658" height="557" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-61.jpg" alt="" class="wp-image-1535" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-61.jpg 658w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-61-300x254.jpg 300w" sizes="(max-width: 658px) 100vw, 658px" /></figure>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">これで、Vagrantからも、VirtualBoxからも、削除されました。</p>



<p class="wp-block-paragraph">確認してみます。</p>



<br>



<p class="wp-block-paragraph">VirtualBoxからも削除されています。</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="777" height="455" src="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-7.jpg" alt="" class="wp-image-1527" srcset="https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-7.jpg 777w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-7-300x176.jpg 300w, https://gogohito.com/wp-content/uploads/2020/04/vagrant-use-7-768x450.jpg 768w" sizes="(max-width: 777px) 100vw, 777px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading"><span id="toc12">まとめ</span></h2>



<p class="wp-block-paragraph">Vagrantを使用することで、テスト環境を簡単に構築することがわかりました。</p>



<p class="wp-block-paragraph">必要な仮想環境は、<a rel="nofollow noopener" target="_blank" href="https://app.vagrantup.com/boxes/search">Vagrant Cloud</a>から検索してみてあればそのまま使用することができます。</p>



<p class="wp-block-paragraph"></p>



<br>



<p class="wp-block-paragraph">これは、非常に便利です。</p>



<p class="wp-block-paragraph">一からOSをインストールして環境を作らなくてもよいことを考えるとインストール失敗による時間の無駄がなくなります。</p>



<p class="wp-block-paragraph">さらに、複数のOSで実行したい場合などは環境構築にかかる時間が圧倒的に少なく済みます。</p>



<br>



<p class="wp-block-paragraph">技術者が、何かを試したい時なども有用です。</p>



<p class="wp-block-paragraph">ただ、一からインストールする楽しみはあるので、それは別途楽しんでください。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://gogohito.com/vag-inst/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Disk: Enhanced  を使用したページ キャッシュ
遅延読み込み (feed)
Disk を使用して縮小 
Disk を使用してデータベースキャッシュ

Served from: gogohito.com @ 2026-06-24 12:26:26 by W3 Total Cache
-->