FOLLOWS ON FROM “CHEF install apache on AWS EC2 Ubuntu

Next we’ll setup MySQL. As the community site has a cookbook for MySQL, the process is similar to Apache. Again we’ll ask knife to fetch the cookbook from the community site for us.


cd cookbooks

knife cookbook site download mysql

tar zxf mysql*

rm mysql-*.tar.gz

Install mysql as both a client and server as we only have the one machine.

cd mysql/recipes/

cd ../../phpapp


vi metadata.rb # and add the line

depends “mysql”


vi recipes/default.rb # and after the include apache2 add the following lines

include_recipe “mysql::client”

include_recipe “mysql::server”

cd ..


knife cookbook site download openssl

tar zxf openssl*.tar.gz

rm openssl*.tar.gz

knife cookbook site download build-essential

tar zxf build-essential-*.tar.gz

rm build-essential-*.tar.gz

knife cookbook site download homebrew

tar zxf homebrew-*.tar.gz

rm homebrew-*.tar.gz

knife cookbook site download windows

tar zxf windows-*.tar.gz

rm windows-*.tar.gz

knife cookbook site download chef_handler

tar zxf chef_handler-*.tar.gz

rm chef_handler-*.tar.gz

knife cookbook site download chef-sugar

tar zxf chef-sugar-*.tar.gz

rm chef-sugar-*.tar.gz

knife cookbook site download seven_zip

tar zxf ..

rm ..

knife cookbook site download mingw

tar zxf ..

rm ..

vi mysql/metadata.rb # remove the version numbers for openssl and build_essential

depends ‘openssl’
depends ‘build-essential’


depends ‘openssl’
depends ‘build-essential’
cd ..
We need to define a root password for MySQL. This is an attribute. In Chef, attributes are values which we use to configure our applications or platform. An attribute could be a port number for Apache. Often a sensible default is specified inside a cookbook. Such a default for a web server port would be 80. There’s no sensible default MySQL password, so we need to specify one. Open web.json.
vi web.json # and amend to look like:
“mysql”: {“server_root_password”: “808052769e2c6d909027a2905b224bad”, “server_debian_password”: “569d1ed2d46870cc020fa87be83af98d”, “server_repl_password”: “476911180ee92a2ee5a471f33340f6f4”},
“run_list”: [ “recipe[apt]”, “recipe[phpapp]” ]
chef-solo -c solo.rb -j web.json

Next Page CHEF install PHP on AWS EC2 Ubuntu