vargrant+chefã§ã¤ããPHP5.5+MySQL5.6+CakePHP3ç°å¢
å··ã§è©±é¡ã®vagrantãchefã試ãã¦ã¿ã¾ããã
æè§ãªã®ã§ããããææ°ãã¼ã¸ã§ã³ãç©æ¥µçã«å
¥ãã¦ã¿ããã¨ã«ãã¾ãããï¼çµæ§è¦å´ãã¾ããâ¦ï¼
ã¨ããããæã£åãæ©ãç°å¢ãä½ãæé ãæ¸ãã¦è¡ãã¾ãã
åæç°å¢
- ãã¹ããã·ã³ç°å¢
- MacOS 10.9
- VirtualBox 4.3.6
- Vagrant 1.4.1
- Chef 11.8.2
- vagrant-omnibus 1.2.1
- ruby 2.0.0p247
- gem 2.0.3
- ä»®æ³ãã·ã³ç°å¢
- CentOS 6.5 64bit
- Apache2.2 (yumã¬ãã¸ããª)
- PHP5.5 (remiã¬ãã¸ããª)
- MySQL5.5 (å ¬å¼rpm)
å種ã½ããã¦ã§ã¢ã®ã¤ã³ã¹ãã¼ã«
VirtualBox
ä»®æ³ãã·ã³ã½ããã§ãã以ä¸URLãããã¦ã³ãã¼ããã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã
https://www.virtualbox.org/wiki/Downloads
vagrant
ä»®æ³ãã·ã³(ããã§ã¯VirtualBox)ã®ç®¡çã便å©ã«ãããã¼ã«ã§ãã以ä¸URLãããã¦ã³ãã¼ããã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã
http://www.vagrantup.com/
chef
ãµã¼ãã¼è¨å®ãã¼ã«ã§ãããã¹ããã·ã³ã§ä»¥ä¸ã®ããã«ã³ãã³ããæµãã°ã¤ã³ã¹ãã¼ã«ããã¾ããã¾ããä»éãã¼ã«ã®ã¤ã³ã¹ãã¼ã«ãåæè¨å®ãªã©ãè¡ãã¾ãã
mac$ curl -L https://www.opscode.com/chef/install.sh | sudo bash mac$ sudo gem install knife-solo mac$ knife configure
knife configureã§è²ã
質åããã¾ããããã®ã¾ã¾ENTERãæ¼ãã¦ããã°OKã§ãã
omnibus
ä»®æ³ãã·ã³ã«chefãå ¥ããvagrantã®pluginã§ãããã¹ããã·ã³ã§ä»¥ä¸ã®ããã«å®è¡ããã¨ã¤ã³ã¹ãã¼ã«ããã¾ãã
mac$ vagrant plugin install vagrant-omnibus
ä»®æ³ãã·ã³ã®èµ·å
ä»åä½ã£ãè¨å®ãã¡ã¤ã«ã¨CakePHP3ã®ãã¡ã¤ã«ãã¾ã¨ãã¦githubã«ç½®ãã¾ããã®ã§ãã¨ãããããããcloneãã¦é²ãã¾ã
mac$ git clone --recursive https://github.com/takemaru123/vagrant-cakephp3-sample.git mac$ cd vagrant-cakephp3-sample mac$ vagrant up
ããã ãã§ãvagrantã®box(ä»®æ³ãã·ã³ãã³ãã¬ã¼ã)ããã¦ã³ãã¼ããããapache,php,mysqlãªã©ãä»®æ³ãã·ã³ä¸ã«æ§ç¯ããã¾ã
以ä¸ã®ããã«ããã¨ãä»®æ³ãã·ã³ä¸ã®ã³ã³ã½ã¼ã«ã«å ¥ããã¨ãã§ãã¾ã
mac$ vagrant ssh
以ä¸ã®ããã«åä½ç¢ºèªãã¦ã¿ã¾ãããã
centos$ cat /etc/redhat-release CentOS release 6.5 (Final) centos$ php -v PHP 5.5.7 (cli) (built: Dec 11 2013 07:13:20) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans centos$ mysql --version mysql Ver 14.14 Distrib 5.6.15, for Linux (x86_64) using EditLine wrapper
ã¾ãããã¹ããã·ã³ã®ãã©ã¦ã¶ããã以ä¸ã®URLãå®è¡ããã¨ãInternal Server Errorã¨ãªãã¨æãã¾ãã
http://192.168.33.10/
ããã¯CakePHPå¨ãã®è¨å®ãã¾ã è¡ã£ã¦ããªãããã§ãããHTTPãµã¼ãã¼ãèµ·åãã¦ããäºã¯ãããã¨æãã¾ãã
cakephp3ã®è¨å®
cloneããã¬ãã¸ããªã«ã¯ãCakePHPã®appãã£ã¬ã¯ããªã¯å«ã¾ãã¦ãã¾ãããCakePHPæ¬ä½ã¯å«ã¾ãã¦ãã¾ãããCakePHPæ¬ä½ã¯Composerã¨ããPHPã®ããã±ã¼ã¸ç®¡çãã¼ã«ãç¨ãã¦å°å ¥ãã¾ãã
ä»®æ³ãã·ã³ã®ã³ã³ã½ã¼ã«ã«å ¥ãã¾ãã
mac$ vagrant ssh
CakePHPã®appãã£ã¬ã¯ããªã¸ç§»åããComposeré¢ä¿ã®æä½ãå®æ½ãã¾ãã
ã¡ãªã¿ã«ããã¹ããã·ã³ã®vagrant-cakephp3-sampleãã£ã¬ã¯ããªã¨ãä»®æ³ãã·ã³ã®/vagrantãã£ã¬ã¯ããªãåæããã¦ããã®ãããã§ãããã¨ãããã¾ãã
centos$ cd /vagrant/app centos$ curl -sS https://getcomposer.org/installer | php centos$ php composer.phar install
ããã§composerãã¤ã³ã¹ãã¼ã«ãããcomposer.jsonã«è¨è¼ããã¦ããå¿ è¦ãªã©ã¤ãã©ãªé¡(CakePHPæ¬ä½ç)ãã¤ã³ã¹ãã¼ã«ããã¾ããã
ãã®æç¹ã§ä»¥ä¸URLããã¹ããã·ã³ããå©ãã¨ãCakePHPã®åä½ç¢ºèªç»é¢ã確èªãããã¨ãã§ãã¾ãã
http://192.168.33.10/
æè§MySQLãå
¥ããã®ã§ãCakePHPã®è¨å®ãã¡ã¤ã«ãæ¸ãæããMySQLã¸ç¹ããããã«ãã¾ãã
ãã®æä½ã¯ãã¹ãOS(mac)ãä»®æ³ãã·ã³ã©ã¡ãããè¡ã£ã¦ã大ä¸å¤«ã§ãã
/path/to/vagrant-cakephp3-sample/app/App/Config/app.php å㯠/vagrant/app/App/Config/app.php
以ä¸ã®ããã«æ¸ãæãã¾ãã
â»ãã¡ã¤ã« : vagrant-cakephp3-sample3/app/App/Config/acl.php â»æç² 'Datasources' => [ 'default' => [ 'className' => 'Cake\\Database\\Driver\\Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'root', 'password' => '', 'database' => 'test', 'prefix' => false, 'encoding' => 'utf8', ],
å度ãã©ã¦ã¶ããã¢ã¯ã»ã¹ãããCake is able to connect to the database.ãã¨è¡¨ç¤ºãããã°æåã§ãã
ããã§ç°å¢ãä¸éãã§ããããã¾ããã
Vagrantãã¡ã¤ã«
ããããã¯å種è¨å®ãã¡ã¤ã«ãã¬ã·ãã«ã¤ãã¦æ¸ãã¦ããã¾ãã
ã¾ãVagrantã使ç¨ããä»®æ³ãã·ã³æ¯ã«ããã¼ã¹ã¨ãªããã£ã¬ã¯ããªãä½æãã¾ãããã®ãã£ã¬ã¯ããªä»¥ä¸ã«Vagrantã®è¨å®ãã¡ã¤ã«ãchefã®ã¬ã·ããè¨ç½®ãã¾ãã
ã¾ãããã®ãã£ã¬ã¯ããªå
ã¯ä»®æ³ãã·ã³ã¨ã®å
±æãã£ã¬ã¯ããªã«ãªãã¾ãã®ã§ãéçºããããã°ã©ã ãããã«è¨ç½®ããã¨ããã¹ããã·ã³ã®ã¨ãã£ã¿ã§ã³ã¼ããæ¸ããä»®æ³ãã·ã³ã§åä½ãããã¨ãã£ãæµããå¯è½ã«ãªãã¾ãã
mac$ mkdir vagrant-cakephp3-sample mac$ cd vagrant-cakephp3-sample
次ã«ãä»®æ³ãã·ã³ã®è¨å®ãè¨è¿°ããVagrantãã¡ã¤ã«ã®ã²ãªå½¢ãä½æãã¾ãã
mac$ vagrant init
Vagrantã®å
容ã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "CentOS_6.5_x86_64" config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box" config.vm.network :private_network, ip: "192.168.33.10" # cakephpã使ãããã«å¿ è¦ config.vm.synced_folder "./", "/vagrant", mount_options: ['dmode=777', 'fmode=666'] config.omnibus.chef_version = :latest config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "./site-cookbooks" chef.add_recipe "base" chef.add_recipe "mysql56" chef.add_recipe "php55" chef.json = { httpd: { port: 80, docroot: "/vagrant/app/webroot" }, php: { timezone: "Asia/Tokyo" }, mysql: { password: '' }, } end end
以ä¸æç²ã§ãã
config.vm.box = "CentOS_6.5_x86_64" config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box"
CentOSãã¤ã³ã¹ãã¼ã«ããã¦ããä»®æ³ãã·ã³ããããä¸ããåã£ã¦ããããã«è¨å®ãã¦ãã¾ãã(æå¿ã®æ¹ãå
¬éãã¦ãããã®ã§ã)
ä¸åº¦ãã¦ã³ãã¼ãããã°PCå
ã«ãã³ãã¬ã¼ã(box)ã¨ãã¦ä¿åãããã¾ãåãboxããä»®æ³ãã·ã³ãä½ãå ´åã¯ããã¼ã«ã«ã«ä¿æãã¦ããboxã使ãããããã«ãªãã¾ãã
config.vm.network :private_network, ip: "192.168.33.10"
ãã¹ããã·ã³(mac)ããä»®æ³ãã·ã³ã«ã¢ã¯ã»ã¹ããéã®IPã¢ãã¬ã¹ãè¨å®ãã¦ãã¾ãã
ä»®æ³ãã·ã³ãè¤æ°ç«ã¡ä¸ããå ´åãªã©ã¯ãé©å®å¤æ´ããå¿
è¦ãããã¾ãã
config.omnibus.chef_version = :latest
ä»å使ã£ãboxã«ã¯chefãã¤ã³ã¹ãã¼ã«ããã¦ããªããããomnibusã使ããä»®æ³ãã·ã³ã«chefãä»®æ³ãã·ã³ã«èªåã¤ã³ã¹ãã¼ã«ãã¾ãã
chef.cookbooks_path = "./site-cookbooks" chef.add_recipe "base" chef.add_recipe "mysql56" chef.add_recipe "php55"
ä»®æ³ãã·ã³ãèµ·åããå¾ã«å®è¡ããchefã®ã¬ã·ããå®ç¾©ãã¦ãã¾ãã
ããã§ã¯base,mysql56,php55ã®3ã¤ã®ã¬ã·ããå®è¡ããã¾ãã
chef.json = { httpd: { port: 80, docroot: "/vagrant/app/webroot" }, php: { timezone: "Asia/Tokyo" }, mysql: { password: '' }, }
chefå®è¡æã®å¤æ°ãããã§æå®ãã¦ãã¾ãã
ã¬ã·ã:base
chefã®ã¬ã·ããè¨è¿°ãã¦è¡ãã¾ãã
ã¾ãã¯ã¬ã·ãã®ãã¼ã¹ã¨ãªããã³ãã¬ã¼ããä½æãã¾ãã
mac$ knife cookbook create base -o site-cookbooks/
èªåã§ä½æããã¬ã·ãã¯ãsite-cookbooksã¨ãããã£ã¬ã¯ããªã«è¨ç½®ããã®ã決ã¾ãã®ããã§ãã
ãã®ã³ãã³ãã§ã
vagrant-cakephp3-sample/site-cookbooks/base
ã¨ãããã£ã¬ã¯ããªãä½æãããæ´ã«ãã®ä¸ã«è¤æ°ã®ãã£ã¬ã¯ããªããã¡ã¤ã«ãä½æããã¾ããã
ã¬ã·ãã®å 容ãè¨è¿°ãã¦ããã¾ãã
â»ãã¡ã¤ã« : vagrant-cakephp3-sample/site-cookbooks/base/recipes/default.rb # ã¹ã¯ããé åä½æ # åè:http://qiita.com/naoya@github/items/2059e3755962e907315e bash 'create swapfile' do user 'root' code <<-EOC dd if=/dev/zero of=/swap.img bs=1M count=1024 && chmod 600 /swap.img mkswap /swap.img EOC only_if "test ! -f /swap.img -a `cat /proc/swaps | wc -l` -eq 1" end mount '/dev/null' do # swap file entry for fstab action :enable # cannot mount; only add to fstab device '/swap.img' fstype 'swap' end bash 'activate swap' do code 'swapon -ae' only_if "test `cat /proc/swaps | wc -l` -eq 1" end # iptablesç¡å¹ service "iptables" do action [:stop, :disable] end # yumé¢ä¿ %w{gcc make wget telnet readline-devel ncurses-devel gdbm-devel openssl-devel zlib-devel libyaml-devel httpd}.each do |p| package p do action :install end end # httpdè¨å® service "httpd" do action [:start, :enable] end template "httpd.conf" do path "/etc/httpd/conf/httpd.conf" source "httpd.conf.erb" mode 0644 notifies :restart, 'service[httpd]' end
baseã¬ã·ãã§ã¯ãOSã®åºæ¬è¨å®ããCentOSæ¨æºã®yumã³ãã³ãã§ã¤ã³ã¹ãã¼ã«ã§ããããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«ãApacheã®ã¤ã³ã¹ãã¼ã«ãè¨å®ãè¡ãããã«ãã¦ãã¾ãã
以ä¸æç²ã§ãã
# ã¹ã¯ããé åä½æ # åè:http://qiita.com/naoya@github/items/2059e3755962e907315e bash 'create swapfile' do user 'root' code <<-EOC dd if=/dev/zero of=/swap.img bs=1M count=1024 && chmod 600 /swap.img mkswap /swap.img EOC only_if "test ! -f /swap.img -a `cat /proc/swaps | wc -l` -eq 1" end mount '/dev/null' do # swap file entry for fstab action :enable # cannot mount; only add to fstab device '/swap.img' fstype 'swap' end bash 'activate swap' do code 'swapon -ae' only_if "test `cat /proc/swaps | wc -l` -eq 1" end
ä»åå©ç¨ããboxã§ã¯ã¹ã¯ããé åãç¡ãã£ãããã念ã®ããã¹ã¯ããé åãä½æãã¦ãã¾ãã
# iptablesç¡å¹ service "iptables" do action [:stop, :disable] end
éçºç°å¢ãªã®ã§iptablesã¯ç¡å¹ã¨ãã¾ãã
ããã§ã¯iptablesã®åæ¢ãã¾ãã次åä»®æ³ãã·ã³OSèµ·åæã«ã¯iptablesãèµ·åããªãããã«ãã¦ãã¾ãã
# yumé¢ä¿ %w{gcc make wget telnet readline-devel ncurses-devel gdbm-devel openssl-devel zlib-devel libyaml-devel httpd}.each do |p| package p do action :install end end
CentOSæ¨æºã®yumã³ãã³ãã§å°å
¥ãã¹ãããã±ã¼ã¸ãããã§ã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã
æ¬æ¥ã§ããã°packageãªã½ã¼ã¹ã¯OSã«åããã¦ãå®éã«å®è¡ãããã³ãã³ããyumã ã£ããapt-getã ã£ãããã¾ãããããã§ã¯CentOSã§å®è¡ãããåæã§æ¸ãã¦ãã¾ã£ã¦ãã¾ãã
# httpdè¨å® service "httpd" do action [:start, :enable] end
Apacheã®èµ·åãOSèµ·åæã«èªåçã«Apacheãèµ·åããããã«è¨å®ãã¦ãã¾ãã
template "httpd.conf" do path "/etc/httpd/conf/httpd.conf" source "httpd.conf.erb" mode 0644 notifies :restart, 'service[httpd]' end
chefã®templateã¨ããæ©è½ã使ã£ã¦ãhttpd.confãè¨å®ãã¦ãã¾ãã
ã¾ããè¨å®å¤æ´å¾ã¯notifiesã使ã£ã¦ãApacheãåèµ·åããããã«æå®ãã¦ãã¾ãã
httpd.confã¯chefã®templateã§è¨å®ãã¦ãããããtemplateã®è¨å®ãè¡ãã¾ãã
ãã®ã®ãã¡ã¤ã«ã®ãã¼ã¹ã¯ãå®éã¤ã³ã¹ãã¼ã«ããApacheã®httpd.conf(ä»®æ³ãã·ã³ã®/etc/httpd/conf/httpd.conf)ã®å
容ã§ãã
å¿
è¦ãªã¨ããã ã以ä¸ã®æ§ã«å¤æ°ãåãè¾¼ããå½¢ã«ãã¾ãã
â»ãã¡ã¤ã« : vagrant-cakephp3-sample/site-cookbooks/base/templates/default/httpd.conf.erb â»æç² Listen <%= node[:httpd][:port] %> DocumentRoot "<%= node[:httpd][:docroot] %>" <Directory "<%= node[:httpd][:docroot] %>"> ã </Directory>
nodeãã§æå®ããå¤æ°ã¯ãVagrantãã¡ã¤ã«ã®chef.json = ãã§è¨å®ããå
容ãèªã¿è¾¼ã¾ãã¾ãã
ããã«ãããå¯å¤é¨åã®ã¿ãVagrantãã¡ã¤ã«ã«è¨è¿°ãããã¨ãã§ãã¾ãã
ã¬ã·ã:mysql56
MySQL5.6ãã¤ã³ã¹ãã¼ã«ããã¬ã·ããä½æãã¾ãã
baseã¨ã¯å¥ã®cookbookã«ããçç±ã¯ãªãã¨ãªãã§ãã
æ¦è¦ã¨ãã¦ã¯ãOSæ¨æºããµã¼ããã¼ãã£ãå«ããyumã§MySQL5.6ãå°å ¥ããæ¹æ³ããªããããOracleãå ¬å¼ã§é å¸ãã¦ããrpmããã±ã¼ã¸ããã¦ã³ãã¼ãããã¤ã³ã¹ãã¼ã«ããæ¹å¼ãã¨ã£ã¦ãã¾ãã
ã¬ã·ããã¡ã¤ã«ã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
vagrant-cakephp3-sample/site-cookbooks/mysql56/recipes/default.rb
大é¨åã¯ä»¥ä¸ã®ãã¼ã¸ãã»ã¼ãã®ã¾ã¾ä½¿ããã¦ããã ãã¾ããã®ã§ã詳細ã¯ãã¡ãããåç
§ãã ããã
MySQL5.6のchefの書き方の決定版が出来たので公開する。 - nigoblog
以ä¸ã追å ããå
容ããç´¹ä»ãã¾ãã
# ãµã¼ãã¼èµ·å service "mysql" do action [:start, :enable] end
MySQLãµã¼ãã¼ãèµ·åããä»®æ³ãã·ã³èµ·åæã«ãèªåèµ·åããããã«è¨å®ãã¾ãã
# my.cnf template "my.cnf" do path "/usr/my.cnf" source "my.cnf.erb" mode 0644 notifies :restart, 'service[mysql]' end
Apacheè¨å®æã«ãå©ç¨ããtemplateæ©è½ã使ã£ã¦ãmy.cnfãè¨å®ãã¾ãã
# åæãã¹ã¯ã¼ãè¨å® # åè:http://blog.youyo.info/blog/2013/07/11/chef-mysql56/ script "Secure_Install" do interpreter 'bash' user "root" not_if "mysql -u root -p#{node[:mysql][:password]} -e 'show databases'" code <<-EOL export Initial_PW=`head -n 1 /root/.mysql_secret |awk '{print $(NF - 0)}'` mysql -u root -p${Initial_PW} --connect-expired-password -e "SET PASSWORD FOR root@localhost=PASSWORD('#{node[:mysql][:password]}');" mysql -u root -p#{node[:mysql][:password]} -e "SET PASSWORD FOR root@'127.0.0.1'=PASSWORD('#{node[:mysql][:password]}');" mysql -u root -p#{node[:mysql][:password]} -e "FLUSH PRIVILEGES;" EOL end
chefå®è¡æã«ãMySQLã®ãã¹ã¯ã¼ããèªåè¨å®ããããã«ãã¦ãã¾ãã
MySQL5.6ã¯åæãã¹ã¯ã¼ãã¨ãã¦ã©ã³ãã ãã¹ã¯ã¼ããè¨å®ããããããã¾ãã¯ãããå©ç¨ãã¦ãã¹ã¯ã¼ãè¨å®ã³ãã³ããå®è¡ãã¾ãã
ãã¹ã¯ã¼ãã¯Vagrantãã¡ã¤ã«ã§è¨å®ã§ããããã«ãã¦ãã¾ãã
ã¾ããåèãµã¤ãã§ã¯MySQLã¯ã©ã¤ã¢ã³ãã®ã¿ãã¤ã³ã¹ãã¼ã«ãã¦ããã¾ããããã¡ãã§ã¯Serverã®ã¤ã³ã¹ãã¼ã«ã«ã対å¿ãããããattributeã以ä¸ã«ããã«ãã¾ããã
â»ãã¡ã¤ã« : vagrant-cakephp3-sample/site-cookbooks/mysql56/attribute/default.rb versions = "5.6.15-1.el6.x86_64" default['mysql']['versions'] = versions default['mysql']['file_name'] = "MySQL-#{versions}.rpm-bundle.tar" default['mysql']['remote_uri'] = "http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.6/MySQL-#{versions}.rpm-bundle.tar" default['mysql']['rpm'] = [ { :rpm_file => "MySQL-server-#{versions}.rpm", :package_name => "MySQL-server" }, { :rpm_file => "MySQL-client-#{versions}.rpm", :package_name => "MySQL-client" }, { :rpm_file => "MySQL-devel-#{versions}.rpm", :package_name => "MySQL-devel" }, { :rpm_file => "MySQL-shared-#{versions}.rpm", :package_name => "MySQL-shared" } ]
ã¬ã·ã:php55
PHP5.5ãã¤ã³ã¹ãã¼ã«ããã¬ã·ããä½æãã¾ãã
baseã¨ã¯å¥ã®cookbookã«ããçç±ã¯ãªãã¨ãªï¼ï½ï½
æ¦è¦ã¨ãã¾ãã¦ã¯ããã¡ããOSæ¨æºã®yumã¬ãã¸ããªã«ã¯ç¡ãã®ã§ãremiã¨ãããµã¼ããã¼ãã£ã®ã¬ãã¸ããªããã¤ã³ã¹ãã¼ã«ããããã«ãã¦ãã¾ãã
ã¾ãã¯attributeã以ä¸ã®ããã«å®ç¾©ãã¾ãã
â»ãã¡ã¤ã« : vagrant-cakephp3-sample/site-cookbooks/php55/attribute/default.rb default['remi']['file_name'] = "remi-release-6.rpm" default['remi']['remote_uri'] = "http://rpms.famillecollet.com/enterprise/remi-release-6.rpm"
ã¬ã·ããã¡ã¤ã«ã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
â»ãã¡ã¤ã« : vagrant-cakephp3-sample/site-cookbooks/php55/recipe/default.rb # remi repositoryå°å ¥ remote_file "/tmp/#{node['remi']['file_name']}" do source "#{node['remi']['remote_uri']}" not_if { ::File.exists?("/tmp/#{node['remi']['file_name']}") } end package node['remi']['file_name'] do action :install provider Chef::Provider::Package::Rpm source "/tmp/#{node['remi']['file_name']}" end # phpã¤ã³ã¹ãã¼ã« %w{php php-devel php-mbstring php-mcrypt php-mysql php-phpunit-PHPUnit php-pecl-xdebug}.each do |p| package p do action :install options "--enablerepo=remi --enablerepo=remi-php55" end end # phpè¨å® template "php.ini" do path "/etc/php.ini" source "php.ini.erb" mode 0644 notifies :restart, 'service[httpd]' end
以ä¸æç²ã§ãã
# remi repositoryå°å ¥ remote_file "/tmp/#{node['remi']['file_name']}" do source "#{node['remi']['remote_uri']}" not_if { ::File.exists?("/tmp/#{node['remi']['file_name']}") } end package node['remi']['file_name'] do action :install provider Chef::Provider::Package::Rpm source "/tmp/#{node['remi']['file_name']}" end
remiå°å
¥ã®ããã®rpmããã±ã¼ã¸ããã¦ã³ãã¼ãããã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã
# phpã¤ã³ã¹ãã¼ã« %w{php php-devel php-mbstring php-mcrypt php-mysql php-phpunit-PHPUnit php-pecl-xdebug}.each do |p| package p do action :install options "--enablerepo=remi --enablerepo=remi-php55" end end
PHPé¢ä¿ã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã¾ãã
options "--enablerepo=remi --enablerepo=remi-php55" ãæå®ããã¨ããããã¢ã§ãã
# phpè¨å® template "php.ini" do path "/etc/php.ini" source "php.ini.erb" mode 0644 notifies :restart, 'service[httpd]' end
templateã®ä»çµã¿ã使ããphp.iniãè¨å®ãã¦ãã¾ãã
ã¾ããphp.iniå¤æ´æã¯Apacheãåèµ·åããããã«ãã¦ãã¾ãã
â»ãã¡ã¤ã« : vagrant-cakephp3-sample/site-cookbooks/php53/templates/default/php.ini.erb â»æç² date.timezone = '<%= node[:php][:timezone] %>'
timezoneã®è¨å®ãVagrantãã¡ã¤ã«å´ããèªã¿è¾¼ãããã«ãã¦ãã¾ãã
ã¾ã¨ã
é·ããªãã¾ããããVagrant,chefã使ããCakePHP3ãåä½ãããç°å¢ãä½ãã¨ããã¾ã§ãè¡ãã¾ããã
ææ¢ãç¶æ
ã§æ¥ããããããã¾ã§ããã®ã«æ°æ¥ãè²»ããã¦ãã¾ãã¾ããã
èªåã§ã¬ã·ããæ¸ãã¦ãããã¨ããã¨ãæåã¯ãããã試è¡é¯èª¤ã®é£ç¶ã«ãªãããã§ãã
ãããã¤ã³ãã©ãéçºç°å¢ãã³ã¼ãåãã¦ãgit管çã§ããã¨ããã®ã¯å¤§å¤é
åãæãã¾ããã
ãã¼ã éçºã®å ´åã¯éçºç°å¢ãçµ±ä¸ã§ãã¾ãããç§ã®å ´åã¯èªå®
ã®ãã¹ã¯ãããæ©ããã¼ããªã©ã®è¤æ°ãã·ã³éã§éçºç°å¢ãçµ±ä¸ãããã¨ããç®è«è¦ãããã¾ããã
ä»å¾ã¯Vagrant+chefã®éçºç°å¢ãå¸æããã¨å
±ã«ããããVPSãEC2çããchefã§ç®¡çãã¦ããããã¨æãã¾ãã