VagrantでPHPとnode.jsのコマンドラインツール環境


CentOS6(32bit)+PHP+Composer+nodejs

Vagrantfile

1
2
3
4
5
6
7
Vagrant.configure(2) do |config|
  config.vm.box = "bento/centos-6.7-i386"
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.provider "virtualbox"
  config.vm.provision :shell, :path => "provision.sh"
  config.ssh.insert_key = false
end

provision.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
### Les RPM de Remi
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
### node.js
yum install -y --enablerepo=remi nodejs npm
npm update -g npm
npm install -g htmlhint
npm install -g csslint
npm install -g csscomb
npm install -g pleeease-cli
npm install -g jshint
npm install -g jscs
npm install -g plato
npm install -g uglify-js
### PHP
yum install -y --enablerepo=remi,remi-php56 php php-cli php-common php-devel php-gd php-intl php-mbstring php-openssl \
php-pear php-xml php-mcrypt \
php-pecl-xdebug php-phpunit-PHPUnit
echo 'date.timezone = Asia/Tokyo' >> /etc/php.ini
### PHP Composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
su - vagrant -c '
  echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $HOME/.bash_profile
  source $HOME/.bash_profile
  composer global require "squizlabs/php_codesniffer=*"
  composer global require "phpmd/phpmd=*"
  composer global require "sebastian/phpcpd=*"
  composer global require "sebastian/phpdcd=*"
  composer global require "halleck45/phpmetrics"
'