Vagrantを使って、CentOS7.3+PHP7.1環境を、素早くコマンド1つで構築する為の手順です。
手順
-
vagrantをインストールする
-
下記の内容のファイルを"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
- コマンドラインから
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...
...
-
コーヒーでも飲みながら、インストールが終わるのを5分ぐらい待つ
おいしいコーヒーのいれ方 -
コマンドラインから
vagrant ssh
を実行
$ vagrant ssh
[vagrant@localhost ~]$
- 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
こちらもおススメ