Last active
August 29, 2015 14:24
-
-
Save burtlo/1112a7d501d86d2b184e to your computer and use it in GitHub Desktop.
Apache Cookbook Updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if @port != 80 -%> | |
Listen <%= @port %> | |
<% end -%> | |
<VirtualHost *:<%= @port %>> | |
ServerAdmin webmaster@localhost | |
DocumentRoot <%= @document_root %> | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride None | |
</Directory> | |
<Directory <%= @document_root %>> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride None | |
Order allow,deny | |
allow from all | |
</Directory> | |
</VirtualHost> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package "httpd" | |
#cookbook_file "/var/www/html/index.html" do | |
# mode "0644" | |
# source node["apache"]["indexfile"] | |
#end | |
execute "mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.disabled" do | |
only_if do | |
File.exist?("/etc/httpd/conf.d/welcome.conf") | |
end | |
notifies :restart, "service[httpd]" | |
end | |
node["apache"]["sites"].each do |site_name, site_data| | |
document_root = "/srv/apache/#{site_name}" | |
directory document_root do | |
mode "0755" | |
recursive true | |
end | |
template "/etc/httpd/conf.d/#{site_name}.conf" do | |
source "custom.erb" | |
mode "0644" | |
variables( | |
:document_root => document_root, | |
:port => site_data["port"] | |
) | |
notifies :restart, "service[httpd]" | |
end | |
template "#{document_root}/index.html" do | |
source "index.html.erb" | |
mode "0644" | |
variables( | |
:site_name => site_name, | |
:port => site_data["port"], | |
:nose => site_data["nose"] | |
) | |
end | |
end | |
service "httpd" do | |
action [ :start, :enable ] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h2>We love <%= @site_name %> with <%= @nose %> noses</h2> | |
<h2><%= node["ipaddress"] %> : <%= @port %></h2> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment