Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
miya0001 committed Jun 13, 2015
2 parents 7da6b9e + 1c95ad8 commit cb196dc
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ Vagrant.configure(2) do |config|
:url => 'http://' << File.join(_conf['hostname'], _conf['wp_home']),
:wpdir => File.join(_conf['document_root'], _conf['wp_siteurl']),
:dbhost => _conf['db_host']
},
:phpenv => {
:php_version => _conf['php_version']
}
},
:rbenv => {
Expand Down
6 changes: 6 additions & 0 deletions provision/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,9 @@ disable_vccw_cookbook: false
#
user: vagrant
group: vagrant


#
# phpenv
#
php_version: default
4 changes: 4 additions & 0 deletions provision/site-cookbooks/vccw/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@

default[:vccw][:user] = 'vagrant'
default[:vccw][:group] = 'vagrant'

default[:vccw][:phpenv][:phpenv_root] = '/usr/local/phpenv'
default[:vccw][:phpenv][:install] = 'curl -L https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh | sh'
default[:vccw][:phpenv][:php_version] = 'default'
1 change: 1 addition & 0 deletions provision/site-cookbooks/vccw/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

include_recipe 'ruby_build'
include_recipe 'rbenv::system'
include_recipe 'vccw::phpenv'

packages = %w{gettext subversion npm lftp sshpass}

Expand Down
122 changes: 122 additions & 0 deletions provision/site-cookbooks/vccw/recipes/phpenv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# encoding: utf-8
# vim: ft=ruby expandtab shiftwidth=2 tabstop=2

require 'shellwords'

if /^[0-9]/ =~ node[:vccw][:phpenv][:php_version].to_s

packages = %w{httpd-devel libxml2-devel libcurl-devel libjpeg-turbo-devel libpng-devel giflib-devel gd-devel libmcrypt-devel sqlite-devel libtidy-devel libxslt-devel}

packages.each do |pkg|
package pkg do
action [:install, :upgrade]
end
end

execute node[:vccw][:phpenv][:install] do
user "root"
group "root"
environment ({
'PHPENV_ROOT' => node[:vccw][:phpenv][:phpenv_root]
})
not_if { ::File.exists?(node[:vccw][:phpenv][:phpenv_root]) }
end

execute node[:vccw][:phpenv][:install] do
user "root"
group "root"
environment ({
'PHPENV_ROOT' => node[:vccw][:phpenv][:phpenv_root],
'UPDATE' => 'yes'
})
only_if { ::File.exists?(node[:vccw][:phpenv][:phpenv_root]) }
end

template "/etc/profile.d/phpenv.sh" do
source "phpenv.sh.erb"
owner "root"
group "root"
mode "0755"
variables(
:phpenv_root => node[:vccw][:phpenv][:phpenv_root]
)
action :create_if_missing
end

directory File.join(node[:vccw][:phpenv][:phpenv_root], "/shims") do
recursive true
owner "root"
group "root"
mode "0755"
action :create
end

directory File.join(node[:vccw][:phpenv][:phpenv_root], "/versions") do
recursive true
owner "root"
group "root"
mode "0755"
action :create
end

directory File.join(node[:vccw][:phpenv][:phpenv_root], "/plugins") do
recursive true
owner "root"
group "root"
mode "0755"
action :create
end

git File.join(node[:vccw][:phpenv][:phpenv_root], "/plugins/php-build") do
repository "https://github.com/php-build/php-build.git"
reference "master"
user "root"
group "root"
action :sync
end

template File.join(node[:vccw][:phpenv][:phpenv_root], "/plugins/php-build/share/php-build/default_configure_options") do
source "default_configure_options.erb"
owner "root"
group "root"
mode "0755"
action :create
end

execute "install-php" do
user "root"
group "root"
command <<-EOF
rm -fr /tmp/php-build*
#{File.join(node[:vccw][:phpenv][:phpenv_root], '/bin/phpenv')} install #{Shellwords.shellescape(node[:vccw][:phpenv][:php_version].to_s)}
#{File.join(node[:vccw][:phpenv][:phpenv_root], '/bin/phpenv')} global #{Shellwords.shellescape(node[:vccw][:phpenv][:php_version].to_s)}
#{File.join(node[:vccw][:phpenv][:phpenv_root], '/bin/phpenv')} rehash
EOF
environment ({
'PHPENV_ROOT' => node[:vccw][:phpenv][:phpenv_root]
})
returns [0, 1]
notifies :restart, "service[apache2]"
end

template File.join(node[:vccw][:phpenv][:phpenv_root], 'versions/', node[:vccw][:phpenv][:php_version].to_s, '/etc/conf.d/vccw.ini') do
source "vccw.ini.erb"
owner "root"
group "root"
mode "0644"
variables(:directives => node['php']['directives'])
notifies :restart, "service[apache2]"
end

template "/etc/sudoers.d/phpenv" do
source "sudoers.erb"
owner "root"
group "root"
mode "0400"
variables(
:phpenv_root => node[:vccw][:phpenv][:phpenv_root]
)
action :create
end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--without-pear
--with-gd
--enable-sockets
--with-jpeg-dir=/usr
--with-png-dir=/usr
--enable-exif
--enable-zip
--with-zlib
--with-zlib-dir=/usr
--with-kerberos
--with-openssl
--with-mcrypt=/usr
--enable-soap
--enable-xmlreader
--with-xsl
--enable-ftp
--enable-cgi
--with-curl=/usr
--with-tidy
--with-xmlrpc
--enable-sysvsem
--enable-sysvshm
--enable-shmop
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--with-mysql-sock=/var/lib/mysql/mysql.sock
--with-pdo-sqlite
--enable-pcntl
--with-readline
--enable-mbstring
--enable-bcmath
--with-apxs2=/usr/sbin/apxs
2 changes: 0 additions & 2 deletions provision/site-cookbooks/vccw/templates/default/motd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
\__\::::/ \ \::/ \ \::/ \ \::/
~~~~ \__\/ \__\/ \__\/

VCCW v<%= @version %>
http://vccw.cc/

Initial code by Takayuki Miyauchi.
https://github.com/miya0001

6 changes: 6 additions & 0 deletions provision/site-cookbooks/vccw/templates/default/phpenv.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# encoding: utf-8
# vim: ft=ruby expandtab shiftwidth=2 tabstop=2

export PHPENV_ROOT="<%= @phpenv_root %>"
export PATH="${PHPENV_ROOT}/bin:$PATH"
eval "$(phpenv init -)"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Defaults secure_path = <%= @phpenv_root %>/shims:<%= @phpenv_root %>/bin:/sbin:/bin:/usr/sbin:/usr/bin
3 changes: 3 additions & 0 deletions provision/site-cookbooks/vccw/templates/default/vccw.ini.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% @directives.sort_by { |key, val| key }.each do |directive, value| -%>
<%= "#{directive}=\"#{value}\"" %>
<% end -%>

0 comments on commit cb196dc

Please sign in to comment.