diff --git a/.gitignore b/.gitignore index 93f07f37b5..e76ab0f401 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ build/ vendor bin composer.phar + +/.vagrant \ No newline at end of file diff --git a/README.vagrant.md b/README.vagrant.md new file mode 100644 index 0000000000..c99de223e2 --- /dev/null +++ b/README.vagrant.md @@ -0,0 +1,38 @@ +# Using Symfony Standard Edition with Vagrant + +## Get Vagrant, if you don't have already + +From http://vagrantup.com/ + + +## startup vagrant + + vagrant up + +(this takes up to 15-20 minutes the first time, especially the "composer.phar install" part) + +## watch site + +go to http://192.168.22.22/app_dev.php and start playing. + +## PHP 5.4 + +If you want PHP 5.4, open the file `vagrant/puppet/manifests/main.pp` and uncomment the line +`include php54dotdeb` and comment out `include php53debian` so that it looks like this + +```` +include php54dotdeb +#include php53debian +```` + +## Mysql + +If you want to use Mysql, open the file `vagrant/puppet/manifests/main.pp` and uncomment the line +`include mysql` so that it looks like this + +```` +include mysql +```` + +The database is named `symfony`, the user is `symfony` and the password `Shub9aiJ` + diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000000..5827aa4998 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,24 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# -*- mode: ruby -*- +# vi: set ft=ruby : + +def Kernel.is_windows + processor, platform, *rest = RUBY_PLATFORM.split("-") + platform == "mingw32" +end + +Vagrant::Config.run do |config| + config.vm.define :main do |main_config| + main_config.vm.box = "liip-squeeze64" + main_config.vm.box_url = "http://vagrantbox-public.liip.ch/liip-squeeze64.box" + main_config.vm.network :hostonly, "192.168.22.22" + main_config.vm.share_folder "v-root", "/vagrant", ".", :nfs => !Kernel.is_windows + main_config.vm.provision :puppet, :module_path => "vagrant/puppet/modules" do |puppet| + puppet.manifests_path = "vagrant/puppet/manifests" + puppet.manifest_file = "main.pp" + end + end +end + diff --git a/vagrant/puppet/manifests/main.pp b/vagrant/puppet/manifests/main.pp new file mode 100644 index 0000000000..ca015b7c60 --- /dev/null +++ b/vagrant/puppet/manifests/main.pp @@ -0,0 +1,214 @@ +include apt_update +include php5 + +# If you want PHP 5.4 uncomment the following line, and comment out the php53debian line +# then run "vagrant provision" and you should have php 5.4 + +#include php54dotdeb +include php53debian + +include otherstuff +include apache +include groups +include composer +include symfony + +# If you want the mysql package and server, uncomment the following line +# then run "vagrant provision" +# The database is named `symfony`, the user is `symfony` and the password `Shub9aiJ` + +#include mysql + + +class apt_update { + exec { "aptGetUpdate": + command => "apt-get update", + path => ["/bin", "/usr/bin"] + } +} + +class apache { + package { "apache2-mpm-prefork": + ensure => latest, + require => Exec["aptGetUpdate"] + } + + package { "libapache2-mod-php5": + ensure => latest, + require => Package["apache2-mpm-prefork"], + notify => Service["apache2"], + } + + service { "apache2": + ensure => running, + require => Package["apache2-mpm-prefork"], + subscribe => File["main-vhost.conf", "httpd.conf", "mod_rewrite"] + } + + file { "main-vhost.conf": + path => '/etc/apache2/conf.d/main-vhost.conf', + ensure => file, + content => template('default/main-vhost.conf'), + require => Package["apache2-mpm-prefork"] + } + + file { "httpd.conf": + path => "/etc/apache2/httpd.conf", + ensure => file, + content => template('default/httpd.conf'), + require => Package["apache2-mpm-prefork"] + } + + file { "mod_rewrite": + path => "/etc/apache2/mods-enabled/rewrite.load", + ensure => "link", + target => "/etc/apache2/mods-available/rewrite.load", + require => Package["apache2-mpm-prefork"] + } +} + +class php5 { + + package { "php5-cli": + ensure => latest, + require => Exec["aptGetUpdate"], + } + + package { ["php5-xdebug", "php5-intl", "php5-sqlite"]: + ensure => latest, + require => Package["libapache2-mod-php5"], + notify => Service["apache2"] + } + + package { "php5-suhosin": + ensure => purged, + notify => Service["apache2"] + } + + file { "php-timezone.ini": + path => "/etc/php5/cli/conf.d/30-timezone.ini", + ensure => file, + content => template('default/php-timezone.ini'), + require => Package["php5-cli"] + } +} + +class php54dotdeb { + file { "dotdeb.list": + path => "/etc/apt/sources.list.d/dotdeb.list", + ensure => file, + owner => "root", + group => "root", + content => "deb http://ftp.ch.debian.org/debian squeeze main contrib non-free\ndeb http://packages.dotdeb.org squeeze all\ndeb-src http://packages.dotdeb.org squeeze all\ndeb http://packages.dotdeb.org squeeze-php54 all\ndeb-src http://packages.dotdeb.org squeeze-php54 all", + notify => Exec["dotDebKeys"] + } + +#there's a conflict when you upgrade from 5.3 to 5.4 in xdebug.ini. +# you don't need this, if you directly install 5.4 + file { "xdebug.ini": + path => "/etc/php5/mods-available/xdebug.ini", + ensure => file, + owner => "root", + group => "root", + source => "/usr/share/php5/xdebug/xdebug.ini", + require => Package['php5-xdebug'] + } + + exec { "dotDebKeys": + command => "wget -q -O - http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add -", + path => ["/bin", "/usr/bin"], + notify => Exec["aptGetUpdate"], + unless => "apt-key list | grep dotdeb" + } + + package { ["php5-apc", "php5-xhprof"]: + ensure => latest, + require => Package["libapache2-mod-php5"], + notify => Service["apache2"], + } + + package { ["phpapi-20090626", "php-apc"]: + ensure => purged, + } + +} + +class php53debian { + package { "php-apc": + ensure => latest, + require => Package["libapache2-mod-php5"] + } + + file { "dotdeb.list": + path => "/etc/apt/sources.list.d/dotdeb.list", + ensure => absent, + notify => Exec["aptGetUpdate"], + } +} + +class symfony { + + exec { "vendorsInstall": + cwd => "/vagrant", + command => "php composer.phar install", + timeout => 1200, + path => ["/bin", "/usr/bin"], + creates => "/vagrant/vendor", + logoutput => true, + require => Exec["composerPhar"], + } +} + +class composer { + exec { "composerPhar": + cwd => "/vagrant", + command => "curl -s http://getcomposer.org/installer | php", + path => ["/bin", "/usr/bin"], + creates => "/vagrant/composer.phar", + require => Package["php5-cli", "curl", "git"], + } +} + +class groups { + group { "puppet": + ensure => present, + } +} + +class otherstuff { + package { ["git", "curl", "nfs-common"]: + ensure => latest, + } +} + +class mysql { + service { "mysql": + ensure => running, + require => Package["mysql-server"], + } + + mysqldb { "symfony": + user => "symfony", + password => "Shub9aiJ" + } + + package { ["mysql-client", "mysql-server"]: + ensure => latest, + } + + package { ["php5-mysql"]: + ensure => latest, + require => Package["libapache2-mod-php5", "mysql-client"], + notify => Service["apache2"], + } + +} + +define mysqldb( $user, $password ) { + exec { "create-${name}-db": + unless => "/usr/bin/mysql -u${user} -p${password} ${name}", + command => "/usr/bin/mysql -uroot -p$mysql_password -e \"CREATE DATABASE ${name}; GRANT ALL ON ${name}.* TO ${user}@localhost IDENTIFIED BY '$password'; GRANT ALL ON ${name}.* TO ${user}@'%' IDENTIFIED BY '$password'; GRANT ALL ON ${name}.* TO root@'%'; FLUSH PRIVILEGES;\"", + require => Service["mysql"], + } +} + diff --git a/vagrant/puppet/modules/default/templates/httpd.conf b/vagrant/puppet/modules/default/templates/httpd.conf new file mode 100644 index 0000000000..cd667c3e9a --- /dev/null +++ b/vagrant/puppet/modules/default/templates/httpd.conf @@ -0,0 +1,4 @@ +User vagrant +Group vagrant + +EnableSendfile off \ No newline at end of file diff --git a/vagrant/puppet/modules/default/templates/main-vhost.conf b/vagrant/puppet/modules/default/templates/main-vhost.conf new file mode 100644 index 0000000000..b70a12f02a --- /dev/null +++ b/vagrant/puppet/modules/default/templates/main-vhost.conf @@ -0,0 +1,9 @@ + + + ServerAdmin admin@example.org + DocumentRoot /vagrant/web + ErrorLog /var/log/apache2/symfony-error_log + CustomLog /var/log/apache2/symfony-access_log combined + RewriteEngine On + + diff --git a/vagrant/puppet/modules/default/templates/php-timezone.ini b/vagrant/puppet/modules/default/templates/php-timezone.ini new file mode 100644 index 0000000000..c3d7967943 --- /dev/null +++ b/vagrant/puppet/modules/default/templates/php-timezone.ini @@ -0,0 +1 @@ +date.timezone = UTC diff --git a/web/app_dev.php b/web/app_dev.php index 5a05245a6e..9b8535ea9a 100644 --- a/web/app_dev.php +++ b/web/app_dev.php @@ -12,6 +12,7 @@ || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !in_array(@$_SERVER['REMOTE_ADDR'], array( '127.0.0.1', + '192.168.22.1', '::1', )) ) {