Skip to content

Commit

Permalink
Preparation for replacing PHP with PHP-FPM recipe
Browse files Browse the repository at this point in the history
Disabled existing PHP cookbook
Improved configuration handling for website definitions
Disabled folder sharing due to issues with file permissions
  • Loading branch information
SpenserJ committed Nov 9, 2012
1 parent 1463e91 commit 408ea80
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
3 changes: 2 additions & 1 deletion Vagrantfile
Expand Up @@ -18,7 +18,8 @@ Vagrant::Config.run do |config|
# folder, and the third is the path on the host to the actual folder.
# config.vm.share_folder "v-data", "/vagrant_data", "../data"

config.vm.share_folder "www-data", "/var/www/", "www/", :create => true
# Causes issues with file permissions. Change this to NFS shares in the future
# config.vm.share_folder "www-data", "/var/www/", "www/", :create => true

config.vm.customize do |vm|
vm.memory_size = 256
Expand Down
6 changes: 3 additions & 3 deletions chef-solo.json
Expand Up @@ -2,12 +2,12 @@
"run_list": ["recipe[hostname]", "recipe[vagrant_main]"],
"mysql": { "server_root_password": "root" },
"nginx": { "default_site_enabled": false, "user": "www", "log_dir": "/var/log/nginx" },
"php": { "fpm_user": "www", "fpm_group": "www" },
"set_fqdn": "lemp",
"set_fqdn_reload_method": "reload",
"phpmyadmin": true,
"website": {
"dev1.localhost": { "default": true, "php": true, "https": true },
"dev1.localhost": { "user": "www", "default": true, "php": true, "https": true },
"dev2.localhost": { "server_name": "dev2.localhost", "php": false, "https": true, "http": false, "enable": false },
"dev3.localhost": {}
"dev3.localhost": { "user": "www" }
}
}
4 changes: 4 additions & 0 deletions cookbooks/vagrant_main/definitions/website.rb
Expand Up @@ -30,6 +30,10 @@
end
end

if params[:php]
# Configure a PHP-FPM pool
end

directory "/var/log/nginx/#{params[:name]}" do
owner "root"
group "root"
Expand Down
28 changes: 13 additions & 15 deletions cookbooks/vagrant_main/recipes/default.rb
Expand Up @@ -39,7 +39,7 @@
end

require_recipe "build-essential"
require_recipe "php"
# require_recipe "chef-php-fpm"
require_recipe "nginx"
require_recipe "mysql::server"
require_recipe "git"
Expand All @@ -57,10 +57,10 @@
package package_name
end

php_pear "apc" do; action :install; end
php_pear "curl" do; action :install; end
php_pear "gd" do; action :install; end
php_pear "mysql" do; action :install; end
# php_pear "apc" do; action :install; end
# php_pear "curl" do; action :install; end
# php_pear "gd" do; action :install; end
# php_pear "mysql" do; action :install; end

cookbook_file "/etc/nginx/fastcgi_params" do
source "nginx/fastcgi_params"
Expand All @@ -76,29 +76,27 @@

node[:website].each do | name, website_config |
website_stock name do
server_name website_config[:server_name].nil? ? name : website_config[:server_name]
enable website_config[:enable] if !website_config[:enable].nil?
default website_config[:default] if !website_config[:default].nil?
http website_config[:http] if !website_config[:http].nil?
https website_config[:https] if !website_config[:https].nil?
php website_config[:php] if !website_config[:php].nil?

host_aliases.push website_config[:server_name].nil? ? name : website_config[:server_name]
website_config[:server_name] ||= name # Set the server_name to name, if it isn't set
website_config.each { |key, value| self.send(key, value) } # Set up the definition based on our website_config hash.
host_aliases.push website_config[:server_name] # Add this server name to our host alias list for /etc/hosts
end
end

if node[:phpmyadmin] == true
remote_file "/tmp/phpmyadmin.tar.gz" do
source "http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.5.3/phpMyAdmin-3.5.3-all-languages.tar.gz?r=&ts=#{Time.now.to_i}&use_mirror=autoselect"
owner "www"
group "www"
owner node[:nginx][:user]
group node[:nginx][:user]
mode "0644"
end

execute "rm -rf /var/www/phpmyadmin/*"
execute "tar -C /tmp -zxvf /tmp/phpmyadmin.tar.gz"
execute "mv /tmp/phpMyAdmin-*/* /var/www/phpmyadmin"
end

execute "sudo chown -R #{node[:nginx][:user]}:#{node[:nginx][:user]} /var/www"

hostsfile_entry '127.0.1.1' do
ip_address '127.0.1.1'
hostname 'localhost'
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/vagrant_main/templates/default/nginx/website.erb
Expand Up @@ -8,6 +8,8 @@ server {
server_name <%= @params[:server_name] %>;
root /var/www/<%= @params[:name] %>;

index <% if @params[:php] %>index.php <% end %>index.html;

access_log /var/log/nginx/<%= @params[:name] %>/access.log;
error_log /var/log/nginx/<%= @params[:name] %>/error.log;
<%- if @params[:php] %>
Expand Down

0 comments on commit 408ea80

Please sign in to comment.