�G���^�[�v���C�Y�����@�\���[�����Ă���Chef���g���č��������x�̍����T�[�o�[�C���t�����\�z�^�Ǘ�������@�ɂ��ĉ������A�ځB����́AWordPress���\�z���V�s�̍Ō�̎d�グ�Ƃ��āASQL����Template�Ƃ��č쐬���āAMySQL��ݒ肷�������Cookbook���쐬���A���s���Ă݂܂��B
�@6��ɂ킽��A�ڂ��A���ŏI��ƂȂ�܂����BWordPress���\�z���V�s�̍Ō�̎d�グ�̕����ƁA��B�̂��߂̃|�C���g�ɂ��ĐG��܂��B
�@�܂��A�A�ڑ�3��́uWordPress�\�z�Ŋw�ԁA�T�[�o�[�\�z��Ƃ�Chef��Cookbook�Ƃ��ċL�q���邽�߂̃|�C���g�v�ʼn�������u�\�z���̑O������v�ƁuCookbook�̍쐬���j�v���ēx�L�ڂ��Ă����܂��B
�@�O��́uWordPress�̃_�E�����[�h�^�z�u�ƃo�[�`�����z�X�g�ݒ�Ō���Chef�̕ϐ���Attribute�̏������̊�{��Template���p�v�ŁA5.�܂Ŋ������Ă��܂��B�����6.�ɂ��ċL�ڂ��܂��B
�y1�z���|�W�g���ݒ聨�O��Cookbook�𗘗p
�y2�zApache�APHP�AMySQL�̃C���X�g�[����Resource�Œ�`
�y3�zWordPress�̃_�E�����[�h�Ɖ𓀁�Resource�Œ�`
�y4�z�o�[�`�����z�X�g�ݒ聨Template���g�p
�y5�zWordPress�pMySQL�ݒ聨Template���g�p
�@���̂�������́y5�z�ɂ��č�Ƃ�i�߂Ă����܂��B
�@�ucookbook/wordpress01/recipes/default.rb�v��MySQL�ݒ�p�̏�����NjL���܂��B����NjL����������10�s�ڂ�66�`69�s�ڂł��B
package ['httpd', 'httpd-devel', 'mysql', 'mysql-server', 'mysql-devel', 'php', 'php-mysql'] do action :install end filename = "#{node['wordpress']['wp_tar_name']}" install_dir = "#{node['wordpress']['wp_dir']}" remote_uri = "#{node['wordpress']['wp_tar_uri']}" file_checksum = "#{node['wordpress']['wp_tar_sum']}" httpd_conf_dir = "#{node['wordpress']['httpd_conf_dir']}" mysql_pw = "#{node['wordpress']['mysql_pw']}" #�C���X�g�[���f�B���N�g���쐬 directory "#{install_dir}" do recursive true mode 0755 owner "apache" group "apache" action :create end #WordPress�_�E�����[�h remote_file "/tmp/#{filename}" do source "#{remote_uri}" checksum "#{file_checksum}" end #WordPress�z�u script "install_wordpress" do interpreter "bash" user "root" code <<-EOL install -d #{install_dir} tar zxvf /tmp/#{filename} -C #{install_dir} EOL end #httpd.conf�z�u template "httpdconf" do path "#{httpd_conf_dir}httpd.conf" source "httpdconf.erb" mode 0644 end #wordpress�f�B���N�g��permission�ύX directory "#{install_dir}/wordpress" do recursive true mode 0755 owner "apache" group "apache" end service "httpd" do action :start end service "mysqld" do action :start end template "sql-for-wordpress" do path "/tmp/wordpress.sql" source "wordpress.sql.erb" mode 0644 end execute "mysql-create-user" do command "mysql -u root -p#{mysql_pw} < /tmp/wordpress.sql" action :run end
�@MySQL�̐ݒ�́A�Θb�`������{�ƂȂ邽�߃��V�s�ŕ\������̂���������ł��B�����SQL����Template�Ƃ��č쐬���Ă����A�Ώۂ�MySQL�ɑ��Ď��s������Ƃ��������Ŏ������܂����B
�@MySQL��root�p�X���[�h�p�Ɂumysql_pw�v�Ƃ���Attribute��lj����܂����̂ŁAcookbook/wordpress01/attributes/default.rb�ɂ��lj����Ă����܂��B�lj������̂́A7�s�ڂł��B
default['wordpress']['wp_tar_name'] = 'wordpress-4.2.2-ja.tar.gz' default['wordpress']['wp_dir'] = '/var/www/ec2.tokyo' default['wordpress']['wp_tar_uri'] = 'https://ja.wordpress.org/wordpress-4.2.2-ja.tar.gz' default['wordpress']['wp_tar_sum'] = '7e34ba580aed16c4fd769f033b0e7fa79b7c5813ba52e4496f14da0ac4451373' default['wordpress']['httpd_conf_dir'] = '/etc/httpd/conf/' default['wordpress']['vhost_domain'] = 'ec2.tokyo' default['wordpress']['mysql_pw'] = '[MySQL��root�p�X���[�h]'
�@����V�K�쐬����cookbook/wordpress01/templates/default/wordpress.sql.erb�̓��e�͈ȉ��̒ʂ�ł��BDB���E���[�U�[���E�p�X���[�h�͕�����₷���悤�Ɂuwordpress�v�Ƃ��Ă���܂����A���^�p�̍ۂ͓K�X�K�ȕ�������w�肵�Ă��������B
CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON *.* TO wordpress@"%" IDENTIFIED BY 'wordpress' WITH GRANT OPTION; FLUSH PRIVILEGES;
�@�����WordPress�����\�z����Cookbook���������܂����B
Copyright © ITmedia, Inc. All Rights Reserved.