├── .gitmodules
├── ssh
└── .gitignore
├── log
└── .gitignore
├── www
└── default
│ ├── public
│ ├── php-info.php
│ └── index.php
│ ├── assets
│ ├── css
│ │ ├── global
│ │ │ └── _variables.scss
│ │ ├── components
│ │ │ ├── _dialog.scss
│ │ │ ├── _toolbar.scss
│ │ │ ├── _content.scss
│ │ │ └── _sidenav.scss
│ │ └── app.scss
│ └── js
│ │ ├── controllers
│ │ ├── home.js
│ │ ├── env.js
│ │ ├── frame.js
│ │ ├── app.js
│ │ └── site.js
│ │ └── application.js
│ ├── bower.json
│ ├── package.json
│ ├── app
│ ├── views
│ │ ├── index.phtml
│ │ ├── index
│ │ │ ├── index.phtml
│ │ │ ├── _list.phtml
│ │ │ ├── _edit-site.phtml
│ │ │ ├── _new-site.phtml
│ │ │ └── _homepage.phtml
│ │ └── layouts
│ │ │ └── index.phtml
│ ├── controllers
│ │ └── IndexController.php
│ └── config
│ │ ├── phalconvm.yml
│ │ ├── services.php
│ │ └── fields.yml
│ ├── Gruntfile.js
│ └── data
│ └── defaults.json
├── provision
├── puppet
│ ├── setup.pp
│ ├── modules
│ │ └── phalconvm
│ │ │ ├── manifests
│ │ │ ├── tools
│ │ │ │ ├── opcache.pp
│ │ │ │ ├── webgrind.pp
│ │ │ │ ├── npm.pp
│ │ │ │ └── composer.pp
│ │ │ ├── utils
│ │ │ │ ├── known_host.pp
│ │ │ │ └── puppet_modules.pp
│ │ │ ├── php
│ │ │ │ ├── phalcon.pp
│ │ │ │ ├── zephir.pp
│ │ │ │ └── pecl.pp
│ │ │ ├── memcached
│ │ │ │ └── phpmemcacheadmin.pp
│ │ │ ├── mongodb.pp
│ │ │ ├── sphinxsearch.pp
│ │ │ ├── gearman.pp
│ │ │ ├── rabbitmq.pp
│ │ │ ├── memcached.pp
│ │ │ ├── redis.pp
│ │ │ ├── postgres
│ │ │ │ └── phppgadmin.pp
│ │ │ ├── postgres.pp
│ │ │ ├── elasticsearch.pp
│ │ │ ├── mysql
│ │ │ │ └── phpmyadmin.pp
│ │ │ ├── website.pp
│ │ │ ├── varnish.pp
│ │ │ ├── mysql.pp
│ │ │ ├── init.pp
│ │ │ ├── nginx.pp
│ │ │ └── php.pp
│ │ │ └── templates
│ │ │ ├── phpmyadmin
│ │ │ └── config.inc.php.erb
│ │ │ ├── varnish
│ │ │ └── default.vcl.erb
│ │ │ └── phppgadmin
│ │ │ └── config.inc.php.erb
│ └── modules.pp
├── startup.sh
└── provision.sh
├── .gitignore
├── LICENSE
├── Vagrantfile
└── README.md
/.gitmodules:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ssh/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/log/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/www/default/public/php-info.php:
--------------------------------------------------------------------------------
1 | deep_merge(
3 | loadjson( '/srv/www/default/data/defaults.json', {} ),
4 | loadjson( '/srv/www/default/data/settings.json', {} )
5 | )
6 | }
7 |
--------------------------------------------------------------------------------
/www/default/assets/js/controllers/home.js:
--------------------------------------------------------------------------------
1 | (function(phalconvm) {
2 | phalconvm.app.controller('HomeCtrl', ['$rootScope', function($rootScope) {
3 | $rootScope.saveButton = false;
4 | $rootScope.title = 'Introduction';
5 | }]);
6 | })(phalconvm);
--------------------------------------------------------------------------------
/www/default/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "phalcon-vm",
3 | "private": true,
4 | "dependencies": {
5 | "angular-material": "^1.1.1",
6 | "angular-route": "^1.5.8",
7 | "angular-sanitize": "^1.5.8",
8 | "angular-messages": "^1.5.8"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/www/default/assets/css/app.scss:
--------------------------------------------------------------------------------
1 | @import 'global/variables';
2 |
3 | @import '../../bower_components/angular-material/modules/scss/angular-material.scss';
4 |
5 | @import 'components/sidenav';
6 | @import 'components/toolbar';
7 | @import 'components/content';
8 | @import 'components/dialog';
9 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/tools/opcache.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::tools::opcache {
2 | vcsrepo { '/srv/www/default/public/opcache-status':
3 | ensure => 'present',
4 | provider => 'git',
5 | source => 'https://github.com/rlerdorf/opcache-status.git',
6 | depth => 1,
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/www/default/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "phalcon-vm",
3 | "devDependencies": {
4 | "grunt": "^1.0.1",
5 | "grunt-contrib-concat": "^1.0.1",
6 | "grunt-contrib-jshint": "^1.0.0",
7 | "grunt-sass": "^1.2.1",
8 | "grunt-contrib-watch": "^1.0.0",
9 | "matchdep": "^1.0.1"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/utils/known_host.pp:
--------------------------------------------------------------------------------
1 | define phalconvm::utils::known_host() {
2 | exec { "${name}-to-known-hosts":
3 | command => "ssh-keyscan -H ${name} >> /etc/ssh/ssh_known_hosts",
4 | onlyif => "test -z `ssh-keygen -F ${name} -f /etc/ssh/ssh_known_hosts`",
5 | path => '/bin:/usr/bin',
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/php/phalcon.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::php::phalcon {
2 | packagecloud::repo { 'phalcon/stable':
3 | type => 'deb',
4 | }
5 |
6 | package { 'php7.0-phalcon':
7 | ensure => 'installed',
8 | notify => Service['php7.0-fpm'],
9 | require => Packagecloud::Repo['phalcon/stable'],
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/www/default/assets/js/controllers/env.js:
--------------------------------------------------------------------------------
1 | (function(phalconvm) {
2 | phalconvm.app.controller('EnvCtrl', ['$scope', '$rootScope', '$routeParams', function($scope, $rootScope, $routeParams) {
3 | $rootScope.title = phalconvm.menu.environment['/env/' + $routeParams.service].label;
4 | $rootScope.saveButton = true;
5 |
6 | $scope.data = phalconvm.data;
7 | }]);
8 | })(phalconvm);
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/tools/webgrind.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::tools::webgrind {
2 | package { 'graphviz':
3 | ensure => 'installed',
4 | }
5 |
6 | vcsrepo { '/srv/www/default/public/webgrind':
7 | ensure => 'present',
8 | provider => 'git',
9 | source => 'https://github.com/michaelschiller/webgrind.git',
10 | depth => 1,
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/provision/startup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | restart() {
4 | if service --status-all | grep -Fq ${1}; then
5 | service ${1} restart
6 | fi
7 | }
8 |
9 | restart nginx
10 | restart varnish
11 | restart php7.0-fpm
12 | restart mysql
13 | restart postgresql
14 | restart mongodb
15 | restart redis-server
16 | restart memcached
17 | restart gearman-job-server
18 | restart rabbitmq-server
19 | restart sphinxsearch
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.vagrant/
2 | /.data/
3 | /nbproject/
4 | /www/*
5 | !/www/default/
6 | /www/default/bower_components/
7 | /www/default/node_modules/
8 | /www/default/public/opcache-status/
9 | /www/default/public/webgrind/
10 | /www/default/public/phpmyadmin/
11 | /www/default/public/phppgadmin/
12 | /www/default/public/phpmemcachedadmin/
13 | /www/default/data/settings.json
14 | /ubuntu-xenial-16.04-cloudimg-console.log
15 | .DS_Store
16 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/utils/puppet_modules.pp:
--------------------------------------------------------------------------------
1 | define phalconvm::utils::puppet_modules( $modules ) {
2 | $modules.each |$module, $version| {
3 | $command = $version ? {
4 | false => "/opt/puppetlabs/bin/puppet module install ${name}-${module}",
5 | default => "/opt/puppetlabs/bin/puppet module install ${name}-${module} --version ${version}",
6 | }
7 |
8 | exec { "${name}-${module}":
9 | command => $command,
10 | creates => "/etc/puppetlabs/code/environments/production/modules/${module}/",
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/memcached/phpmemcacheadmin.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::memcached::phpmemcacheadmin( $enabled = false ) {
2 | if $enabled == true {
3 | vcsrepo { '/srv/www/default/public/phpmemcachedadmin':
4 | ensure => 'present',
5 | provider => 'git',
6 | source => 'https://github.com/wp-cloud/phpmemcacheadmin.git',
7 | revision => '1.2.2.1',
8 | depth => 1,
9 | }
10 | } else {
11 | file { '/srv/www/default/public/phpmemcachedadmin':
12 | ensure => 'absent',
13 | force => true,
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/mongodb.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::mongodb( $enabled = false ) {
2 | if $enabled == true {
3 | class { '::mongodb::server': }
4 | } else {
5 | service { 'mongodb':
6 | ensure => 'stopped',
7 | }
8 |
9 | package { 'mongodb-server':
10 | ensure => 'purged',
11 | require => Service['mongodb'],
12 | }
13 |
14 | exec { 'mongodb-remove':
15 | command => '/usr/bin/apt-get autoremove --purge -y',
16 | refreshonly => true,
17 | subscribe => Package['mongodb-server'],
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/php/zephir.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::php::zephir() {
2 | vcsrepo { '/usr/local/src/zephir':
3 | ensure => 'present',
4 | provider => 'git',
5 | source => 'https://github.com/phalcon/zephir.git',
6 | depth => 1,
7 | revision => '0.9.4',
8 | }
9 |
10 | exec { 'zephir-install':
11 | command => '/usr/local/src/zephir/install -c',
12 | cwd => '/usr/local/src/zephir/',
13 | refreshonly => true,
14 | subscribe => Vcsrepo['/usr/local/src/zephir'],
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/www/default/assets/js/controllers/frame.js:
--------------------------------------------------------------------------------
1 | (function(phalconvm) {
2 | phalconvm.app.controller('FrameCtrl', ['$rootScope', '$routeParams', function($rootScope, $routeParams) {
3 | var key = '/iframe' + encodeURIComponent($routeParams.href).split('%2F').join('/');
4 |
5 | $rootScope.saveButton = false;
6 | $rootScope.title = false;
7 |
8 | if (phalconvm.menu.miscellaneous[key]) {
9 | $rootScope.title = phalconvm.menu.miscellaneous[key].label;
10 | } else if (phalconvm.menu.tools[key]) {
11 | $rootScope.title = phalconvm.menu.tools[key].label;
12 | }
13 | }]);
14 | })(phalconvm);
--------------------------------------------------------------------------------
/www/default/assets/css/components/_toolbar.scss:
--------------------------------------------------------------------------------
1 | #toolbar {
2 | box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.14), 0px 0px 2px 2px rgba(0, 0, 0, 0.098), 0px 0px 5px 1px rgba(0, 0, 0, 0.084);
3 | background-color: #f6f6f6;
4 |
5 | .md-toolbar-tools {
6 | width: auto;
7 | max-width: $content-width;
8 | margin: 0 ;
9 | }
10 |
11 | .md-breadcrumb {
12 | margin: 0;
13 | padding: 0;
14 | color: black;
15 | font-size: 24px !important;
16 | font-weight: 400 !important;
17 |
18 | .md-breadcrumb-page {
19 | display: inline-block;
20 | word-wrap: break-word;
21 | }
22 | }
23 |
24 | .md-icon-button {
25 | color: black;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/www/default/app/views/index.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | tag->getTitle(); ?>
8 |
9 | assets->outputCss(); ?>
10 | assets->outputInlineCss(); ?>
11 |
12 | getContent();
14 | $this->assets->outputInlineJs();
15 | $this->assets->outputJs();
16 | ?>
17 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/tools/npm.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::tools::npm {
2 | package { ['nodejs', 'npm']:
3 | ensure => 'installed',
4 | }
5 |
6 | ->
7 |
8 | file { '/usr/bin/node':
9 | ensure => 'link',
10 | target => '/usr/bin/nodejs',
11 | }
12 |
13 | ->
14 |
15 | exec { 'bower':
16 | command => '/usr/bin/npm install -g bower',
17 | creates => '/usr/local/bin/bower',
18 | }
19 |
20 | ->
21 |
22 | exec { 'grunt':
23 | command => '/usr/bin/npm install -g grunt-cli',
24 | creates => '/usr/local/bin/grunt',
25 | }
26 |
27 | ->
28 |
29 | exec { 'gulp':
30 | command => '/usr/bin/npm install -g gulp-cli',
31 | creates => '/usr/local/bin/gulp',
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/sphinxsearch.pp:
--------------------------------------------------------------------------------
1 | # https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-sphinx-on-ubuntu-14-04
2 |
3 | class phalconvm::sphinxsearch( $enabled = false ) {
4 | if $enabled == true {
5 | package { 'sphinxsearch':
6 | ensure => 'installed',
7 | }
8 | } else {
9 | service { 'sphinxsearch':
10 | ensure => 'stopped',
11 | }
12 |
13 | package { 'sphinxsearch':
14 | ensure => 'purged',
15 | require => Service['sphinxsearch'],
16 | }
17 |
18 | exec { 'sphinxsearch-remove':
19 | command => '/usr/bin/apt-get autoremove --purge -y',
20 | refreshonly => true,
21 | subscribe => Package['sphinxsearch'],
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/www/default/public/index.php:
--------------------------------------------------------------------------------
1 | getConfig();
15 |
16 | $loader = new \Phalcon\Loader();
17 | $loader->registerDirs( array( $config->application->controllersDir ) );
18 | $loader->register();
19 |
20 | $application = new \Phalcon\Mvc\Application( $di );
21 |
22 | $response = $application->handle();
23 | $response->send();
24 | } catch ( \Exception $e ) {
25 | echo $e->getMessage() . '
';
26 | echo '' . $e->getTraceAsString() . '
';
27 | }
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/gearman.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::gearman( $enabled = false ) {
2 | if $enabled == true {
3 | package { 'gearman-job-server':
4 | ensure => 'installed',
5 | }
6 |
7 | service { 'gearman-job-server':
8 | ensure => 'running',
9 | require => Package['gearman-job-server'],
10 | }
11 | } else {
12 | service { 'gearman-job-server':
13 | ensure => 'stopped',
14 | }
15 |
16 | package { 'gearman-job-server':
17 | ensure => 'purged',
18 | require => Service['gearman-job-server'],
19 | }
20 |
21 | exec { 'gearman-remove':
22 | command => '/usr/bin/apt-get autoremove --purge -y',
23 | refreshonly => true,
24 | subscribe => Package['gearman-job-server'],
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/php/pecl.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::php::pecl {
2 | package { 'php-pear':
3 | ensure => 'installed',
4 | }
5 |
6 | exec { 'pecl-install-yaml':
7 | command => '/usr/bin/pecl install yaml-2.0.0',
8 | creates => '/usr/lib/php/20151012/yaml.so',
9 | require => Package['php-pear'],
10 | }
11 |
12 | file { '/etc/php/7.0/mods-available/yaml.ini':
13 | ensure => 'present',
14 | owner => 'root',
15 | group => 'root',
16 | content => 'extension=yaml.so',
17 | require => Exec['pecl-install-yaml'],
18 | }
19 |
20 | file { '/etc/php/7.0/fpm/conf.d/20-yaml.ini':
21 | ensure => 'link',
22 | target => '/etc/php/7.0/mods-available/yaml.ini',
23 | owner => 'root',
24 | group => 'root',
25 | require => File['/etc/php/7.0/mods-available/yaml.ini'],
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/provision/provision.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # installs puppet and its modules if it is not installed yet
4 | if [ ! -f /opt/puppetlabs/bin/puppet ]; then
5 | # install latest version of puppet
6 | pushd /tmp/
7 | wget http://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
8 | dpkg -i puppetlabs-release-pc1-xenial.deb
9 | apt-get update --quiet --yes
10 | apt-get install --quiet --yes puppetserver
11 | popd
12 |
13 | # make a symlink to puppet executable
14 | ln -s /opt/puppetlabs/bin/puppet /usr/local/bin/puppet
15 |
16 | # set basemodulepath
17 | puppet config set basemodulepath "/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules:/srv/provision/puppet/modules" --section main
18 | fi
19 |
20 | # install puppet modules and apply server configurations
21 | puppet apply /srv/provision/puppet/modules.pp
22 | puppet apply /srv/provision/puppet/setup.pp
23 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/rabbitmq.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::rabbitmq( $enabled = false ) {
2 | if $enabled == true {
3 | packagecloud::repo { 'rabbitmq/rabbitmq-server': type => 'deb' }
4 |
5 | package { 'rabbitmq-server':
6 | ensure => 'installed',
7 | require => Packagecloud::Repo['rabbitmq/rabbitmq-server'],
8 | }
9 |
10 | service { 'rabbitmq-server':
11 | ensure => 'running',
12 | require => Package['rabbitmq-server'],
13 | }
14 | } else {
15 | service { 'rabbitmq-server':
16 | ensure => 'stopped',
17 | }
18 |
19 | package { 'rabbitmq-server':
20 | ensure => 'purged',
21 | require => Service['rabbitmq-server'],
22 | }
23 |
24 | exec { 'rabbitmq-remove':
25 | command => '/usr/bin/apt-get autoremove --purge -y',
26 | refreshonly => true,
27 | subscribe => Package['rabbitmq-server'],
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/memcached.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::memcached(
2 | $enabled = false,
3 | $max_memory = 64,
4 | $port = 11211,
5 | $forward_port = false,
6 | ) {
7 | if $enabled == true {
8 | class { 'memcached':
9 | package_ensure => 'present',
10 | listen_ip => '127.0.0.1',
11 | tcp_port => $port,
12 | max_memory => $max_memory,
13 | user => 'memcache',
14 | }
15 | } else {
16 | # file { '/srv/log/memcached.log':
17 | # ensure => 'absent',
18 | # }
19 |
20 | service { 'memcached':
21 | ensure => 'stopped',
22 | }
23 |
24 | package { 'memcached':
25 | ensure => 'purged',
26 | require => Service['memcached'],
27 | }
28 |
29 | exec { 'memcached-removed':
30 | command => '/usr/bin/apt-get autoremove --purge -y',
31 | refreshonly => true,
32 | subscribe => Package['memcached'],
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/provision/puppet/modules.pp:
--------------------------------------------------------------------------------
1 | phalconvm::utils::puppet_modules { 'puppetlabs':
2 | modules => {
3 | 'stdlib' => '4.13.1',
4 | 'apt' => '2.3.0',
5 | 'vcsrepo' => '1.4.0',
6 | 'inifile' => '1.6.0',
7 | 'mysql' => '3.9.0',
8 | 'postgresql' => '4.8.0',
9 | 'mongodb' => '0.14.0',
10 | }
11 | }
12 |
13 | phalconvm::utils::puppet_modules { 'computology':
14 | modules => {
15 | 'packagecloud' => '0.3.1',
16 | }
17 | }
18 |
19 | phalconvm::utils::puppet_modules { 'saz':
20 | modules => {
21 | 'memcached' => '2.8.1',
22 | }
23 | }
24 |
25 | phalconvm::utils::puppet_modules { 'puppet':
26 | modules => {
27 | 'nginx' => '0.4.0',
28 | 'archive' => '1.1.2',
29 | }
30 | }
31 |
32 | phalconvm::utils::puppet_modules { 'elasticsearch':
33 | modules => {
34 | 'elasticsearch' => '0.14.0',
35 | }
36 | }
37 |
38 | phalconvm::utils::puppet_modules { 'arioch':
39 | modules => {
40 | 'redis' => '1.2.3',
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/redis.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::redis(
2 | $enabled = false,
3 | $port = 6379,
4 | $forward_port = false,
5 | $maxmemory = 64,
6 | $save_db_to_disk = true,
7 | $slowlog_log_slower_than = 100,
8 | ) {
9 | if $enabled == true {
10 | class { 'redis':
11 | port => $port,
12 | maxmemory => $maxmemory << 20,
13 | maxmemory_policy => 'volatile-lru',
14 | save_db_to_disk => $save_db_to_disk,
15 | daemonize => true,
16 | slowlog_log_slower_than => $slowlog_log_slower_than * 1000,
17 | }
18 | } else {
19 | service { 'redis-server':
20 | ensure => 'stopped',
21 | }
22 |
23 | package { 'redis-server':
24 | ensure => 'purged',
25 | require => Service['redis-server'],
26 | }
27 |
28 | exec { 'redis-remove':
29 | command => '/usr/bin/apt-get autoremove --purge -y',
30 | refreshonly => true,
31 | subscribe => Package['redis-server'],
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/postgres/phppgadmin.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::postgres::phppgadmin( $enabled = true ) {
2 | if $enabled == true {
3 | archive { '/tmp/phppgadmin.tar.gz':
4 | ensure => 'present',
5 | source => 'https://github.com/phppgadmin/phppgadmin/archive/REL_5-1-0.tar.gz',
6 | extract => true,
7 | extract_path => '/tmp/',
8 | creates => '/srv/www/default/public/phppgadmin/index.php',
9 | cleanup => true,
10 | }
11 |
12 | exec { 'move-phppgadmin':
13 | command => '/bin/mv /tmp/phppgadmin-REL_5-1-0 /srv/www/default/public/phppgadmin',
14 | creates => '/srv/www/default/public/phppgadmin/index.php',
15 | require => Archive['/tmp/phppgadmin.tar.gz']
16 | }
17 |
18 | file { '/srv/www/default/public/phppgadmin/conf/config.inc.php':
19 | ensure => 'present',
20 | content => template( 'phalconvm/phppgadmin/config.inc.php.erb' ),
21 | require => Exec['move-phppgadmin'],
22 | }
23 | } else {
24 | file { '/srv/www/default/public/phppgadmin/':
25 | ensure => 'absent',
26 | force => true,
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/postgres.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::postgres(
2 | $enabled = true,
3 | $password = 'postgres',
4 | $log_min_duration_statement = 250,
5 | ) {
6 | if $enabled == true {
7 | class { 'postgresql::server':
8 | postgres_password => $password,
9 | }
10 |
11 | postgresql::server::config_entry { 'logging_collector':
12 | ensure => 'present',
13 | value => 'on',
14 | }
15 |
16 | postgresql::server::config_entry { 'log_min_duration_statement':
17 | ensure => 'present',
18 | value => $log_min_duration_statement,
19 | }
20 |
21 | postgresql::server::config_entry { 'log_statement':
22 | ensure => 'present',
23 | value => 'none',
24 | }
25 | } else {
26 | service { 'postgresql':
27 | ensure => 'stopped',
28 | }
29 |
30 | package { ['postgresql-9.5', 'postgresql-client-9.5']:
31 | ensure => 'purged',
32 | require => Service['postgresql'],
33 | }
34 |
35 | exec { 'postgresql-remove':
36 | command => '/usr/bin/apt-get autoremove --purge -y',
37 | refreshonly => true,
38 | subscribe => Package['postgresql-9.5'],
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2015 the contributors of the Phalcon VM project
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/www/default/app/controllers/IndexController.php:
--------------------------------------------------------------------------------
1 | getDI();
7 |
8 | $phalconvm = $di->getShared( 'phalconvmConfig' );
9 | $fields = $di->getShared( 'fieldsConfig' );
10 |
11 | $this->tag->setTitle( 'Phalcon VM' );
12 |
13 | $this->assets->addCss( '//fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic', false );
14 | $this->assets->addCss( '//fonts.googleapis.com/icon?family=Material+Icons', false );
15 | $this->assets->addCss( 'css/app.css' );
16 |
17 | $this->assets->addInlineJs( sprintf( 'var phalconvm = %s;', json_encode( $phalconvm ) ) );
18 | $this->assets->addJs( 'js/app.js' );
19 |
20 | $phalconvm['fields'] = $fields;
21 | $this->view->phalconvm = $phalconvm;
22 | }
23 |
24 | public function saveEnvAction() {
25 | if ( ! $this->request->isPost() ) {
26 | $this->response->redirect( '/', false );
27 | } else {
28 | $postdata = trim( file_get_contents( "php://input" ) );
29 | $json = json_decode( $postdata, true );
30 | if ( ! empty( $json ) ) {
31 | file_put_contents( BASE_PATH . '/data/settings.json', json_encode( $json, JSON_PRETTY_PRINT ) );
32 | }
33 | }
34 |
35 | return false;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/elasticsearch.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::elasticsearch(
2 | $enabled = false,
3 | $port = '9200',
4 | $forward_port = false,
5 | # $xpack = false,
6 | ) {
7 | if $enabled == true {
8 | class { 'elasticsearch':
9 | manage_repo => true,
10 | repo_version => '2.x',
11 | restart_on_change => true,
12 | config => {
13 | 'http.port' => $port,
14 | },
15 | }
16 |
17 | elasticsearch::instance { 'es-01':
18 | config => {
19 | 'network.bind_host' => '0.0.0.0',
20 | }
21 | }
22 |
23 | # if $xpack == true {
24 | # elasticsearch::plugin { 'elasticsearch/marvel':
25 | # url => 'https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/marvel-agent/2.4.1/marvel-agent-2.4.1.zip',
26 | # module_dir => 'marvel',
27 | # instances => 'es-01',
28 | # }
29 | # }
30 | } else {
31 | service { 'elasticsearch-es-01':
32 | ensure => 'stopped',
33 | }
34 |
35 | package { 'elasticsearch':
36 | ensure => 'purged',
37 | require => Service['elasticsearch-es-01'],
38 | }
39 |
40 | exec { 'elasticsearch-remove':
41 | command => '/usr/bin/apt-get autoremove --purge -y',
42 | refreshonly => true,
43 | subscribe => Package['elasticsearch'],
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/www/default/app/views/index/index.phtml:
--------------------------------------------------------------------------------
1 | partial( 'index/_homepage' );
4 | $this->partial( 'index/_new-site' );
5 | $this->partial( 'index/_edit-site' );
6 |
7 | foreach ( $phalconvm['menu']['environment'] as $env ) :
8 | ?>and up it again with --provision mode.')
20 | .ok('Got it!');
21 |
22 | self.nasty = false;
23 |
24 | $http.post('/save/env', phalconvm.data);
25 | $mdDialog.show(alert);
26 | };
27 |
28 | self.toggleSidenav = function() {
29 | $mdSidenav('left').toggle();
30 | };
31 |
32 | self.newSiteDialog = function() {
33 | $rootScope.newSite = true;
34 |
35 | $mdDialog.show({
36 | controller: 'SiteCtrl',
37 | controllerAs: 'site',
38 | template: document.getElementById('tmpl-new-site').innerHTML
39 | }).then(function() {
40 | self.setNasty();
41 | });
42 | };
43 | };
44 |
45 | phalconvm.app.controller('AppCtrl', ['$rootScope', '$mdSidenav', '$mdDialog', '$http', controller]);
46 | })(phalconvm);
47 |
--------------------------------------------------------------------------------
/www/default/assets/css/components/_content.scss:
--------------------------------------------------------------------------------
1 | #wrapper {
2 | position: relative;
3 | overflow-x: hidden
4 | }
5 |
6 | #content {
7 | position: absolute;
8 | top: 64px;
9 | left: 0;
10 | right: 0;
11 | bottom: 4px;
12 |
13 | .content-container {
14 | max-width: $content-width;
15 | margin: 16px;
16 | }
17 |
18 | .header > h2 {
19 | margin: 0;
20 | color: #164371;
21 | }
22 |
23 | p {
24 | font-size: 16px;
25 | font-weight: 400;
26 | letter-spacing: 0.010em;
27 | line-height: 1.6em;
28 | margin: 0.8em 0 1.6em;
29 |
30 | &:last-of-type {
31 | margin-bottom: 0;
32 | }
33 | }
34 |
35 | .md-title {
36 | margin-top: 1.5em;
37 | }
38 |
39 | .md-2-line {
40 | p {
41 | font-size: 11px;
42 | }
43 | }
44 |
45 | .md-secondary-container {
46 | min-width: 75px;
47 |
48 | > * {
49 | margin-left: auto;
50 | margin-right: auto;
51 | }
52 |
53 | input[type="text"] {
54 | text-align: center;
55 | width: 75px;
56 | border-width: 1px;
57 | border-color: rgba(0, 0, 0, 0.1);
58 | border-bottom-width: 2px;
59 | border-bottom-color: rgba(0, 0, 0, 0.2);
60 | padding: 5px 0;
61 |
62 | &:focus {
63 | outline-color: #106CC8;
64 | outline-width: 1px;
65 | }
66 | }
67 | }
68 |
69 | md-tabs {
70 | .md-subhead {
71 | margin: 2em 0 .5em 14px;
72 | font-weight: bold;
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/www/default/assets/css/components/_sidenav.scss:
--------------------------------------------------------------------------------
1 | #sidebar,
2 | #sidebar-menu {
3 | color: white;
4 | background-color: #106CC8;
5 | }
6 |
7 | #sidebar {
8 | #logo {
9 | text-transform: uppercase;
10 | text-align: center;
11 | display: block;
12 | padding: 0;
13 | margin: .5em 0;
14 |
15 | a {
16 | color: #fff;
17 | text-decoration: none;
18 | }
19 |
20 | small {
21 | display: block;
22 | font-size: 14px;
23 | font-weight: 400;
24 | line-height: 1em;
25 | color: #bbb;
26 | }
27 | }
28 |
29 | md-divider {
30 | border-color: #267ED5;
31 | }
32 |
33 | ul {
34 | padding: 0;
35 | margin: 0 0 1.5em;
36 | }
37 |
38 | .section-title {
39 | text-transform: uppercase;
40 | color: rgba(255, 255, 255, 0.54);
41 | display: block;
42 | margin: 1em 0 0;
43 | padding: .5em 1.5em 0;
44 | line-height: 32px;
45 | }
46 |
47 | .group-title {
48 | text-transform: uppercase;
49 | display: block;
50 | line-height: 32px;
51 | font-weight: bold;
52 | }
53 |
54 | .menu-item {
55 | margin: 0;
56 | list-style: none;
57 |
58 | a {
59 | color: #fff;
60 | text-decoration: none;
61 | font-weight: 500;
62 | display: block;
63 | padding: .5em 1.5em;
64 |
65 | &:hover {
66 | background-color: rgba(255, 255, 255, 0.25);
67 | }
68 | }
69 | }
70 |
71 | .material-icons {
72 | font-size: 14px;
73 | font-weight: bold;
74 | }
75 | }
--------------------------------------------------------------------------------
/www/default/assets/js/application.js:
--------------------------------------------------------------------------------
1 | (function(angular, phalconvm, document) {
2 | phalconvm.app = angular.module('PhalconVM', ['ngMaterial', 'ngRoute', 'ngSanitize', 'ngMessages']);
3 | phalconvm.app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
4 | $routeProvider.when('/', {
5 | controller: 'HomeCtrl',
6 | controllerAs: 'home',
7 | template: function() {
8 | return document.getElementById('tmpl-homepage').innerHTML;
9 | }
10 | });
11 |
12 | $routeProvider.when('/site/:site', {
13 | controller: 'SiteCtrl',
14 | controllerAs: 'site',
15 | template: function() {
16 | return document.getElementById('tmpl-edit-site').innerHTML;
17 | }
18 | });
19 |
20 | $routeProvider.when('/env/:service', {
21 | controller: 'EnvCtrl',
22 | controllerAs: 'env',
23 | template: function(params) {
24 | var template = document.getElementById('tmpl-' + params.service);
25 |
26 | if (template) {
27 | return template.innerHTML;
28 | }
29 |
30 | return ' ';
31 | }
32 | });
33 |
34 | $routeProvider.when('/iframe:href*', {
35 | controller: 'FrameCtrl',
36 | controllerAs: 'frm',
37 | template: function(params) {
38 | return '';
39 | }
40 | });
41 |
42 | $locationProvider.html5Mode(true);
43 | }]);
44 | })(angular, phalconvm, document);
45 |
--------------------------------------------------------------------------------
/www/default/app/config/phalconvm.yml:
--------------------------------------------------------------------------------
1 | app: null
2 | menu:
3 | environment:
4 | "/env/web":
5 | key: web
6 | label: Web Sevices
7 | items:
8 | nginx: Nginx
9 | php: PHP
10 | varnish: Varnish
11 |
12 | "/env/db":
13 | key: db
14 | label: Databases
15 | items:
16 | mysql: MySQL
17 | postgres: PostgreSQL
18 | mongodb: MongoDB
19 |
20 | "/env/cache":
21 | key: cache
22 | label: Caching Systems
23 | items:
24 | redis: Redis
25 | memcached: Memcached
26 |
27 | "/env/queue":
28 | key: queue
29 | label: Queue Systems
30 | items:
31 | gearman: Gearman
32 | rabbitmq: RabbitMQ
33 |
34 | "/env/search":
35 | key: search
36 | label: Search Engines
37 | items:
38 | elasticsearch: Elasticsearch
39 | sphinx: Sphinxsearch
40 | tools: []
41 | miscellaneous:
42 | "/iframe/opcache-status/opcache.php":
43 | label: Opcache Status
44 | "/iframe/webgrind":
45 | label: Webgrind
46 | "/iframe/php-info.php":
47 | label: PHP Info
48 | "/iframe/php-status%3Fhtml%26full":
49 | label: PHP Status
50 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/templates/phpmyadmin/config.inc.php.erb:
--------------------------------------------------------------------------------
1 | ';
12 |
13 | $i = 1;
14 |
15 | // server settings
16 | $cfg['Servers'][$i]['auth_type'] = 'cookie';
17 | $cfg['Servers'][$i]['host'] = 'localhost';
18 | $cfg['Servers'][$i]['port'] = <%= @port %>;
19 | $cfg['Servers'][$i]['connect_type'] = 'tcp';
20 | $cfg['Servers'][$i]['compress'] = false;
21 | $cfg['Servers'][$i]['extension'] = 'mysqli';
22 | $cfg['Servers'][$i]['AllowNoPassword'] = false;
23 |
24 | // general settings
25 | $cfg['AllowThirdPartyFraming'] = true;
26 | $cfg['MaxDbList'] = <%= @maxDbList %>;
27 | $cfg['MaxTableList'] = <%= @maxTableList %>;
28 | $cfg['ShowSQL'] = <%= @showSQL %>;
29 | $cfg['AllowUserDropDatabase'] = <%= @allowUserDropDatabase %>;
30 | $cfg['Confirm'] = <%= @confirm %>;
31 | $cfg['UseDbSearch'] = <%= @useDbSearch %>;
32 | $cfg['RetainQueryBox'] = <%= @retainQueryBox %>;
33 | $cfg['IgnoreMultiSubmitErrors'] = <%= @ignoreMultiSubmitErrors %>;
34 |
35 | // load custom config
36 | if ( file_exists( 'config.inc.custom.php' ) ) {
37 | include( 'config.inc.custom.php' );
38 | }
39 |
--------------------------------------------------------------------------------
/www/default/app/views/index/_list.phtml:
--------------------------------------------------------------------------------
1 | $field ) :
4 | $defaultDisabled = ! in_array( $key, array( 'nginx', 'php' ) )
5 | ? "!data.{$key}.enabled"
6 | : 0;
7 |
8 | ?>
9 |
10 |
15 |
16 |
17 |
22 |
23 |
24 |
30 |
31 |
32 |
36 |
37 |
38 | 'present',
16 | source => 'https://github.com/phpmyadmin/phpmyadmin/archive/RELEASE_4_6_4.tar.gz',
17 | extract => true,
18 | extract_path => '/tmp/',
19 | creates => '/srv/www/default/public/phpmyadmin/index.php',
20 | cleanup => true,
21 | }
22 |
23 | exec { 'move-phpmyadmin':
24 | command => '/bin/mv /tmp/phpmyadmin-RELEASE_4_6_4 /srv/www/default/public/phpmyadmin',
25 | creates => '/srv/www/default/public/phpmyadmin/index.php',
26 | require => Archive['/tmp/phpmyadmin.tar.gz']
27 | }
28 |
29 | $fqdn_rand = fqdn_rand( 9999 )
30 | $blowfish_secret = pw_hash( "${fqdn_rand}", 'SHA-512', 'JXXdi4G0Nl9xlh0emuoHZNSuPvZ0qcfGx1hF4cUfOkf3jS' )
31 |
32 | file { '/srv/www/default/public/phpmyadmin/config.inc.php':
33 | ensure => 'present',
34 | content => template( 'phalconvm/phpmyadmin/config.inc.php.erb' ),
35 | require => Exec['move-phpmyadmin'],
36 | }
37 | } else {
38 | file { '/srv/www/default/public/phpmyadmin/':
39 | ensure => 'absent',
40 | force => true,
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/www/default/assets/js/controllers/site.js:
--------------------------------------------------------------------------------
1 | (function(phalconvm) {
2 | var controller = function($rootScope, $routeParams, $mdDialog) {
3 | var self = this,
4 | data = {};
5 |
6 | $rootScope.saveButton = true;
7 |
8 | if ($rootScope.newSite) {
9 | data = {
10 | label: '',
11 | directory: '',
12 | domains: '',
13 | repository: '',
14 | provider: ''
15 | };
16 | } else {
17 | angular.forEach(phalconvm.data.sites, function(site) {
18 | if (site.directory == $routeParams.site) {
19 | data = site;
20 | }
21 | });
22 |
23 | $rootScope.title = data.label;
24 | }
25 |
26 | self.data = data;
27 | self.providers = [
28 | {key: 'git', label: 'Git'},
29 | {key: 'bzr', label: 'Bazaar'},
30 | {key: 'cvs', label: 'CVS'},
31 | {key: 'hg', label: 'Mercurial'},
32 | {key: 'p4', label: 'Perforce'},
33 | {key: 'svn', label: 'Subversion'}
34 | ];
35 |
36 | self.add = function() {
37 | if (!angular.isArray(phalconvm.data.sites)) {
38 | phalconvm.data.sites = [];
39 | }
40 |
41 | phalconvm.data.sites.push({
42 | label: self.data.label,
43 | directory: self.data.directory,
44 | domains: self.data.domains,
45 | repository: self.data.repository,
46 | provider: self.data.provider
47 | });
48 |
49 | $rootScope.newSite = false;
50 | $mdDialog.hide();
51 | };
52 |
53 | self.cancel = function() {
54 | $rootScope.newSite = false;
55 | $mdDialog.cancel();
56 | };
57 | };
58 |
59 | phalconvm.app.controller('SiteCtrl', ['$rootScope', '$routeParams', '$mdDialog', controller]);
60 | })(phalconvm);
61 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/tools/composer.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::tools::composer {
2 | package { 'composer':
3 | ensure => 'installed',
4 | require => Package['php7.0-phalcon'],
5 | }
6 |
7 | exec { 'composer-config':
8 | command => '/usr/bin/composer -q global config bin-dir /usr/local/bin',
9 | environment => 'COMPOSER_HOME=/usr/local/src/composer',
10 | unless => '/bin/grep -Fq "bin-dir" /usr/local/src/composer/composer.json',
11 | require => Package['composer'],
12 | }
13 |
14 | exec { 'codeception':
15 | command => '/usr/bin/composer -q global require codeception/codeception',
16 | creates => '/usr/local/src/composer/vendor/codeception/codeception',
17 | environment => 'COMPOSER_HOME=/usr/local/src/composer',
18 | require => [Package['composer'], Exec['composer-config']],
19 | }
20 |
21 | exec { 'phpunit':
22 | command => '/usr/bin/composer -q global require phpunit/phpunit',
23 | creates => '/usr/local/src/composer/vendor/phpunit/phpunit',
24 | environment => 'COMPOSER_HOME=/usr/local/src/composer',
25 | require => [Package['composer'], Exec['composer-config']],
26 | }
27 |
28 | exec { 'phalcon-dev-tools':
29 | command => '/usr/bin/composer -q global require phalcon/devtools',
30 | creates => '/usr/local/src/composer/vendor/phalcon/devtools',
31 | environment => 'COMPOSER_HOME=/usr/local/src/composer',
32 | require => [Package['composer'], Exec['composer-config']],
33 | }
34 |
35 | file { '/usr/bin/phalcon':
36 | ensure => 'link',
37 | target => '/usr/local/bin/phalcon.php',
38 | require => Exec['phalcon-dev-tools'],
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/templates/varnish/default.vcl.erb:
--------------------------------------------------------------------------------
1 | #
2 | # This is an example VCL file for Varnish.
3 | #
4 | # It does not do anything by default, delegating control to the
5 | # builtin VCL. The builtin VCL is called when there is no explicit
6 | # return statement.
7 | #
8 | # See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
9 | # and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples.
10 |
11 | # Marker to tell the VCL compiler that this VCL has been adapted to the
12 | # new 4.0 format.
13 | vcl 4.0;
14 |
15 | # Default backend definition. Set this to point to your content server.
16 | backend default {
17 | .host = "127.0.0.1";
18 | .port = "80";
19 | }
20 |
21 | sub vcl_recv {
22 | # Happens before we check if we have this in cache already.
23 | #
24 | # Typically you clean up the request here, removing cookies you don't need,
25 | # rewriting the request, etc.
26 |
27 | # unset cookies for images, stylesheets and javascript files to be able to cache it
28 | if (req.url ~ "\.(css|js|png|gif|jp(e)?g)") {
29 | unset req.http.cookie;
30 | }
31 |
32 | # bypass audio and video files and not cache it
33 | if (req.url ~ "\.(mp4|mp3|avi)") {
34 | return (pass);
35 | }
36 |
37 | return (hash);
38 | }
39 |
40 | sub vcl_backend_response {
41 | # Happens after we have read the response headers from the backend.
42 | #
43 | # Here you clean the response headers, removing silly Set-Cookie headers
44 | # and other mistakes your backend does.
45 | }
46 |
47 | sub vcl_deliver {
48 | # Happens when we have all the pieces we need, and are about to send the
49 | # response to the client.
50 | #
51 | # You can do accounting or modifying the final object here.
52 | }
53 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/website.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::website( $sites = [] ) {
2 | $sites.each |$site| {
3 | file { "/srv/www/${site[directory]}":
4 | ensure => 'directory',
5 | }
6 |
7 | file { "/srv/www/${site[directory]}/htdocs":
8 | ensure => 'directory',
9 | require => File["/srv/www/${site[directory]}"],
10 | }
11 |
12 | nginx::resource::vhost { $site[label]:
13 | ensure => present,
14 | server_name => split($site[domains], ' '),
15 | www_root => "/srv/www/${site[directory]}/htdocs/public",
16 | index_files => ['index.php'],
17 | try_files => ['$uri', '$uri/', '/index.php?_url=$uri&$args'],
18 | # access_log => "/srv/log/nginx/${site[directory]}.access.log",
19 | # error_log => "/srv/log/nginx/${site[directory]}.error.log",
20 | locations => {
21 | "${site[label]}-php-loc" => {
22 | ensure => present,
23 | location => '~ \.php$',
24 | try_files => ['$uri', '=404'],
25 | fastcgi => 'phpupstream',
26 | fastcgi_param => {
27 | 'SCRIPT_FILENAME' => '$document_root$fastcgi_script_name'
28 | },
29 | },
30 | },
31 | }
32 |
33 | if empty($site[repository]) {
34 | exec { "${site[label]} Installation":
35 | command => "phalcon project ${site[directory]} --directory=/tmp && mv /tmp/${site[directory]}/* /srv/www/${site[directory]}/htdocs",
36 | creates => "/srv/www/${site[directory]}/htdocs/public/index.php",
37 | path => '/bin:/usr/bin',
38 | }
39 | } else {
40 | vcsrepo { "/srv/www/${site[directory]}/htdocs":
41 | ensure => 'present',
42 | provider => $site[provider],
43 | source => $site[repository],
44 | require => [Phalconvm::Utils::Known_host['github.com'], Phalconvm::Utils::Known_host['bitbucket.org']],
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/varnish.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::varnish (
2 | $enabled = false,
3 | $port = '6081',
4 | $storage_size = '64m',
5 | $ttl = '120',
6 | ) {
7 | if $enabled == true {
8 | package { 'varnish':
9 | ensure => 'installed',
10 | }
11 |
12 | service { 'varnish':
13 | ensure => 'running',
14 | require => Package['varnish'],
15 | }
16 |
17 | $varnish_service = {
18 | 'Service' => {
19 | 'ExecStart' => "/usr/sbin/varnishd -j unix,user=vcache -F -a :${port} -T localhost:6082 -f /etc/varnish/default.vcl -t ${ttl} -S /etc/varnish/secret -s malloc,${storage_size}",
20 | },
21 | }
22 |
23 | create_ini_settings( $varnish_service, {
24 | path => '/lib/systemd/system/varnish.service',
25 | require => Package['varnish'],
26 | notify => Exec['varnish-daemon-reload'],
27 | } )
28 |
29 | file { '/etc/varnish/default.vcl':
30 | ensure => 'present',
31 | content => template( 'phalconvm/varnish/default.vcl.erb' ),
32 | require => Package['varnish'],
33 | notify => Service['varnish'],
34 | }
35 |
36 | exec { 'varnish-daemon-reload':
37 | command => '/bin/systemctl daemon-reload',
38 | refreshonly => true,
39 | notify => Service['varnish'],
40 | }
41 | } else {
42 | service { 'varnish':
43 | ensure => 'stopped',
44 | }
45 |
46 | exec { 'varnish-unmount':
47 | command => 'umount /var/lib/varnish',
48 | path => '/bin:/usr/bin',
49 | unless => "test -n `mount | grep varnish`",
50 | }
51 |
52 | package { 'varnish':
53 | ensure => 'purged',
54 | require => [ Service['varnish'], Exec['varnish-unmount'] ],
55 | }
56 |
57 | exec { 'varnish-remove':
58 | command => 'apt-get autoremove --purge -y',
59 | refreshonly => true,
60 | path => '/bin:/usr/bin',
61 | subscribe => Package['varnish'],
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/www/default/app/views/index/_edit-site.phtml:
--------------------------------------------------------------------------------
1 |
46 |
--------------------------------------------------------------------------------
/www/default/app/views/index/_new-site.phtml:
--------------------------------------------------------------------------------
1 |
50 |
--------------------------------------------------------------------------------
/www/default/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function(grunt) {
2 | require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
3 |
4 | grunt.initConfig({
5 | pkg: grunt.file.readJSON('package.json'),
6 | concat: {
7 | scripts: {
8 | files: {
9 | 'public/js/app.js': [
10 | 'bower_components/angular/angular.js',
11 | 'bower_components/angular-animate/angular-animate.js',
12 | 'bower_components/angular-aria/angular-aria.js',
13 | 'bower_components/angular-messages/angular-messages.js',
14 | 'bower_components/angular-sanitize/angular-sanitize.js',
15 | 'bower_components/angular-material/angular-material.js',
16 | 'bower_components/angular-route/angular-route.js',
17 | 'assets/js/application.js',
18 | 'assets/js/controllers/*.js'
19 | ]
20 | }
21 | }
22 | },
23 | jshint: {
24 | all: ['assets/js/**/*.js'],
25 | options: {
26 | curly: true,
27 | eqeqeq: false,
28 | immed: true,
29 | latedef: true,
30 | newcap: true,
31 | noarg: true,
32 | sub: true,
33 | undef: true,
34 | boss: true,
35 | eqnull: true,
36 | globals: {
37 | window: false,
38 | document: false,
39 | console: false,
40 | angular: false,
41 | phalconvm: false
42 | }
43 | }
44 | },
45 | sass: {
46 | options: {
47 | sourceMap: true,
48 | precision: 5,
49 | outputStyle: 'compressed'
50 | },
51 | all: {
52 | files: {
53 | 'public/css/app.css': 'assets/css/app.scss'
54 | }
55 | }
56 | },
57 | watch: {
58 | styles: {
59 | files: ['assets/css/**/*.scss'],
60 | tasks: ['css'],
61 | options: {
62 | debounceDelay: 500
63 | }
64 | },
65 | scripts: {
66 | files: ['assets/js/**/*.js'],
67 | tasks: ['js'],
68 | options: {
69 | debounceDelay: 500
70 | }
71 | }
72 | }
73 | });
74 |
75 | // Default tasks
76 | grunt.registerTask('css', ['sass']);
77 | grunt.registerTask('js', ['jshint', 'concat']);
78 | grunt.registerTask('default', ['js', 'css']);
79 |
80 | grunt.util.linefeed = '\n';
81 | };
--------------------------------------------------------------------------------
/www/default/app/views/index/_homepage.phtml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/mysql.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::mysql(
2 | $enabled = false,
3 | $password = 'root',
4 | $port = '3306',
5 | $forward_port = false,
6 | $general_log = false,
7 | $slow_query_log = true,
8 | $log_queries_not_using_indexes = true,
9 | $long_query_time = 1,
10 | ) {
11 | if $enabled == true {
12 | class { '::mysql::server':
13 | root_password => $password,
14 | remove_default_accounts => true,
15 | override_options => {
16 | 'mysqld' => {
17 | 'bind-address' => '0.0.0.0',
18 | 'port' => $port,
19 | 'general_log' => $general_log ? { true => 'on', default => 'off' },
20 | 'slow_query_log' => $slow_query_log ? { true => 'on', default => 'off' },
21 | 'long_query_time' => $long_query_time,
22 | 'log_queries_not_using_indexes' => $log_queries_not_using_indexes ? { true => 'on', default => 'off' },
23 | },
24 | 'client' => {
25 | 'port' => $port,
26 | },
27 | }
28 | }
29 |
30 | mysql_user { 'root@%':
31 | ensure => 'present',
32 | password_hash => mysql_password( $password ),
33 | max_user_connections => 0,
34 | max_connections_per_hour => 0,
35 | max_queries_per_hour => 0,
36 | max_updates_per_hour => 0,
37 | require => Class['::mysql::server'],
38 | }
39 |
40 | mysql_grant { 'root@%/*.*':
41 | ensure => 'present',
42 | options => ['GRANT'],
43 | privileges => ['ALL'],
44 | table => '*.*',
45 | user => 'root@%',
46 | require => Mysql_user['root@%'],
47 | }
48 | } else {
49 | service { 'mysql':
50 | ensure => 'stopped',
51 | }
52 |
53 | package { 'mysql-server':
54 | ensure => 'purged',
55 | require => Service['mysql'],
56 | }
57 |
58 | exec { 'mysql-remove':
59 | command => '/usr/bin/apt-get autoremove --purge -y',
60 | refreshonly => true,
61 | subscribe => Package['mysql-server'],
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/init.pp:
--------------------------------------------------------------------------------
1 | class phalconvm ( $config ) {
2 | # prepare settings
3 | $settings = deep_merge( $config, {
4 | 'phpMyAdmin' => {
5 | 'port' => $config[mysql][port],
6 | },
7 | } )
8 |
9 | # prerequisites
10 | $packages = [
11 | 'imagemagick', 'subversion', 'git', 'zip', 'unzip', 'ngrep', 'curl', 'make',
12 | 'autoconf', 'automake', 'build-essential', 'libxslt1-dev', 're2c',
13 | 'libxml2-dev', 'libmcrypt-dev', 'vim', 'colordiff', 'gcc', 'libpcre3-dev',
14 | 'dos2unix', 'ntp', 'gettext', 'libyaml-dev', 'ack-grep', 'g++', 'ruby', 'rubygems-integration',
15 | ]
16 |
17 | package { $packages: ensure => 'installed' }
18 |
19 | # build known_hosts file
20 | phalconvm::utils::known_host { 'github.com': }
21 | phalconvm::utils::known_host { 'bitbucket.org': }
22 |
23 | # php
24 | class { 'phalconvm::php': * => $settings[php] }
25 | class { 'phalconvm::php::zephir': }
26 | class { 'phalconvm::php::phalcon': }
27 | class { 'phalconvm::php::pecl': }
28 |
29 | # tools
30 | class { 'phalconvm::tools::composer': }
31 | class { 'phalconvm::tools::npm': }
32 | class { 'phalconvm::tools::webgrind': }
33 | class { 'phalconvm::tools::opcache': }
34 |
35 | # services
36 | class { 'phalconvm::nginx': * => $settings[nginx] }
37 | class { 'phalconvm::varnish': * => $settings[varnish] }
38 | class { 'phalconvm::mysql': * => $settings[mysql] }
39 | class { 'phalconvm::mysql::phpmyadmin': * => $settings[phpMyAdmin] }
40 | class { 'phalconvm::postgres': * => $settings[postgres] }
41 | class { 'phalconvm::postgres::phppgadmin': * => $settings[phpPgAdmin] }
42 | class { 'phalconvm::mongodb': * => $settings[mongodb] }
43 | class { 'phalconvm::redis': * => $settings[redis] }
44 | class { 'phalconvm::memcached': * => $settings[memcached] }
45 | class { 'phalconvm::memcached::phpmemcacheadmin': * => $settings[phpMemcacheAdmin] }
46 | class { 'phalconvm::gearman': * => $settings[gearman] }
47 | class { 'phalconvm::rabbitmq': * => $settings[rabbitmq] }
48 | class { 'phalconvm::elasticsearch': * => $settings[elasticsearch] }
49 | class { 'phalconvm::sphinxsearch': * => $settings[sphinx] }
50 |
51 | # websites
52 | class { 'phalconvm::website': sites => $settings[sites] }
53 | }
54 |
--------------------------------------------------------------------------------
/www/default/app/views/layouts/index.phtml:
--------------------------------------------------------------------------------
1 |
57 |
58 |
59 |
60 |
61 |
62 | menu
63 |
64 |
65 |
68 |
69 |
70 |
71 |
72 | Save Changes
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | getContent(); ?>
81 |
--------------------------------------------------------------------------------
/www/default/data/defaults.json:
--------------------------------------------------------------------------------
1 | {
2 | "mysql": {
3 | "enabled": false,
4 | "password": "root",
5 | "port": "3306",
6 | "forward_port": false,
7 | "general_log": false,
8 | "slow_query_log": true,
9 | "log_queries_not_using_indexes": true,
10 | "long_query_time": "1"
11 | },
12 | "php": {
13 | "max_execution_time": "30",
14 | "memory_limit": "128M",
15 | "post_max_size": "1024M",
16 | "upload_max_filesize": "1024M",
17 | "max_file_uploads": "20",
18 | "display_errors": true,
19 | "display_startup_errors": true,
20 | "log_errors": true,
21 | "ignore_repeated_errors": false,
22 | "ignore_repeated_source": false,
23 | "track_errors": false,
24 | "html_errors": true,
25 | "xdebug_idekey": "PVMDBG",
26 | "xdebug_remote_port": "9000",
27 | "xdebug_var_display_max_children": "-1",
28 | "xdebug_var_display_max_data": "-1",
29 | "xdebug_var_display_max_depth": "-1"
30 | },
31 | "varnish": {
32 | "enabled": false,
33 | "port": "6081",
34 | "ttl": "120",
35 | "storage_size": "64m"
36 | },
37 | "phpMyAdmin": {
38 | "enabled": false,
39 | "maxDbList": "100",
40 | "maxTableList": "250",
41 | "showSQL": true,
42 | "allowUserDropDatabase": true,
43 | "confirm": true,
44 | "useDbSearch": true,
45 | "retainQueryBox": false,
46 | "ignoreMultiSubmitErrors": false
47 | },
48 | "nginx": {
49 | "client_max_body_size": "1024m",
50 | "client_body_timeout": "60s",
51 | "send_timeout": "60s",
52 | "keepalive_timeout": "75s",
53 | "gzip": false,
54 | "gzip_comp_level": "5",
55 | "gzip_min_length": "256",
56 | "gzip_disable": "msie6"
57 | },
58 | "redis": {
59 | "enabled": false,
60 | "port": "6379",
61 | "forward_port": false,
62 | "maxmemory": "64",
63 | "save_db_to_disk": true,
64 | "slowlog_log_slower_than": "100"
65 | },
66 | "postgres": {
67 | "enabled": false,
68 | "password": "postgres",
69 | "log_min_duration_statement": "250"
70 | },
71 | "phpPgAdmin": {
72 | "enabled": false
73 | },
74 | "mongodb": {
75 | "enabled": false
76 | },
77 | "memcached": {
78 | "enabled": false,
79 | "max_memory": "64",
80 | "port": "11211",
81 | "forward_port": false
82 | },
83 | "phpMemcacheAdmin": {
84 | "enabled": false
85 | },
86 | "gearman": {
87 | "enabled": false
88 | },
89 | "rabbitmq": {
90 | "enabled": false
91 | },
92 | "elasticsearch": {
93 | "enabled": false,
94 | "port": "9200",
95 | "forward_port": false
96 | },
97 | "sphinx": {
98 | "enabled": false
99 | },
100 | "sites": {
101 |
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/nginx.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::nginx (
2 | $client_max_body_size = '1024m',
3 | $client_body_timeout = '60s',
4 | $send_timeout = '60s',
5 | $keepalive_timeout = '75s',
6 | $gzip = false,
7 | $gzip_comp_level = '5',
8 | $gzip_min_length = '256',
9 | $gzip_disable = 'msie6',
10 | ) {
11 | $gzip_types = [
12 | 'application/atom+xml', 'pplication/javascript', 'application/json',
13 | 'application/rss+xml', 'application/vnd.ms-fontobject',
14 | 'application/x-font-ttf', 'application/x-javascript',
15 | 'application/x-web-app-manifest+json', 'application/xhtml+xml',
16 | 'application/xml', 'font/opentype', 'image/svg+xml', 'image/x-icon',
17 | 'text/css', 'text/plain', 'text/x-component',
18 | ]
19 |
20 | # file { '/srv/log/nginx':
21 | # ensure => 'directory',
22 | # }
23 |
24 | class { '::nginx::config':
25 | # require => File['/srv/log/nginx'],
26 | # nginx_error_log => '/srv/log/nginx/error.log',
27 | sendfile => 'Off',
28 | http_tcp_nopush => 'On',
29 | keepalive_timeout => $keepalive_timeout,
30 | server_tokens => 'Off',
31 | client_max_body_size => $client_max_body_size,
32 | gzip => $gzip ? { true => 'on', default => 'off' },
33 | gzip_comp_level => $gzip_comp_level,
34 | gzip_min_length => $gzip_min_length,
35 | gzip_disable => $gzip_disable,
36 | gzip_types => $gzip_types,
37 | http_cfg_append => {
38 | 'client_body_timeout' => $client_body_timeout,
39 | 'send_timeout' => $send_timeout,
40 | },
41 | }
42 |
43 | class { 'nginx':
44 | package_ensure => 'present',
45 | service_ensure => 'running',
46 | }
47 |
48 | nginx::resource::upstream { 'phpupstream':
49 | ensure => present,
50 | members => ['unix:/run/php/php7.0-fpm.sock'],
51 | }
52 |
53 | nginx::resource::vhost { "phalcon-vm":
54 | ensure => present,
55 | listen_options => 'default_server',
56 | www_root => "/srv/www/default/public",
57 | index_files => ['index.php'],
58 | try_files => ['$uri', '$uri/', '/index.php?$args'],
59 | locations => {
60 | '~ \.php$' => {
61 | ensure => present,
62 | try_files => ['$uri', '=404'],
63 | fastcgi => 'phpupstream',
64 | fastcgi_param => {
65 | 'SCRIPT_FILENAME' => '$document_root$fastcgi_script_name'
66 | },
67 | },
68 | '/php-status' => {
69 | ensure => present,
70 | fastcgi => 'phpupstream',
71 | fastcgi_param => {
72 | 'SCRIPT_FILENAME' => '$document_root$fastcgi_script_name'
73 | },
74 | }
75 | },
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/www/default/app/config/services.php:
--------------------------------------------------------------------------------
1 | setShared( 'config', function () {
12 | return new \Phalcon\Config( array(
13 | 'application' => array(
14 | 'appDir' => APP_PATH . '/',
15 | 'controllersDir' => APP_PATH . '/controllers/',
16 | 'viewsDir' => APP_PATH . '/views/',
17 | 'baseUri' => '/',
18 | ),
19 | ) );
20 | } );
21 |
22 | $di->setShared( 'url', function () {
23 | $config = $this->getConfig();
24 |
25 | $url = new \Phalcon\Mvc\Url();
26 | $url->setBaseUri( $config->application->baseUri );
27 |
28 | return $url;
29 | } );
30 |
31 | $di->setShared( 'view', function () {
32 | $config = $this->getConfig();
33 |
34 | $view = new \Phalcon\Mvc\View();
35 | $view->setDI( $this );
36 | $view->setViewsDir( $config->application->viewsDir );
37 |
38 | $view->registerEngines( [
39 | '.phtml' => \Phalcon\Mvc\View\Engine\Php::class
40 | ] );
41 |
42 | return $view;
43 | } );
44 |
45 | $di->setShared( 'router', function() {
46 | $router = new Router();
47 | $router->setUriSource( Router::URI_SOURCE_SERVER_REQUEST_URI );
48 |
49 | $router->add( '/', array(
50 | 'controller' => 'index',
51 | 'action' => 'index',
52 | ) );
53 |
54 | $router->add( '/save/env', array(
55 | 'controller' => 'index',
56 | 'action' => 'saveEnv',
57 | ) );
58 |
59 | $router->add( '/save/site', array(
60 | 'controller' => 'index',
61 | 'action' => 'saveSite',
62 | ) );
63 |
64 | return $router;
65 | } );
66 |
67 | $di->setShared( 'dispatcher', function () {
68 | $eventsManager = new EventsManager();
69 | $eventsManager->attach( 'dispatch:beforeException', function( Event $event, $dispatcher, Exception $exception ) {
70 | $index = array( "controller" => "index", "action" => "index" );
71 |
72 | if ( $exception instanceof DispatchException ) {
73 | $dispatcher->forward( $index );
74 | return false;
75 | }
76 |
77 | switch ( $exception->getCode() ) {
78 | case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
79 | case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
80 | $dispatcher->forward( $index );
81 | return false;
82 | }
83 | } );
84 |
85 | $dispatcher = new MvcDispatcher();
86 | $dispatcher->setEventsManager($eventsManager);
87 |
88 | return $dispatcher;
89 | } );
90 |
91 | $di->setShared( 'phalconvmConfig', function() {
92 | $defaults = file_get_contents( BASE_PATH . '/data/defaults.json' );
93 | $defaults = json_decode( $defaults, true );
94 |
95 | $settings = array();
96 | if ( is_readable( BASE_PATH . '/data/settings.json' ) ) {
97 | $settings = file_get_contents( BASE_PATH . '/data/settings.json' );
98 | $settings = json_decode( $settings, true );
99 | if ( ! $settings ) {
100 | $settings = array();
101 | }
102 | }
103 |
104 | $phalconvm = new Yaml( APP_PATH . '/config/phalconvm.yml' );
105 | $phalconvm = $phalconvm->toArray();
106 | $phalconvm['data'] = array_replace_recursive( $defaults, $settings );
107 |
108 | $tools = array(
109 | 'phpmyadmin' => 'phpMyAdmin',
110 | 'phppgadmin' => 'phpPgAdmin',
111 | 'phpmemcachedadmin' => 'phpMemcacheAdmin',
112 | );
113 |
114 | foreach ( $tools as $key => $label ) {
115 | $filename = sprintf( '%s/public/%s/index.php', BASE_PATH, $key );
116 | if ( ! empty( $phalconvm['data'][ $label ]['enabled'] ) && file_exists( $filename ) ) {
117 | $iframe = '/iframe/' . $key;
118 | $phalconvm['menu']['tools'][ $iframe ] = array( 'label' => $label );
119 | }
120 | }
121 |
122 | if ( empty( $phalconvm['menu']['tools'] ) ) {
123 | unset( $phalconvm['menu']['tools'] );
124 | }
125 |
126 | return $phalconvm;
127 | } );
128 |
129 | $di->setShared( 'fieldsConfig', function() {
130 | $fields = new Yaml( APP_PATH . '/config/fields.yml' );
131 | $fields = $fields->toArray();
132 |
133 | return $fields;
134 | } );
135 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | Vagrant.require_version ">= 1.8.5"
2 |
3 | required_plugins = %w(vagrant-hostsupdater vagrant-vbguest)
4 | plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
5 | if not plugins_to_install.empty?
6 | puts "Installing plugins: #{plugins_to_install.join(' ')}"
7 | if system "vagrant plugin install #{plugins_to_install.join(' ')}"
8 | exec "vagrant #{ARGV.join(' ')}"
9 | else
10 | abort "Installation of one or more plugins has failed. Aborting."
11 | end
12 | end
13 |
14 | require 'json'
15 |
16 | class ::Hash
17 | def deep_merge(second)
18 | merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
19 | self.merge(second, &merger)
20 | end
21 | end
22 |
23 | vagrant_dir = File.expand_path(File.dirname(__FILE__))
24 | data_dir = File.join(vagrant_dir, 'www', 'default', 'data')
25 |
26 | default_settings = File.join(data_dir, 'defaults.json')
27 | custom_settings = File.join(data_dir, 'settings.json')
28 |
29 | settings = JSON.parse(File.read(default_settings))
30 | if File.exists?(custom_settings)
31 | settings = settings.deep_merge(JSON.parse(File.read(custom_settings)))
32 | end
33 |
34 | Vagrant.configure(2) do |config|
35 | config.vm.box = "ubuntu/xenial64"
36 | config.vm.hostname = "phalcon-vm"
37 |
38 | config.vm.provider :virtualbox do |v|
39 | v.name = File.basename(vagrant_dir) + "_" + (Digest::SHA256.hexdigest vagrant_dir)[0..10]
40 |
41 | v.customize ["modifyvm", :id, "--memory", 1024]
42 | v.customize ["modifyvm", :id, "--cpus", 1]
43 | v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
44 | v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
45 | v.customize ["modifyvm", :id, "--rtcuseutc", "on"]
46 | v.customize ["modifyvm", :id, "--audio", "none"]
47 | v.customize ["modifyvm", :id, "--paravirtprovider", "kvm"]
48 | end
49 |
50 | config.vm.provider :parallels do |v, override| override.vm.box = "parallels/ubuntu-14.04"; end
51 | config.vm.provider :vmware_fusion do |v, override| override.vm.box = "netsensia/ubuntu-trusty64"; end
52 | config.vm.provider :vmware_workstation do |v, override| override.vm.box = "netsensia/ubuntu-trusty64"; end
53 | config.vm.provider :hyperv do |v, override| override.vm.box = "ericmann/trusty64"; end
54 |
55 | config.ssh.forward_agent = true
56 |
57 | config.vm.network "private_network", ip: "192.168.50.99"
58 | config.vm.provider :hyperv do |v, override| override.vm.network :private_network, id: "avm_primary", ip: nil; end
59 |
60 | if settings['varnish']['enabled'] === true
61 | config.vm.network "forwarded_port", guest: settings['varnish']['port'], host: settings['varnish']['port']
62 | end
63 | if settings['mysql']['enabled'] === true and settings['mysql']['forward_port'] === true
64 | config.vm.network "forwarded_port", guest: settings['mysql']['port'], host: settings['mysql']['port']
65 | end
66 | if settings['redis']['enabled'] === true and settings['redis']['forward_port'] === true
67 | config.vm.network "forwarded_port", guest: settings['redis']['port'], host: settings['redis']['port']
68 | end
69 | if settings['memcached']['enabled'] === true and settings['memcached']['forward_port'] === true
70 | config.vm.network "forwarded_port", guest: settings['memcached']['port'], host: settings['memcached']['port']
71 | end
72 | if settings['elasticsearch']['enabled'] === true and settings['elasticsearch']['forward_port'] === true
73 | config.vm.network "forwarded_port", guest: settings['elasticsearch']['port'], host: settings['elasticsearch']['port']
74 | end
75 |
76 | config.vm.synced_folder "provision/", "/srv/provision/"
77 | config.vm.synced_folder "ssh/", "/root/.ssh/", :owner => "root"
78 | # config.vm.synced_folder "log/", "/srv/log/", :owner => "www-data"
79 | config.vm.synced_folder "www/", "/srv/www/", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ]
80 |
81 | # config.vm.synced_folders.each do |id, options|
82 | # # Make sure we use Samba for file mounts on Windows
83 | # if ! options[:type] && Vagrant::Util::Platform.windows?
84 | # options[:type] = "smb"
85 | # end
86 | # end
87 |
88 | if defined?(VagrantPlugins::HostsUpdater)
89 | hosts = settings['sites'].map do |site|
90 | site['domains']
91 | end
92 |
93 | config.hostsupdater.aliases = hosts
94 | config.hostsupdater.remove_on_suspend = true
95 | end
96 |
97 | config.vm.provision "fix-no-tty", type: "shell" do |s|
98 | s.privileged = false
99 | s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
100 | end
101 |
102 | config.vm.provision "provision", type: "shell", path: File.join( "provision", "provision.sh" )
103 | config.vm.provision "startup", type: "shell", path: File.join( "provision", "startup.sh" ), run: "always"
104 | end
105 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/manifests/php.pp:
--------------------------------------------------------------------------------
1 | class phalconvm::php(
2 | $max_execution_time = '30',
3 | $memory_limit = '128M',
4 | $post_max_size = '1024M',
5 | $upload_max_filesize = '1024M',
6 | $max_file_uploads = '20',
7 | $display_errors = true,
8 | $display_startup_errors = true,
9 | $log_errors = true,
10 | $ignore_repeated_errors = false,
11 | $ignore_repeated_source = false,
12 | $track_errors = false,
13 | $html_errors = true,
14 | $xdebug_idekey = 'PVMDBG',
15 | $xdebug_remote_port = '9000',
16 | $xdebug_var_display_max_children = '-1',
17 | $xdebug_var_display_max_data = '-1',
18 | $xdebug_var_display_max_depth = '-1',
19 | ) {
20 | $packages = [
21 | 'php7.0', 'php7.0-fpm', 'php7.0-common', 'php7.0-dev', 'php7.0-mbstring',
22 | 'php7.0-mcrypt', 'php7.0-mysql', 'php7.0-imap', 'php7.0-curl', 'php7.0-gd',
23 | 'php7.0-json', 'php-memcache', 'php-imagick', 'php-xdebug', 'php7.0-pgsql',
24 | ]
25 |
26 | package { $packages: ensure => 'installed' }
27 |
28 | $poold_www = {
29 | 'www' => {
30 | 'listen.mode' => '0666',
31 | 'pm.max_requests' => 100,
32 | 'pm.status_path' => '/php-status',
33 | 'chdir' => '/',
34 | 'catch_workers_output' => 'yes',
35 | }
36 | }
37 |
38 | create_ini_settings( $poold_www, {
39 | path => '/etc/php/7.0/fpm/pool.d/www.conf',
40 | require => Package['php7.0-fpm'],
41 | notify => Service['php7.0-fpm'],
42 | } )
43 |
44 | $php = {
45 | 'PHP' => {
46 | 'short_open_tag' => 'Off',
47 | 'allow_call_time_pass_reference' => 'Off',
48 | 'max_execution_time' => $max_execution_time,
49 | 'memory_limit' => $memory_limit,
50 | 'error_reporting' => 'E_ALL | E_STRICT',
51 | 'display_errors' => $display_errors ? { true => 'On', default => 'Off' },
52 | 'display_startup_errors' => $display_startup_errors ? { true => 'On', default => 'Off' },
53 | 'log_errors' => $log_errors ? { true => 'On', default => 'Off' },
54 | 'log_errors_max_len' => '1024',
55 | 'ignore_repeated_errors' => $ignore_repeated_errors ? { true => 'On', default => 'Off' },
56 | 'ignore_repeated_source' => $ignore_repeated_source ? { true => 'On', default => 'Off' },
57 | 'track_errors' => $track_errors ? { true => 'On', default => 'Off' },
58 | 'html_errors' => $html_errors ? { true => 'On', default => 'Off' },
59 | # 'error_log' => '/srv/log/php_errors.log',
60 | 'post_max_size' => $post_max_size,
61 | 'upload_max_filesize' => $upload_max_filesize,
62 | 'max_file_uploads' => $max_file_uploads,
63 | 'default_socket_timeout' => 60,
64 | }
65 | }
66 |
67 | create_ini_settings( $php, {
68 | path => '/etc/php/7.0/fpm/php.ini',
69 | require => Package['php7.0-fpm'],
70 | notify => Service['php7.0-fpm'],
71 | } )
72 |
73 | # file { '/srv/log/xdebug-remote.log':
74 | # ensure => 'present',
75 | # owner => 'www-data',
76 | # group => 'www-data',
77 | # }
78 |
79 | $xdebug = {
80 | 'XDebug' => {
81 | 'xdebug.collect_params' => 1,
82 | 'xdebug.idekey' => $xdebug_idekey,
83 | 'xdebug.profiler_enable_trigger' => 1,
84 | 'xdebug.profiler_output_name' => 'cachegrind.out.%t-%s',
85 | 'xdebug.remote_enable' => 1,
86 | 'xdebug.remote_host' => '192.168.50.99',
87 | # 'xdebug.remote_log' => '/srv/log/xdebug-remote.log',
88 | 'xdebug.remote_port' => $xdebug_remote_port,
89 | 'xdebug.var_display_max_children' => $xdebug_var_display_max_children,
90 | 'xdebug.var_display_max_data' => $xdebug_var_display_max_data,
91 | 'xdebug.var_display_max_depth' => $xdebug_var_display_max_depth,
92 | }
93 | }
94 |
95 | create_ini_settings( $xdebug, {
96 | path => '/etc/php/7.0/mods-available/xdebug.ini',
97 | # require => [ Package['php-xdebug'], File['/srv/log/xdebug-remote.log'] ],
98 | require => Package['php-xdebug'],
99 | notify => Service['php7.0-fpm'],
100 | } )
101 |
102 | $opcache = {
103 | 'opcache' => {
104 | 'opcache.enable' => 1,
105 | 'opcache.memory_consumption' => 128,
106 | }
107 | }
108 |
109 | create_ini_settings( $opcache, {
110 | path => '/etc/php/7.0/mods-available/opcache.ini',
111 | require => Package['php7.0'],
112 | notify => Service['php7.0-fpm'],
113 | } )
114 |
115 | service { 'php7.0-fpm':
116 | ensure => 'running',
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Phalcon VM 2.0.1
2 |
3 | Phalcon VM is an open source [Vagrant](https://www.vagrantup.com/) configuration which contains wide range of tools required in modern web development. Like a Swiss Army Knife, Phalcon VM allows you to easily activate and use tools required for you project.
4 |
5 | The primary goal of this project is to provide an approachable development environment with a modern server configuration for project written with PHP7 and Phalcon 3.x framework. The project also contains compiled [Zephir](http://zephir-lang.com/) executable, which allows you to go even further, beyond just PHP. However it doesn't mean that you have to use only Phalcon framework, you can use it with your framework of choice.
6 |
7 | ## What will be installed?
8 |
9 | After initial provision of your vagrant machine, you will have a fresh Ubuntu 16.04 instance with initial applications set required for very basic development. It includes Nginx server, PHP7 and its extensions (including Phalcon 3.x), Zephir, Composer (with Phalcon Dev Tools installed globally) and a few more. It will also contain a default site which will allow you to configure your environment as you want.
10 |
11 | The default site will allow you to activate and configure Varnish cache, MySQL, PostgreSQL or MongoDb databases (along with phpMyAdmin and phpPgAdmin tools), Redis and/or Memcached caching systems (along with phpMemcachedAdmin tool), Gearman and/or RabbitMQ jobs servers, Elasticsearch and/or Sphinxsearch search engines.
12 |
13 | Here is full list of what is and can be installed:
14 |
15 | 1. [Ubuntu](http://www.ubuntu.com/) 16.04 LTS (Xenial Xerus)
16 | 1. [nginx](http://nginx.org/) (mainline version)
17 | 1. [Varnish](http://varnish-cache.org/) 4.x
18 | 1. [Phalcon PHP](https://phalconphp.com/) 3.x
19 | 1. [Phalcon Dev Tools](https://docs.phalconphp.com/en/latest/reference/tools.html) 3.x
20 | 1. [Zephir](http://zephir-lang.com/) 0.9.x
21 | 1. [php-fpm](http://php-fpm.org/) 7.0.x
22 | 1. PHP [memcache extension](https://pecl.php.net/package/memcache)
23 | 1. PHP [xdebug extension](https://pecl.php.net/package/xdebug/)
24 | 1. PHP [imagick extension](https://pecl.php.net/package/imagick/)
25 | 1. [PHPUnit](https://phpunit.de/)
26 | 1. [MySQL](https://www.mysql.com/)
27 | 1. [PostgreSQL](https://www.postgresql.org/)
28 | 1. [MongoDB](https://www.mongodb.com/)
29 | 1. [Redis](https://redis.io/)
30 | 1. [Memcached](http://memcached.org/)
31 | 1. [Gearman](http://gearman.org/)
32 | 1. [RabbitMQ](https://www.rabbitmq.com/)
33 | 1. [Elasticsearch](https://www.elastic.co/)
34 | 1. [Sphinxsearch](http://sphinxsearch.com/)
35 | 1. [git](http://git-scm.com/)
36 | 1. [subversion](https://subversion.apache.org/)
37 | 1. [ngrep](http://ngrep.sourceforge.net/usage.html)
38 | 1. [dos2unix](http://dos2unix.sourceforge.net/)
39 | 1. [Composer](https://github.com/composer/composer)
40 | 1. [phpMyAdmin](http://www.phpmyadmin.net/)
41 | 1. [phpPgAdmin](https://github.com/phppgadmin/phppgadmin)
42 | 1. [phpMemcachedAdmin](https://code.google.com/p/phpmemcacheadmin/)
43 | 1. [Opcache Status](https://github.com/rlerdorf/opcache-status)
44 | 1. [Webgrind](https://github.com/jokkedk/webgrind)
45 | 1. [NodeJs](https://nodejs.org/)
46 | 1. [Grunt](http://gruntjs.com/)
47 | 1. [Gulp](http://gulpjs.com/)
48 |
49 | ## Setup Phalcon VM
50 |
51 | 1. Start with any local operating system such as Mac OS X, Linux, or Windows.
52 | 1. Install [VirtualBox 5.0.x](https://www.virtualbox.org/wiki/Downloads).
53 | 1. Install [Vagrant 1.8.5+](https://www.vagrantup.com/downloads.html).
54 | * `vagrant` will now be available as a command in your terminal, try it out.
55 | * ***Note:*** If Vagrant is already installed, use `vagrant -v` to check the version. You may want to consider upgrading if a much older version is in use.
56 | 1. Clone or extract the Phalcon VM project into a local directory.
57 | * `git clone git@github.com:eugene-manuilov/phalcon-vm.git phalcon-vm`.
58 | * OR download and extract the repository [zip file](https://github.com/eugene-manuilov/phalcon-vm/archive/master.zip) to a local directory on your computer.
59 | 1. In a command prompt, change into the new directory with `cd phalcon-vm`.
60 | 1. Start the Vagrant environment with `vagrant up`.
61 | * Be patient as the magic happens. This could take a while on the first run as your local machine downloads the required files.
62 | * Watch as the script ends, as an administrator or `su` ***password may be required*** to properly modify the hosts file on your local machine.
63 | 1. Visit [the default site](http://phalcon-vm/) in your browser, you should see a dashboard where you can select what tools are needed for your project.
64 |
65 | ## Create Custom Site
66 |
67 | You can easily create a new site in the default dashboard. To do this, go to the [http://phalcon-vm/](http://phalcon-vm/) site and click on `+ Add New Site` link in the sidebar. After doing it you should see a popup which prompts you to enter new site details. So you need to enter required fields like **site name**, **directory** and **domains** to be able to create a new site. After entering that data you need to click on `ADD` button and new site will appear in the sidebar. Finally you need to click `SAVE CHANGES` button in the top right corner to save your changes on disk. After doing it your new site will be created on next provision. So the last step is to stop your current vagrant machine by using `vagrant halt` command and start it again with provisioning flag by using `vagrant up --provision` command.
68 |
69 | Please, pay attention to the domains field in the site form. It allows you to enter multiple domains for your site. To do it, just separate your domains with spaces like this: `example.dev test.example.dev jobs.example.dev`. In this case all these domains will be properly added to your local maching hosts file and added to the nginx setup on your vagrant machine.
70 |
71 | The new site form is also allows you to create new site using existing repository. Just enter a link to your repository into appropriate field and select proper VCS provider and it will be used to build your site on next provision. **One caveat here**: please, don't forget to copy your private SSH keys to the `ssh/` folder if you want to use SSH connection to your repository.
72 |
73 | ## Troubleshooting on Windows
74 |
75 | ### Vagrant gets stucks
76 |
77 | If any vagrant command gets stuck on your Windows machine, then you need to check your PowerShell version. Major version needs to be equal or grater than 3. Use `$PSVersionTable.PSVersion` to determine the engine version.
78 |
79 | ## LICENSE
80 |
81 | The MIT License (MIT)
82 |
--------------------------------------------------------------------------------
/provision/puppet/modules/phalconvm/templates/phppgadmin/config.inc.php.erb:
--------------------------------------------------------------------------------
1 |