Continued from CHEF configure WordPress on AWS EC2 Ubuntu

We need to define a template for the Apache VirtualHost that will run WordPress.

cd cookbooks/phpapp

vi templates/default/site.conf.erb

# Auto generated by Chef. Changes will be overwritten.

 

ServerName

DocumentRoot

 

Options FollowSymLinks

AllowOverride FileInfo Options

AllowOverride All

Order allow,deny

Allow from all

 

 

Options FollowSymLinks

AllowOverride None

 

 

 

We’ll now use a new resource which is provided by the apache2 cookbook called web_app to create an Apache VirtualHost using our template site.conf.erb.

vi recipes/default.rb

#Disable the default apache site , i.e. make the following change which is just after the include_recipe lines

apache_site “default” do

enable false

end

TO

apache_site “default” do

enable true

end

# Then add the following lines at the end of the file.

web_app ‘phpapp’ do

template ‘site.conf.erb’

docroot node[‘phpapp’][‘path’]

server_name node[‘phpapp’][‘server_name’]

end

vi attributes/default.rb # and add the line

default[‘phpapp’][‘server_name’] = “phpapp”

If your server has a hostname setup in DNS we should override our default attribute and specify the actual name in web.json. If there is no proper hostname defined ignore this step.

cd ../..

vi web.json # and change the contents to

{

“mysql”: {“server_root_password”: “808052769e2c6d909027a2905b224bad”, “server_debian_password”: “569d1ed2d46870cc020fa87be83af98d”, “server_repl_password”: “476911180ee92a2ee5a471f33340f6f4”},

“phpapp”: {“db_password”: “212b09752d173876a84d374333ae1ffe”, “server_name”: “###.###.###”},

“run_list”: [ “recipe[apt]”, “recipe[phpapp]” ]

}

chef-solo -c solo.rb -j web.json

Visit the web server and see if that’s worked.

http:///phpapp/wp-admin/install.php