├── .gitignore ├── README.md ├── Vagrantfile ├── config.yaml ├── localhost ├── index.php └── phpinfo.php └── vagrant ├── etc └── nginx │ ├── nginx.conf │ └── sites-enabled │ ├── angular-skeleton.local.conf │ ├── default │ └── phalcon-module.local.conf ├── install.sh ├── postinstall.sh └── scripts ├── dbs ├── mysql.sh └── pgsql.sh ├── lynx.sh ├── nginx.sh ├── nodejs.sh ├── phalcon.sh ├── php.sh ├── pre-installed-projects.sh └── zephir.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vagrant -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | My Vagrant Development Box 2 | ========================== 3 | 4 | [![Gitter](http://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg?style=flat-square)](https://gitter.im/ovr/perfect-php-vagrant?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 5 | [![Author](http://img.shields.io/badge/author-@ovr-blue.svg?style=flat-square)](https://twitter.com/ovrweb) 6 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) 7 | 8 | > Start your development on virtual machine by Vagrant technology 9 | 10 | 11 | 12 | Software: 13 | 14 | * PHP 5.6 (+default+json+memcache+fpm+curl) 15 | * [Nginx](http://nginx.org/) (Web server) 16 | * [Zephir Language](https://github.com/phalcon/zephir) (Compiled high level language aimed to the creation of C-extensions for PHP) 17 | * [Phalcon 2](https://github.com/phalcon/cphalcon/tree/2.0.0) (Framework for PHP on Zephir) 18 | * [Lynx](https://github.com/lynx/lynx) (ORM/DBAL for PHP on Zephir) 19 | * [Composer](https://getcomposer.org/) (Dependency Manager for PHP) 20 | 21 | Frontend (global env): 22 | 23 | * [NodeJS](https://nodejs.org/) 24 | * [Bower](http://bower.io/) 25 | * [Gulp](http://gulpjs.com/) 26 | * [Grunt-cli](https://github.com/gruntjs/grunt-cli) 27 | 28 | Default vm parameters: 29 | 30 | ```yaml 31 | name: phalcon2-dev 32 | hostname: vm.local 33 | box: ubuntu/trusty64 34 | provider: virtualbox 35 | gui: false 36 | ram: 512 37 | cpus: 1 38 | ip: 10.10.10.150 39 | projects-folder: "~/projects" 40 | ``` 41 | 42 | ## Pre-installed projects 43 | 44 | * [Phalcon Full Skeleton Edition](https://github.com/ovr/phalcon-module-skeleton) on [http://phalcon-module.local/](http://phalcon-module.local/) 45 | * [Angular Skeleton](https://github.com/ovr/angular-skeleton) on [http://angular-skeleton.local/](http://angular-skeleton.local/) 46 | 47 | ## Getting Started 48 | 49 | 1. Download and install [VirtualBox](https://www.virtualbox.org/) 50 | 2. Download and install [Vagrant](http://www.vagrantup.com/) 51 | 3. Install project 52 | 53 | Don't forget to install vagrant host manager plugin: 54 | 55 | ```bash 56 | vagrant plugin install vagrant-hostmanager 57 | ``` 58 | 59 | and vagrant cachier (to cache shared packages installation): 60 | 61 | ```bash 62 | vagrant plugin install vagrant-cachier 63 | ``` 64 | 65 | ## Installation 66 | 67 | ```bash 68 | git clone https://github.com/ovr/perfect-php-vagrant.git 69 | cd perfect-php-vagrant 70 | nano config.yaml 71 | vagrant up 72 | ``` 73 | 74 | Weight when installation will be finished and open `http://servername/` to see info about server 75 | 76 | ## Troubleshooting 77 | 78 | If after `vagrant up` you are getting something like it: 79 | 80 | ```sh 81 | ... 82 | default: Warning: Connection timeout. Retrying... 83 | default: Warning: Connection timeout. Retrying... 84 | default: Warning: Connection timeout. Retrying... 85 | ``` 86 | 87 | You need to diagnose an error by setuping GUI to true in `config.yaml` 88 | 89 | ```yaml 90 | gui: true 91 | ``` 92 | 93 | 94 | ## Vagrant 95 | 96 | To stop and reinstall machine please run 97 | 98 | ```bash 99 | vagrant halt && vagrant destroy -f && vagrant up 100 | ``` 101 | 102 | License 103 | ------- 104 | 105 | This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information. 106 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # Require YAML module 2 | require 'yaml' 3 | 4 | # Read YAML file with box details 5 | configuration = YAML.load_file('config.yaml') 6 | 7 | Vagrant.require_version '>= 1.6.0' 8 | 9 | Vagrant.configure(2) do |config| 10 | config.vm.box = configuration["box"] 11 | config.vm.hostname = configuration["hostname"] 12 | 13 | config.vm.network "private_network", ip: configuration["ip"] 14 | 15 | config.vm.provider configuration["provider"] do |vb| 16 | vb.name = configuration["name"] 17 | vb.memory = configuration["ram"] 18 | vb.gui = configuration["gui"] 19 | vb.cpus = configuration["cpus"] 20 | 21 | vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] 22 | end 23 | 24 | if Vagrant.has_plugin?('vagrant-hostmanager') 25 | hosts = Array.new() 26 | 27 | hosts.push("phalcon-module.local"); 28 | hosts.push("angular-skeleton.local"); 29 | hosts.push("phalcon-rest.local"); 30 | hosts.push("phalcon-lynx-rest.local"); 31 | 32 | config.hostmanager.enabled = true 33 | config.hostmanager.manage_host = true 34 | config.hostmanager.ignore_private_ip = false 35 | config.hostmanager.include_offline = false 36 | config.hostmanager.aliases = hosts 37 | end 38 | 39 | if Vagrant.has_plugin?("vagrant-cachier") 40 | config.cache.scope = :box 41 | end 42 | 43 | config.vm.synced_folder configuration["projects-folder"], "/var/www/projects", create: true, group: "www-data", owner: "www-data", :mount_options => ["dmode=777","fmode=666"] 44 | config.vm.synced_folder "./localhost", "/var/www/localhost", create: true, group: "www-data", owner: "www-data", :mount_options => ["dmode=777","fmode=666"] 45 | 46 | config.vm.provision :shell, :path => "vagrant/install.sh" 47 | config.vm.provision :shell, :path => "vagrant/scripts/php.sh" 48 | config.vm.provision :shell, :path => "vagrant/scripts/zephir.sh" 49 | config.vm.provision :shell, :path => "vagrant/scripts/phalcon.sh" 50 | config.vm.provision :shell, :path => "vagrant/scripts/lynx.sh" 51 | config.vm.provision :shell, :path => "vagrant/scripts/pre-installed-projects.sh" 52 | config.vm.provision :shell, :path => "vagrant/scripts/dbs/mysql.sh" 53 | config.vm.provision :shell, :path => "vagrant/scripts/nginx.sh" 54 | config.vm.provision :shell, :path => "vagrant/scripts/nodejs.sh" 55 | config.vm.provision :shell, :path => "vagrant/postinstall.sh" 56 | end 57 | -------------------------------------------------------------------------------- /config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: phalcon2-dev 3 | hostname: vm.local 4 | box: ubuntu/vivid64 5 | provider: virtualbox 6 | gui: true 7 | ram: 512 8 | cpus: 1 9 | ip: 10.10.10.150 10 | projects-folder: "~/projects" 11 | -------------------------------------------------------------------------------- /localhost/phpinfo.php: -------------------------------------------------------------------------------- 1 | > /etc/resolvconf/resolv.conf.d/head 4 | echo "nameserver 8.8.4.4" >> /etc/resolvconf/resolv.conf.d/head 5 | sudo service resolvconf restart 6 | 7 | sudo apt-get -y update 8 | sudo apt-get -y upgrade 9 | sudo apt-get -y dist-upgrade 10 | 11 | sudo apt-get install -y git unzip htop memcached 12 | 13 | cd ~ 14 | mkdir -p build 15 | -------------------------------------------------------------------------------- /vagrant/postinstall.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo service php5-fpm restart 4 | -------------------------------------------------------------------------------- /vagrant/scripts/dbs/mysql.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Installing MySQL..." 4 | 5 | PASSWORD='' 6 | 7 | sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password PASS" 8 | sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password PASS" 9 | 10 | sudo apt-get install -y mysql-server mysql-client 11 | sudo apt-get install -y php5-mysql 12 | 13 | mysql -uroot -pPASS -e "SET PASSWORD = PASSWORD('');" 14 | sudo service mysql restart 15 | 16 | mysql -uroot -e 'CREATE DATABASE `phalcon-module-skeleton` CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;' 17 | mysql -uroot phalcon-module-skeleton < /var/www/projects/ovr/phalcon-module-skeleton/scheme/dump.sql -------------------------------------------------------------------------------- /vagrant/scripts/dbs/pgsql.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Installing PgSQL..." 4 | 5 | PASSWORD='' 6 | 7 | sudo apt-get install -y postgresql postgresql-contrib 8 | sudo apt-get install -y php5-pgsql 9 | 10 | sudo service postgresql start 11 | sudo -u postgres psql -c "CREATE ROLE root LOGIN UNENCRYPTED PASSWORD '$PASSWORD' SUPERUSER;" 12 | sudo service postgresql restart 13 | -------------------------------------------------------------------------------- /vagrant/scripts/lynx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Installing Lynx..." 4 | 5 | cd ~/build 6 | git clone https://github.com/lynx/lynx.git 7 | cd lynx 8 | zephir install 9 | 10 | echo extension=lynx.so > /etc/php5/cli/conf.d/30-lynx.ini 11 | echo extension=lynx.so > /etc/php5/fpm/conf.d/30-lynx.ini 12 | -------------------------------------------------------------------------------- /vagrant/scripts/nginx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Installing Nginx..." 4 | 5 | sudo apt-get -y install nginx-full 6 | 7 | sudo cp /vagrant/vagrant/etc/nginx/nginx.conf /etc/nginx/nginx.conf 8 | sudo rm -rf /etc/nginx/sites-enabled/* 9 | sudo cp /vagrant/vagrant/etc/nginx/sites-enabled/* /etc/nginx/sites-enabled/ 10 | 11 | sudo service nginx restart 12 | -------------------------------------------------------------------------------- /vagrant/scripts/nodejs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Installing NodeJS..." 4 | 5 | sudo apt-get install -y nodejs npm 6 | sudo ln -s /usr/bin/nodejs /usr/bin/node 7 | sudo npm -g update npm 8 | 9 | echo "Installing Gulp and Bower for global env..." 10 | 11 | sudo npm -g -q install bower 12 | sudo npm -g -q install gulp 13 | sudo npm -g -q install grunt-cli 14 | -------------------------------------------------------------------------------- /vagrant/scripts/phalcon.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Installing Phalcon 2..." 4 | 5 | cd ~/build 6 | wget -o /dev/null -O phalcon.zip https://github.com/phalcon/cphalcon/archive/master.zip 7 | unzip phalcon.zip -d cphalcon > /dev/null 8 | rm phalcon.zip 9 | cd cphalcon/cphalcon-master 10 | zephir install 11 | 12 | #git clone -b 2.0.0 https://github.com/phalcon/cphalcon.git 13 | #cd cphalcon 14 | #zephir install 15 | 16 | sudo echo extension=phalcon.so > /etc/php5/mods-available/phalcon.ini 17 | sudo php5enmod phalcon 18 | -------------------------------------------------------------------------------- /vagrant/scripts/php.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Installing PHP..." 4 | 5 | sudo apt-get -y install php5-cli php5-dev php5-fpm php5-curl php5-memcache 6 | 7 | sudo curl -sS https://getcomposer.org/installer | php 8 | sudo mv composer.phar /usr/local/bin/composer 9 | -------------------------------------------------------------------------------- /vagrant/scripts/pre-installed-projects.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ ! -d "/var/www/projects/ovr" ]; then 4 | mkdir /var/www/projects/ovr 5 | fi 6 | 7 | if [ ! -d "/var/www/projects/ovr/angular-skeleton" ]; then 8 | git clone https://github.com/ovr/angular-skeleton.git /var/www/projects/ovr/angular-skeleton 9 | fi 10 | 11 | if [ ! -d "/var/www/projects/ovr/phalcon-module-skeleton" ]; then 12 | git clone https://github.com/ovr/phalcon-module-skeleton.git /var/www/projects/ovr/phalcon-module-skeleton 13 | cd /var/www/projects/ovr/phalcon-module-skeleton 14 | cp ./application/config/parameters.php.dist ./application/config/parameters.php 15 | composer install -o 16 | fi 17 | -------------------------------------------------------------------------------- /vagrant/scripts/zephir.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Installing Zephir..." 4 | 5 | sudo apt-get install -y git gcc make re2c php5-dev libpcre3-dev 6 | 7 | cd ~/build 8 | 9 | git clone https://github.com/phalcon/zephir 10 | cd zephir 11 | ./install-json 12 | ./install -c 13 | --------------------------------------------------------------------------------