WordPress�‹��\�z�ɂ�����MySQL�̐ݒ��Chef��B�̃|�C���g�F�T�[�o�[�Ǘ��҂̂��߂�Chef������i�I�j�i1/3 �y�[�W�j

�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

» 2015�N09��10�� 05��00�� ���J
[��쑽�����C��IT]

�ŏI���WordPress�‹��\�z���V�s�̍Ō�̎d�グ

uT[o[Ǘ҂̂߂ChefṽCfbNX

�A�ږڎ�

�@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

WordPress�\�z�‹��̑O�����

  1. OS��CentOS 6.6���g�p
  2. Apache��MySQL�͓���T�[�o�[���i�u�m�[�h�v�j�ɃC���X�g�[������
  3. MySQL��Remi���|�W�g�����g�p���ăC���X�g�[������
  4. �uwp.example.com�v�Ƃ����o�[�`�����z�X�g���쐬���A�z�X�g�����uwp.example.com�v�A�h�L�������g���[�g���u/var/www/wp.example.com/wordpress�v�Ƃ���
  5. �G���[���O�ƃJ�X�^�����O�̃t�@�C�������ȉ��̒ʂ�Ƃ���
    • wp.example.com-error_log
    • wp.example.com-access_log
  6. MySQL��wordpress���[�U�[��wordpress�f�[�^�x�[�X���쐬���A���[�U�[�Ƀf�[�^�x�[�X�ւ̃A�N�Z�X����t�^����

�@�O��́uWordPress�̃_�E�����[�h�^�z�u�ƃo�[�`�����z�X�g�ݒ�Ō���Chef�̕ϐ���Attribute�̏������̊�{��Template���p�v�ŁA5.�܂Ŋ������Ă��܂��B�����6.�ɂ‚��ċL�ڂ��܂��B

WordPress�\�zCookbook�̍쐬���j

�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

SQL����Template�Ƃ��č쐬���āAWordPress�p��MySQL��ݒ�

�@�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

�@�@�@�@�@�@ 1|2|3 ���̃y�[�W��

Copyright © ITmedia, Inc. All Rights Reserved.

'; this.insertTarget = document.querySelector('#cmsBody .subscription') || document.querySelector('#cmsBody .inner'); }; BodyAdIMSWithCCE.prototype = Object.create(BodyAdContent.prototype); BodyAdIMSWithCCE.prototype.activate = function () { refreshGam('InArtSpecialLink'); } // global reference window.itm = itm; //entry point BodyAdEventBase.polyfill(); const bodyAdManager = BodyAdManager.getInstance(); bodyAdManager.addEventListener(BodyAdManager.EVENTS.READY, function (ev) { bodyAdManager.loadAdvertise(); }); bodyAdManager.init(); })();
�X�|���T�[����̂��m�点PR

���ڂ̃e�[�}

Microsoft  WindowsőO2025
AI for GWjAO
[R[h^m[R[h Zg by IT - ITGWjArWlX̒SŊ􂷂gD
Cloud Native Central by IT - XP[uȔ\͂gD
�V�X�e���J���m�E�n�E �y�����i�r�zPR
���Ȃ��ɂ������߂̋L��PR

RSS�ɂ‚���

�A�C�e�B���f�B�AID�ɂ‚���

���[���}�K�W���o�^

��IT�̃��[���}�K�W���́A �������A���ׂĖ����ł��B���Ѓ��[���}�K�W�������w�ǂ��������B