[PHP]VagrantでCentOS7.3+PHP7.1環境をコマンド1つで構築する

カテゴリ: PHP, Vagrant

Vagrantを使って、CentOS7.3+PHP7.1環境を、素早くコマンド1つで構築する為の手順です。

手順

  1. vagrantをインストールする

  2. 下記の内容のファイルを"Vagrantfile"の名前で作る

Vagrant.configure("2") do |config|
  config.vm.box = "bento/centos-7.3"

  config.vm.provision "shell", inline: <<-SHELL
      yum install epel-release -y
      rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
      yum install --enablerepo=remi,remi-php71 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt -y 

      php --version
  SHELL
end
  1. コマンドラインからvagrant upを実行
$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-7.3'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-7.3' is up to date...
==> default: Setting the name of the VM: wp_default_1507528682091_58865
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
...
  1. コーヒーでも飲みながら、インストールが終わるのを5分ぐらい待つ
    おいしいコーヒーのいれ方

  2. コマンドラインからvagrant sshを実行

$ vagrant ssh
[vagrant@localhost ~]$
  1. sshの中でphp --versionを実行し、phpが使えることを確認
[vagrant@localhost ~]$ php --version
PHP 7.1.10 (cli) (built: Sep 27 2017 08:27:18) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies


Amazonでおトクに買い物する方法
AmazonチャージでポイントGET


Amazonは買いもの前にAmazonギフト券をチャージしてポイントをゲットしないと損!

こちらもおススメ

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です