Initial commit with full version working
This commit is contained in:
parent
95c2a16af2
commit
51d83a436e
24 changed files with 3547 additions and 0 deletions
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
.vagrant/
|
||||
.DS_Store
|
||||
*.log
|
||||
*.box
|
||||
|
||||
apache/**/*
|
||||
!apache/conf/.gitkeep
|
||||
!apache/logs/.gitkeep
|
||||
|
||||
mysql/**/*
|
||||
!mysql/data/.gitkeep
|
||||
!mysql/logs/.gitkeep
|
||||
|
||||
php/**/*
|
||||
!php/logs/.gitkeep
|
||||
|
||||
www/**/*
|
||||
!www/index.php
|
||||
!www/mail.php
|
||||
!www/_browser/
|
||||
|
||||
*.sublime*
|
1
README.md
Normal file
1
README.md
Normal file
|
@ -0,0 +1 @@
|
|||
COMING SOON
|
104
README_FR.md
Normal file
104
README_FR.md
Normal file
|
@ -0,0 +1,104 @@
|
|||
# VAGRANT LAMP ENVIRONMENT
|
||||
|
||||
## Objectifs
|
||||
|
||||
Ce dépôt vous permet de récupérer une version fonctionnelle de LAMP sous Ubuntu 16.04 LTS pour Vagrant pour vos développements locaux.
|
||||
|
||||
En une ligne de commande, un environnement LAMP est installé sur le poste du développeur, avec tous les outils nécessaires.
|
||||
|
||||
Tous les développeurs partagent donc de façon aisée les mêmes outils et les mêmes versions. Si certains outils sont manquants ou certaines configurations sont à adapter. Il suffit ensuite de relancer un `vagrant provision` pour récupérer les mises à jour.
|
||||
|
||||
### ⚠ Attention ⚠
|
||||
Le principe général est le suivant : la VM Ubuntu ne doit pas être modifiée localement car les modifications seront écrasées à la prochaine mise à jour. Il ne faut donc pas **installer quoi que ce soit sur la VM directement, ni conserver des fichiers sur la VM**, tout cela pourrait être définitivement perdu. Les fichiers ou dossiers doivent être stockés sur la machine Host et partagés sur la machine Guest (VM).
|
||||
|
||||
Ceci étant dit, vous pouvez faire ce que vous voulez de votre VM : installer, désinstaller, détruire, réparer, corrompre... car vous savez qu'il suffit de `vagrant destroy` et de `vagrant up` de nouveau pour retrouver une VM fraiche, avec tous les outils réinstallés.
|
||||
|
||||
## Contenu
|
||||
|
||||
- Apache2 (http://www.apache.org)
|
||||
- Bower (https://bower.io)
|
||||
- Composer (https://getcomposer.org/)
|
||||
- Bundler (http://bundler.io)
|
||||
- Browser Sync (https://www.browsersync.io)
|
||||
- CURL (https://curl.haxx.se)
|
||||
- Deployer (https://deployer.org)
|
||||
- Drush@8.1.10 (https://github.com/drush-ops/drush)
|
||||
- Drupal Console (https://drupalconsole.com/)
|
||||
- Git (https://git-scm.com/)
|
||||
- Git-LFS (https://git-lfs.github.com)
|
||||
- Gulp (http://gulpjs.com/)
|
||||
- PHP7 (http://www.php.net) :
|
||||
- CURL
|
||||
- Dev
|
||||
- GD
|
||||
- Json
|
||||
- MySQL
|
||||
- Readline
|
||||
- XML
|
||||
- Intl
|
||||
- Mbstring
|
||||
- Mcrypt
|
||||
- Xdebug
|
||||
- Zip
|
||||
- Sqlite3
|
||||
- Memcached
|
||||
- Mailcatcher (https://mailcatcher.me/)
|
||||
- MariaDB (https://mariadb.org/)
|
||||
- Memcached (http://www.memcached.org/)
|
||||
- MongoDB (https://www.mongodb.com/)
|
||||
- Multitail (https://www.vanheusden.com/multitail/)
|
||||
- Nano
|
||||
- NodeJS 7 (https://nodejs.org/en/) et NPM (https://www.npmjs.com/)
|
||||
- NTPDate
|
||||
- Redis (https://redis.io/)
|
||||
- SASS (http://sass-lang.com)
|
||||
- Sqlite3
|
||||
- Unzip
|
||||
- WP_Cli (http://wp-cli.org/)
|
||||
- XDebug (https://xdebug.org/)
|
||||
|
||||
## Installation
|
||||
|
||||
- Télécharger et installer VirtualBox (http://www.virtualbox.org/)
|
||||
- Télécharger et installer Vagrant (https://www.vagrantup.com/)
|
||||
- Cloner la dernière version du dépôt (https://github.com/axeloz/vagrant-lamp) dans `/Users/utilisateur/Sites`
|
||||
- Ouvrir un Terminal et se rendre dans le dossier ainsi téléchargé
|
||||
- Lancer une commande `vagrant up`
|
||||
- Optionnellement, vous pouvez installer Vagrant Manager (http://vagrantmanager.com/) pour gérer la Virtual Machine
|
||||
|
||||
### ⚠ Attention ⚠
|
||||
Le montage du dossier /vagrant se fait à présent en NFS. Cette opération nécessite les droits administrateurs de votre machine hôte. Il vous sera demandé votre passe de passe de session à chaque démarrage de la machine. Pour éviter cela, il est possible d'éditer les sudoers pour autoriser Vagrant à opérer les changements NFS en ajoutant, dans la configuration des sudoers, les lignes suivantes :
|
||||
|
||||
```
|
||||
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
|
||||
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
|
||||
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
|
||||
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE
|
||||
```
|
||||
|
||||
## Mise à jour
|
||||
|
||||
- Se rendre à la racine du dépôt `/Users/utilisateur/Sites/vagrant-lamp`
|
||||
- Faire un `git pull`
|
||||
- Faire un `vagrant reload --provision`
|
||||
|
||||
## Accès
|
||||
|
||||
- Pour accéder en SSH à la VM, lancez `vagrant ssh` depuis le dossier de la VM
|
||||
- Une IP `192.168.99.100` est créée par la VM
|
||||
- La VM répond également sur `localhost`
|
||||
- Pour accéder aux sites : http://localhost:8080
|
||||
- Pour accéder à l'interface de Mailcatcher : http://localhost:1080
|
||||
- Pour accéder à MySQL depuis le Host : mysql://vagrant:vagrant@localhost:3306
|
||||
- Pour accéder au SMTP de Mailcatcher depuis le Host : smtp://localhost:1025
|
||||
- Pour accéder à BrowserSync depuis le Host : http://localhost:3000
|
||||
- Pour accéder à DRUSH, lancez la commande `drush` depuis la VM
|
||||
- Pour accéder à WP_CLI, lancez la commande `wp` depuis la VM
|
||||
- Pour accéder à DEPLOYER, lancez la commande `dep` depuis la VM
|
||||
- Pour accéder à GULP, lancez la commande `gulp` depuis la VM
|
||||
|
||||
## Fonctionnalités à ajouter
|
||||
|
||||
- Postfix
|
||||
|
||||
|
111
Vagrantfile
vendored
Normal file
111
Vagrantfile
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://atlas.hashicorp.com/search.
|
||||
config.vm.box = "axeloz/ubuntu-server-16.04"
|
||||
|
||||
|
||||
#config.ssh.private_key_path="~/.ssh/id_rsa"
|
||||
config.ssh.username = 'vagrant'
|
||||
config.ssh.password = 'vagrant'
|
||||
config.ssh.forward_agent = true
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
|
||||
# Default HTTP port
|
||||
config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
# Additional HTTP port for PHP Serve or other
|
||||
config.vm.network "forwarded_port", guest: 8081, host: 8081
|
||||
config.vm.network "forwarded_port", guest: 8082, host: 8082
|
||||
# MySQL port
|
||||
config.vm.network "forwarded_port", guest: 3306, host: 3306
|
||||
# Postfix SMTP port
|
||||
config.vm.network "forwarded_port", guest: 25, host: 2525
|
||||
# Mailcatcher SMTP port
|
||||
config.vm.network "forwarded_port", guest: 1025, host: 1025
|
||||
# Mailcatcher HTTP port
|
||||
config.vm.network "forwarded_port", guest: 1080, host: 1080
|
||||
# BrowserSync port
|
||||
config.vm.network "forwarded_port", guest: 3000, host: 3000
|
||||
config.vm.network "forwarded_port", guest: 3001, host: 3001
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
config.vm.network "private_network", ip: "192.168.99.100"
|
||||
|
||||
# Create a public network, which generally matched to bridged network.
|
||||
# Bridged networks make the machine appear as another physical device on
|
||||
# your network.
|
||||
# config.vm.network "public_network"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ['actimeo=2']
|
||||
|
||||
#config.vm.synced_folder "./www", "/vagrant/www", type: "nfs"
|
||||
#config.vm.synced_folder "./mysql", "/vagrant/mysql", type: "nfs"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
#vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
vb.memory = "1024"
|
||||
vb.name = "w_vagrant_lamp"
|
||||
end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||
# such as FTP and Heroku are also available. See the documentation at
|
||||
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||
# config.push.define "atlas" do |push|
|
||||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||
# end
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
# config.vm.provision "shell", inline: <<-SHELL
|
||||
# apt-get update
|
||||
# apt-get install -y apache2
|
||||
# SHELL
|
||||
|
||||
config.vm.provision "chef_solo" do |chef|
|
||||
chef.add_recipe "lamp"
|
||||
end
|
||||
|
||||
config.vm.provision "shell", run: 'always', inline: <<-SHELL
|
||||
service apache2 start
|
||||
service mysql start
|
||||
SHELL
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
16
cookbooks/lamp/.gitignore
vendored
Normal file
16
cookbooks/lamp/.gitignore
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
.vagrant
|
||||
Berksfile.lock
|
||||
*~
|
||||
*#
|
||||
.#*
|
||||
\#*#
|
||||
.*.sw[a-z]
|
||||
*.un~
|
||||
|
||||
# Bundler
|
||||
Gemfile.lock
|
||||
bin/*
|
||||
.bundle/*
|
||||
|
||||
.kitchen/
|
||||
.kitchen.local.yml
|
21
cookbooks/lamp/.kitchen.yml
Normal file
21
cookbooks/lamp/.kitchen.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
driver:
|
||||
name: vagrant
|
||||
|
||||
provisioner:
|
||||
name: chef_zero
|
||||
|
||||
# Uncomment the following verifier to leverage Inspec instead of Busser (the
|
||||
# default verifier)
|
||||
# verifier:
|
||||
# name: inspec
|
||||
|
||||
platforms:
|
||||
- name: ubuntu-14.04
|
||||
- name: centos-7.1
|
||||
|
||||
suites:
|
||||
- name: default
|
||||
run_list:
|
||||
- recipe[lamp::default]
|
||||
attributes:
|
3
cookbooks/lamp/Berksfile
Normal file
3
cookbooks/lamp/Berksfile
Normal file
|
@ -0,0 +1,3 @@
|
|||
source 'https://supermarket.chef.io'
|
||||
|
||||
metadata
|
4
cookbooks/lamp/README.md
Normal file
4
cookbooks/lamp/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# lamp
|
||||
|
||||
TODO: Enter the cookbook description here.
|
||||
|
102
cookbooks/lamp/chefignore
Normal file
102
cookbooks/lamp/chefignore
Normal file
|
@ -0,0 +1,102 @@
|
|||
# Put files/directories that should be ignored in this file when uploading
|
||||
# to a chef-server or supermarket.
|
||||
# Lines that start with '# ' are comments.
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
Icon?
|
||||
nohup.out
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# SASS #
|
||||
########
|
||||
.sass-cache
|
||||
|
||||
# EDITORS #
|
||||
###########
|
||||
\#*
|
||||
.#*
|
||||
*~
|
||||
*.sw[a-z]
|
||||
*.bak
|
||||
REVISION
|
||||
TAGS*
|
||||
tmtags
|
||||
*_flymake.*
|
||||
*_flymake
|
||||
*.tmproj
|
||||
.project
|
||||
.settings
|
||||
mkmf.log
|
||||
|
||||
## COMPILED ##
|
||||
##############
|
||||
a.out
|
||||
*.o
|
||||
*.pyc
|
||||
*.so
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*/rdoc/
|
||||
|
||||
# Testing #
|
||||
###########
|
||||
.watchr
|
||||
.rspec
|
||||
spec/*
|
||||
spec/fixtures/*
|
||||
test/*
|
||||
features/*
|
||||
examples/*
|
||||
Guardfile
|
||||
Procfile
|
||||
.kitchen*
|
||||
.rubocop.yml
|
||||
spec/*
|
||||
Rakefile
|
||||
.travis.yml
|
||||
.foodcritic
|
||||
.codeclimate.yml
|
||||
|
||||
# SCM #
|
||||
#######
|
||||
.git
|
||||
*/.git
|
||||
.gitignore
|
||||
.gitmodules
|
||||
.gitconfig
|
||||
.gitattributes
|
||||
.svn
|
||||
*/.bzr/*
|
||||
*/.hg/*
|
||||
*/.svn/*
|
||||
|
||||
# Berkshelf #
|
||||
#############
|
||||
Berksfile
|
||||
Berksfile.lock
|
||||
cookbooks/*
|
||||
tmp
|
||||
|
||||
# Cookbooks #
|
||||
#############
|
||||
CONTRIBUTING*
|
||||
CHANGELOG*
|
||||
TESTING*
|
||||
MAINTAINERS.toml
|
||||
|
||||
# Strainer #
|
||||
############
|
||||
Colanderfile
|
||||
Strainerfile
|
||||
.colander
|
||||
.strainer
|
||||
|
||||
# Vagrant #
|
||||
###########
|
||||
.vagrant
|
||||
Vagrantfile
|
7
cookbooks/lamp/metadata.rb
Normal file
7
cookbooks/lamp/metadata.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
name 'lamp'
|
||||
maintainer 'The Authors'
|
||||
maintainer_email 'you@example.com'
|
||||
license 'all_rights'
|
||||
description 'Installs/Configures lamp'
|
||||
long_description 'Installs/Configures lamp'
|
||||
version '0.1.0'
|
301
cookbooks/lamp/recipes/default.rb
Normal file
301
cookbooks/lamp/recipes/default.rb
Normal file
|
@ -0,0 +1,301 @@
|
|||
#
|
||||
# Cookbook Name:: lamp
|
||||
# Recipe:: default
|
||||
#
|
||||
|
||||
apt_update 'all platforms' do
|
||||
frequency 86400
|
||||
action :periodic
|
||||
end
|
||||
|
||||
#####################################
|
||||
# VARIOUS TOOLS
|
||||
#####################################
|
||||
package 'nano'
|
||||
package 'multitail'
|
||||
package 'telnet'
|
||||
package 'apt-transport-https'
|
||||
package 'build-essential'
|
||||
package 'curl'
|
||||
package 'unzip'
|
||||
|
||||
#####################################
|
||||
# NTPDATE
|
||||
#####################################
|
||||
package 'ntpdate'
|
||||
template '/etc/cron.daily/ntpdate' do
|
||||
source 'ntpdate_cron'
|
||||
end
|
||||
|
||||
|
||||
#####################################
|
||||
# PHP
|
||||
#####################################
|
||||
package 'php7.0'
|
||||
package 'php7.0-curl'
|
||||
package 'php7.0-dev'
|
||||
package 'php7.0-gd'
|
||||
package 'php7.0-json'
|
||||
package 'php7.0-mysql'
|
||||
package 'php7.0-readline'
|
||||
package 'php7.0-xml'
|
||||
package 'php7.0-intl'
|
||||
package 'php7.0-mbstring'
|
||||
package 'php7.0-mcrypt'
|
||||
package 'php-xdebug'
|
||||
package 'php7.0-zip'
|
||||
package 'php7.0-sqlite3'
|
||||
|
||||
|
||||
#####################################
|
||||
# MEMCACHE
|
||||
#####################################
|
||||
package 'memcached'
|
||||
package 'php-memcached'
|
||||
|
||||
|
||||
#####################################
|
||||
# APACHE
|
||||
#####################################
|
||||
package 'apache2'
|
||||
package 'libapache2-mod-php7.0'
|
||||
|
||||
service 'apache2' do
|
||||
supports :status => true
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
template '/etc/apache2/conf-enabled/users.conf' do
|
||||
source 'users.conf'
|
||||
end
|
||||
|
||||
template '/etc/apache2/sites-enabled/000-default.conf' do
|
||||
source 'apache-000_default.conf.erb'
|
||||
notifies :restart, "service[apache2]"
|
||||
manage_symlink_source true
|
||||
end
|
||||
|
||||
template '/etc/php/7.0/apache2/php.ini' do
|
||||
source 'php.ini.erb'
|
||||
end
|
||||
|
||||
execute 'enable_modrewrite' do
|
||||
user 'root'
|
||||
command '/usr/bin/env a2enmod rewrite'
|
||||
creates '/etc/apache2/mods-enabled/rewrite.load'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# GIT
|
||||
#####################################
|
||||
package 'python-software-properties'
|
||||
|
||||
execute 'add_git_core_ppa' do
|
||||
user 'root'
|
||||
command 'add-apt-repository ppa:git-core/ppa && apt-get update'
|
||||
creates '/usr/bin/git-lfs'
|
||||
end
|
||||
|
||||
execute 'install_git_repo' do
|
||||
user 'root'
|
||||
command 'curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash'
|
||||
creates '/usr/bin/git-lfs'
|
||||
end
|
||||
|
||||
package 'git'
|
||||
package 'git-lfs'
|
||||
|
||||
|
||||
|
||||
#####################################
|
||||
# COMPOSER
|
||||
#####################################
|
||||
execute 'install_composer' do
|
||||
user 'root'
|
||||
command 'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer'
|
||||
creates '/usr/local/bin/composer'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# MYSQL
|
||||
#####################################
|
||||
|
||||
package 'mariadb-server'
|
||||
package 'mariadb-client'
|
||||
|
||||
template '/etc/init.d/mysql' do
|
||||
source 'mysql-init-d'
|
||||
end
|
||||
|
||||
template '/etc/mysql/mariadb.conf.d/50-server.cnf' do
|
||||
source 'mysql-50-server.cnf'
|
||||
end
|
||||
|
||||
service 'mysql' do
|
||||
supports :start => true, :stop => true, :restart => true, :reload => true, :status => true
|
||||
action :restart
|
||||
end
|
||||
|
||||
bash 'mysql_run_perms' do
|
||||
user 'root'
|
||||
code <<-EOH
|
||||
if [ ! -d /var/run/mysqld ]; then
|
||||
mkdir /var/run/mysqld
|
||||
fi
|
||||
chown -R vagrant:vagrant /var/run/mysqld
|
||||
EOH
|
||||
end
|
||||
|
||||
execute 'mysql_create_databases' do
|
||||
user 'root'
|
||||
notifies :stop, 'service[mysql]', :before
|
||||
command '/usr/bin/env mysql_install_db'
|
||||
creates '/vagrant/mysql/data/mysql'
|
||||
notifies :start, 'service[mysql]', :immediately
|
||||
end
|
||||
|
||||
execute 'mysql_create_user' do
|
||||
command '/usr/bin/env mysql -uroot -e "CREATE USER \'vagrant\'@\'%\' IDENTIFIED BY \'vagrant\'; GRANT ALL PRIVILEGES ON *.* TO \'vagrant\'@\'%\' WITH GRANT OPTION;"'
|
||||
not_if '/usr/bin/env mysql -uroot -e "SELECT User FROM mysql.user WHERE User = \'vagrant\'" |grep vagrant'
|
||||
end
|
||||
|
||||
|
||||
#####################################
|
||||
# NODEJS
|
||||
#####################################
|
||||
execute 'install_nodejs' do
|
||||
user 'root'
|
||||
command 'curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -'
|
||||
creates '/usr/bin/nodejs'
|
||||
end
|
||||
package 'nodejs'
|
||||
|
||||
#####################################
|
||||
# MAILCATCHER
|
||||
#####################################
|
||||
package 'bundler'
|
||||
package 'libsqlite3-dev'
|
||||
|
||||
execute 'install_mailcatcher' do
|
||||
user 'root'
|
||||
command 'gem install mailcatcher'
|
||||
creates '/usr/local/bin/mailcatcher'
|
||||
end
|
||||
|
||||
bash 'start_mailcatcher' do
|
||||
user 'root'
|
||||
code <<-EOH
|
||||
killall mailcatcher
|
||||
mailcatcher --no-quit --ip 0.0.0.0
|
||||
EOH
|
||||
end
|
||||
|
||||
|
||||
#####################################
|
||||
# WP_CLI
|
||||
#####################################
|
||||
bash 'install_wpcli' do
|
||||
code <<-EOH
|
||||
/usr/bin/env curl -sO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
||||
if [ $? -eq 0 ] && [ -f "wp-cli.phar" ]; then
|
||||
chmod +x wp-cli.phar
|
||||
mv wp-cli.phar /usr/local/bin/wp
|
||||
fi
|
||||
EOH
|
||||
creates '/usr/local/bin/wp'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# DRUSH
|
||||
#####################################
|
||||
# Installs drush@8.1.10
|
||||
bash 'install_drush' do
|
||||
code <<-EOH
|
||||
/usr/bin/env curl -sLO https://github.com/drush-ops/drush/releases/download/8.1.10/drush.phar
|
||||
if [ $? -eq 0 ] && [ -f "drush.phar" ]; then
|
||||
chmod +x drush.phar
|
||||
mv drush.phar /usr/local/bin/drush
|
||||
fi
|
||||
EOH
|
||||
creates '/usr/local/bin/drush'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# DRUPAL CONSOLE
|
||||
#####################################
|
||||
bash 'install_drupal_console' do
|
||||
code <<-EOH
|
||||
php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar
|
||||
if [ $? -eq 0 ] && [ -f "drupal.phar" ]; then
|
||||
chmod +x drupal.phar
|
||||
mv drupal.phar /usr/local/bin/drupal
|
||||
fi
|
||||
EOH
|
||||
creates '/usr/local/bin/drupal'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# BROWSER SYNC
|
||||
#####################################
|
||||
execute 'install_browsersync' do
|
||||
user 'root'
|
||||
command 'npm install -g browser-sync'
|
||||
creates '/usr/bin/browser-sync'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# NPM
|
||||
#####################################
|
||||
execute 'install_gulp' do
|
||||
user 'root'
|
||||
command 'npm install -g npm'
|
||||
creates '/usr/bin/npm'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# BOWER
|
||||
#####################################
|
||||
execute 'install_bower' do
|
||||
user 'root'
|
||||
command 'npm install -g bower'
|
||||
creates '/usr/bin/bower'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# Deployer
|
||||
#####################################
|
||||
bash 'install_deployer' do
|
||||
code <<-EOH
|
||||
/usr/bin/env curl -sLO https://deployer.org/deployer.phar
|
||||
if [ $? -eq 0 ] && [ -f "deployer.phar" ]; then
|
||||
chmod +x deployer.phar
|
||||
mv deployer.phar /usr/local/bin/dep
|
||||
fi
|
||||
EOH
|
||||
creates '/usr/local/bin/dep'
|
||||
end
|
||||
|
||||
#####################################
|
||||
# REDIS
|
||||
#####################################
|
||||
package 'redis-server'
|
||||
service 'redis-server' do
|
||||
action :stop
|
||||
end
|
||||
|
||||
#####################################
|
||||
# MONGODB
|
||||
#####################################
|
||||
package 'mongodb'
|
||||
service 'mysql' do
|
||||
action :stop
|
||||
end
|
||||
|
||||
#####################################
|
||||
# SASS
|
||||
#####################################
|
||||
execute 'install_sass' do
|
||||
user 'root'
|
||||
command 'gem install sass'
|
||||
creates '/usr/local/bin/sass'
|
||||
end
|
2
cookbooks/lamp/spec/spec_helper.rb
Normal file
2
cookbooks/lamp/spec/spec_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
require 'chefspec'
|
||||
require 'chefspec/berkshelf'
|
20
cookbooks/lamp/spec/unit/recipes/default_spec.rb
Normal file
20
cookbooks/lamp/spec/unit/recipes/default_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# Cookbook Name:: lamp
|
||||
# Spec:: default
|
||||
#
|
||||
# Copyright (c) 2016 The Authors, All Rights Reserved.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'lamp::default' do
|
||||
context 'When all attributes are default, on an unspecified platform' do
|
||||
let(:chef_run) do
|
||||
runner = ChefSpec::ServerRunner.new
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { chef_run }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
29
cookbooks/lamp/templates/default/apache-000_default.conf.erb
Normal file
29
cookbooks/lamp/templates/default/apache-000_default.conf.erb
Normal file
|
@ -0,0 +1,29 @@
|
|||
<VirtualHost *:80>
|
||||
ServerName localhost
|
||||
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /vagrant/www
|
||||
|
||||
<Directory /vagrant/www>
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
|
||||
# error, crit, alert, emerg.
|
||||
# It is also possible to configure the loglevel for particular
|
||||
# modules, e.g.
|
||||
#LogLevel info ssl:warn
|
||||
|
||||
ErrorLog /vagrant/apache/logs/error.log
|
||||
CustomLog /vagrant/apache/logs/access.log combined
|
||||
|
||||
# For most configuration files from conf-available/, which are
|
||||
# enabled or disabled at a global level, it is possible to
|
||||
# include a line for only one particular virtual host. For example the
|
||||
# following line enables the CGI configuration for this host only
|
||||
# after it has been globally disabled with "a2disconf".
|
||||
#Include conf-available/serve-cgi-bin.conf
|
||||
</VirtualHost>
|
||||
|
||||
IncludeOptional /vagrant/apache/conf/*.conf
|
129
cookbooks/lamp/templates/default/mysql-50-server.cnf
Normal file
129
cookbooks/lamp/templates/default/mysql-50-server.cnf
Normal file
|
@ -0,0 +1,129 @@
|
|||
#
|
||||
# These groups are read by MariaDB server.
|
||||
# Use it for options that only the server (but not clients) should see
|
||||
#
|
||||
# See the examples of server my.cnf files in /usr/share/mysql/
|
||||
#
|
||||
|
||||
# this is read by the standalone daemon and embedded servers
|
||||
[server]
|
||||
|
||||
# this is only for the mysqld standalone daemon
|
||||
[mysqld]
|
||||
|
||||
#
|
||||
# * Basic Settings
|
||||
#
|
||||
user = vagrant
|
||||
pid-file = /var/run/mysqld/mysqld.pid
|
||||
socket = /var/run/mysqld/mysqld.sock
|
||||
port = 3306
|
||||
basedir = /usr
|
||||
#datadir = /var/lib/mysql
|
||||
datadir = /vagrant/mysql/data
|
||||
tmpdir = /tmp
|
||||
lc-messages-dir = /usr/share/mysql
|
||||
skip-external-locking
|
||||
|
||||
# Instead of skip-networking the default is now to listen only on
|
||||
# localhost which is more compatible and is not less secure.
|
||||
bind-address = 0.0.0.0
|
||||
|
||||
#
|
||||
# * Fine Tuning
|
||||
#
|
||||
key_buffer_size = 16M
|
||||
max_allowed_packet = 16M
|
||||
thread_stack = 192K
|
||||
thread_cache_size = 8
|
||||
# This replaces the startup script and checks MyISAM tables if needed
|
||||
# the first time they are touched
|
||||
myisam-recover = BACKUP
|
||||
#max_connections = 100
|
||||
#table_cache = 64
|
||||
#thread_concurrency = 10
|
||||
|
||||
#
|
||||
# * Query Cache Configuration
|
||||
#
|
||||
query_cache_limit = 1M
|
||||
query_cache_size = 16M
|
||||
|
||||
#
|
||||
# * Logging and Replication
|
||||
#
|
||||
# Both location gets rotated by the cronjob.
|
||||
# Be aware that this log type is a performance killer.
|
||||
# As of 5.1 you can enable the log at runtime!
|
||||
#general_log_file = /var/log/mysql/mysql.log
|
||||
#general_log = 1
|
||||
#
|
||||
# Error log - should be very few entries.
|
||||
#
|
||||
log_error = /vagrant/mysql/logs/mysql_errors.log
|
||||
#
|
||||
# Enable the slow query log to see queries with especially long duration
|
||||
slow_query_log_file = /vagrant/mysql/logs/mysql_slow.log
|
||||
long_query_time = 10
|
||||
#log_slow_rate_limit = 1000
|
||||
#log_slow_verbosity = query_plan
|
||||
#log-queries-not-using-indexes
|
||||
#
|
||||
# The following can be used as easy to replay backup logs or for replication.
|
||||
# note: if you are setting up a replication slave, see README.Debian about
|
||||
# other settings you may need to change.
|
||||
#server-id = 1
|
||||
#log_bin = /var/log/mysql/mysql-bin.log
|
||||
expire_logs_days = 10
|
||||
max_binlog_size = 100M
|
||||
#binlog_do_db = include_database_name
|
||||
#binlog_ignore_db = include_database_name
|
||||
|
||||
#
|
||||
# * InnoDB
|
||||
#
|
||||
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
|
||||
# Read the manual for more InnoDB related options. There are many!
|
||||
|
||||
#
|
||||
# * Security Features
|
||||
#
|
||||
# Read the manual, too, if you want chroot!
|
||||
# chroot = /var/lib/mysql/
|
||||
#
|
||||
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
|
||||
#
|
||||
# ssl-ca=/etc/mysql/cacert.pem
|
||||
# ssl-cert=/etc/mysql/server-cert.pem
|
||||
# ssl-key=/etc/mysql/server-key.pem
|
||||
|
||||
#
|
||||
# * Character sets
|
||||
#
|
||||
# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
|
||||
# utf8 4-byte character set. See also client.cnf
|
||||
#
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_general_ci
|
||||
|
||||
#
|
||||
# * Unix socket authentication plugin is built-in since 10.0.22-6
|
||||
#
|
||||
# Needed so the root database user can authenticate without a password but
|
||||
# only when running as the unix root user.
|
||||
#
|
||||
# Also available for other users if required.
|
||||
# See https://mariadb.com/kb/en/unix_socket-authentication-plugin/
|
||||
|
||||
# this is only for embedded server
|
||||
[embedded]
|
||||
|
||||
# This group is only read by MariaDB servers, not by MySQL.
|
||||
# If you use the same .cnf file for MySQL and MariaDB,
|
||||
# you can put MariaDB-only options here
|
||||
[mariadb]
|
||||
|
||||
# This group is only read by MariaDB-10.0 servers.
|
||||
# If you use the same .cnf file for MariaDB of different versions,
|
||||
# use this group for options that older servers don't understand
|
||||
[mariadb-10.0]
|
193
cookbooks/lamp/templates/default/mysql-init-d
Normal file
193
cookbooks/lamp/templates/default/mysql-init-d
Normal file
|
@ -0,0 +1,193 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: mysql
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Should-Start: $network $named $time
|
||||
# Should-Stop: $network $named $time
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start and stop the mysql database server daemon
|
||||
# Description: Controls the main MariaDB database server daemon "mysqld"
|
||||
# and its wrapper script "mysqld_safe".
|
||||
### END INIT INFO
|
||||
#
|
||||
set -e
|
||||
set -u
|
||||
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
|
||||
|
||||
test -x /usr/sbin/mysqld || exit 0
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
|
||||
|
||||
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
|
||||
|
||||
# priority can be overriden and "-s" adds output to stderr
|
||||
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"
|
||||
|
||||
if [ -f /etc/default/mysql ]; then
|
||||
. /etc/default/mysql
|
||||
fi
|
||||
|
||||
# Safeguard (relative paths, core dumps..)
|
||||
cd /
|
||||
umask 077
|
||||
|
||||
# mysqladmin likes to read /root/.my.cnf. This is usually not what I want
|
||||
# as many admins e.g. only store a password without a username there and
|
||||
# so break my scripts.
|
||||
export HOME=/etc/mysql/
|
||||
|
||||
## Fetch a particular option from mysql's invocation.
|
||||
#
|
||||
# Usage: void mysqld_get_param option
|
||||
mysqld_get_param() {
|
||||
/usr/sbin/mysqld --print-defaults \
|
||||
| tr " " "\n" \
|
||||
| grep -- "--$1" \
|
||||
| tail -n 1 \
|
||||
| cut -d= -f2
|
||||
}
|
||||
|
||||
## Do some sanity checks before even trying to start mysqld.
|
||||
sanity_checks() {
|
||||
# check for config file
|
||||
if [ ! -r /etc/mysql/my.cnf ]; then
|
||||
log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz"
|
||||
echo "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER
|
||||
fi
|
||||
|
||||
# check for diskspace shortage
|
||||
datadir=`mysqld_get_param datadir`
|
||||
if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
|
||||
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
|
||||
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Checks if there is a server running and if so if it is accessible.
|
||||
#
|
||||
# check_alive insists on a pingable server
|
||||
# check_dead also fails if there is a lost mysqld in the process list
|
||||
#
|
||||
# Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn]
|
||||
mysqld_status () {
|
||||
ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? ))
|
||||
|
||||
ps_alive=0
|
||||
pidfile=`mysqld_get_param pid-file`
|
||||
if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi
|
||||
|
||||
if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
|
||||
[ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
|
||||
return 0 # EXIT_SUCCESS
|
||||
else
|
||||
if [ "$2" = "warn" ]; then
|
||||
echo -e "$ps_alive processes alive and '$MYADMIN ping' resulted in\n$ping_output\n" | $ERR_LOGGER -p daemon.debug
|
||||
fi
|
||||
return 1 # EXIT_FAILURE
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# main()
|
||||
#
|
||||
|
||||
case "${1:-''}" in
|
||||
|
||||
'start')
|
||||
sanity_checks;
|
||||
# Start daemon
|
||||
log_daemon_msg "Starting MariaDB database server" "mysqld"
|
||||
if mysqld_status check_alive nowarn; then
|
||||
log_progress_msg "already running"
|
||||
log_end_msg 0
|
||||
else
|
||||
# Could be removed during boot
|
||||
install -m 755 -o vagrant -g vagrant -d /var/run/mysqld
|
||||
|
||||
# Start MariaDB!
|
||||
/usr/bin/mysqld_safe "${@:2}" 2>&1 >/dev/null | $ERR_LOGGER &
|
||||
|
||||
for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}"); do
|
||||
sleep 1
|
||||
if mysqld_status check_alive nowarn ; then break; fi
|
||||
log_progress_msg "."
|
||||
done
|
||||
if mysqld_status check_alive warn; then
|
||||
log_end_msg 0
|
||||
# Now start mysqlcheck or whatever the admin wants.
|
||||
output=$(/etc/mysql/debian-start)
|
||||
if [ -n "$output" ]; then
|
||||
log_action_msg "$output"
|
||||
fi
|
||||
else
|
||||
log_end_msg 1
|
||||
log_failure_msg "Please take a look at the syslog"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
'stop')
|
||||
# * As a passwordless mysqladmin (e.g. via ~/.my.cnf) must be possible
|
||||
# at least for cron, we can rely on it here, too. (although we have
|
||||
# to specify it explicit as e.g. sudo environments points to the normal
|
||||
# users home and not /root)
|
||||
log_daemon_msg "Stopping MariaDB database server" "mysqld"
|
||||
if ! mysqld_status check_dead nowarn; then
|
||||
set +e
|
||||
shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
|
||||
set -e
|
||||
if [ "$r" -ne 0 ]; then
|
||||
log_end_msg 1
|
||||
[ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out"
|
||||
log_daemon_msg "Killing MariaDB database server by signal" "mysqld"
|
||||
killall -15 mysqld
|
||||
server_down=
|
||||
for i in `seq 1 600`; do
|
||||
sleep 1
|
||||
if mysqld_status check_dead nowarn; then server_down=1; break; fi
|
||||
done
|
||||
if test -z "$server_down"; then killall -9 mysqld; fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! mysqld_status check_dead warn; then
|
||||
log_end_msg 1
|
||||
log_failure_msg "Please stop MariaDB manually and read /usr/share/doc/mariadb-server-10.0/README.Debian.gz!"
|
||||
exit -1
|
||||
else
|
||||
log_end_msg 0
|
||||
fi
|
||||
;;
|
||||
|
||||
'restart')
|
||||
set +e; $SELF stop; set -e
|
||||
shift
|
||||
$SELF start "${@}"
|
||||
;;
|
||||
|
||||
'reload'|'force-reload')
|
||||
log_daemon_msg "Reloading MariaDB database server" "mysqld"
|
||||
$MYADMIN reload
|
||||
log_end_msg 0
|
||||
;;
|
||||
|
||||
'status')
|
||||
if mysqld_status check_alive nowarn; then
|
||||
log_action_msg "$($MYADMIN version)"
|
||||
else
|
||||
log_action_msg "MariaDB is stopped."
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
3
cookbooks/lamp/templates/default/ntpdate_cron
Normal file
3
cookbooks/lamp/templates/default/ntpdate_cron
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
ntpdate ntp.ubuntu.com
|
1872
cookbooks/lamp/templates/default/php.ini.erb
Normal file
1872
cookbooks/lamp/templates/default/php.ini.erb
Normal file
File diff suppressed because it is too large
Load diff
2
cookbooks/lamp/templates/default/users.conf
Normal file
2
cookbooks/lamp/templates/default/users.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
User vagrant
|
||||
Group vagrant
|
|
@ -0,0 +1,9 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'lamp::default' do
|
||||
# Serverspec examples can be found at
|
||||
# http://serverspec.org/resource_types.html
|
||||
it 'does something' do
|
||||
skip 'Replace this with meaningful tests'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
require 'serverspec'
|
||||
|
||||
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
|
||||
set :backend, :exec
|
||||
else
|
||||
set :backend, :cmd
|
||||
set :os, family: 'windows'
|
||||
end
|
290
create-vhost.sh
Executable file
290
create-vhost.sh
Executable file
|
@ -0,0 +1,290 @@
|
|||
#!/bin/bash
|
||||
|
||||
function error {
|
||||
echo "$(tput setaf 1) ! $1$(tput sgr 0)"
|
||||
}
|
||||
|
||||
function success {
|
||||
echo "$(tput setaf 2)$1$(tput sgr 0)"
|
||||
}
|
||||
|
||||
currentdir=`pwd`
|
||||
|
||||
echo
|
||||
echo "= APPLICATION CONFIGURATION ="
|
||||
echo
|
||||
|
||||
# Checking whether /etc/hosts file exists
|
||||
if [ ! -f "/etc/hosts" ]
|
||||
then
|
||||
error "Could not find the /etc/hosts file. I must abort..."
|
||||
exit 1
|
||||
else
|
||||
success "We have detected the following path for the Vagrant root:"
|
||||
success " > $currentdir"
|
||||
fi
|
||||
|
||||
|
||||
# Checking Vagrant root path
|
||||
echo
|
||||
while true
|
||||
do
|
||||
read -p "Is that correct? [Y/n] " correct
|
||||
|
||||
if [ "$correct" = "y" ] || [ -z "$correct" ]
|
||||
then
|
||||
correct="y"
|
||||
break
|
||||
elif [ "$correct" = "n" ]
|
||||
then
|
||||
break
|
||||
else
|
||||
error "You must answer the question using 'y' or 'n'"
|
||||
fi
|
||||
done
|
||||
|
||||
# Vagrant root path must be fixed
|
||||
if [ "$correct" = "n" ]
|
||||
then
|
||||
while true
|
||||
do
|
||||
read -p "Please enter the Vagrant root path: " vagrantroot
|
||||
|
||||
if [ -z "$vagrantroot" ]
|
||||
then
|
||||
error "Vagrant root cannot be empty"
|
||||
elif [ ! -d "$vagrantroot" ]
|
||||
then
|
||||
error "The Vagrant root '$vagrantroot' does not exist"
|
||||
elif [ ! -d "$vagrantroot/apache/conf" ]
|
||||
then
|
||||
error "Could not find the Apache conf directory in '$vagrantroot/apache/conf'"
|
||||
else
|
||||
success "Thank you!"
|
||||
break
|
||||
fi
|
||||
done
|
||||
elif [ "$correct" = "y" ] || [ -z "$correct" ]
|
||||
then
|
||||
success "Thank you!"
|
||||
vagrantroot=$currentdir
|
||||
else
|
||||
error "You must answer the question using 'y' or 'n'"
|
||||
fi
|
||||
|
||||
# Checking whether Vagrant machine is running
|
||||
echo
|
||||
echo "= CHECKING VAGRANT MACHINE STATUS ="
|
||||
cd $vagrantroot
|
||||
cmd=`vagrant status |grep "running" > /dev/null 2>&1`
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
error "The Vagrant machine does not seem to be in running state"
|
||||
|
||||
while true
|
||||
do
|
||||
read -p "Do you want to start the machine? This is mandatory in order to run this app [Y/n] " startmachine
|
||||
if [ -z "$startmachine" ]
|
||||
then
|
||||
startmachine="y"
|
||||
fi
|
||||
|
||||
if [ "$startmachine" != "y" ] && [ "$startmachine" != "n" ]
|
||||
then
|
||||
error "Please answer with 'y' or 'n'"
|
||||
else
|
||||
if [ "$startmachine" = "y" ]
|
||||
then
|
||||
success "Thank you! Now starting machine"
|
||||
vagrant up
|
||||
break
|
||||
else
|
||||
success "Thank you! Unfortunately, I must leave you now..."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
success "The Vagrant machine is running"
|
||||
fi
|
||||
|
||||
|
||||
# Getting the site hostname
|
||||
append=false
|
||||
echo
|
||||
while true
|
||||
do
|
||||
read -p "What is the hostname of the vhost you want to add? " hostname
|
||||
|
||||
if [ -z "$hostname" ]
|
||||
then
|
||||
error "The hostname cannot be empty, please retry..."
|
||||
elif [ -f "$vagrantroot/apache/conf/$hostname.conf" ]
|
||||
then
|
||||
error "The configuration file '$vagrantroot/apache/conf/$hostname.conf' already exists."
|
||||
echo
|
||||
echo "What should I do?"
|
||||
|
||||
PS3='Please enter your choice: '
|
||||
options=("Show" "Overwrite" "Append" "Abort")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"Abort")
|
||||
success "OK, bye!"
|
||||
exit 0
|
||||
;;
|
||||
"Show")
|
||||
success "Sure thing! Here is the content of the file:"
|
||||
echo
|
||||
cat $vagrantroot/apache/conf/$hostname.conf
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
error "Cannot get the configuration file content"
|
||||
fi
|
||||
echo
|
||||
;;
|
||||
"Overwrite")
|
||||
rm -f "$vagrantroot/apache/conf/$hostname.conf"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
error "Could not remove existing configuration file. You should do it manually..."
|
||||
else
|
||||
success "Existing configuration file was removed"
|
||||
fi
|
||||
echo
|
||||
break 2
|
||||
;;
|
||||
"Append")
|
||||
append="true"
|
||||
success "OK, the new configuration will be added to the existing file"
|
||||
echo
|
||||
break 2
|
||||
;;
|
||||
*) error "Please choose a valid option";;
|
||||
esac
|
||||
done
|
||||
else
|
||||
success "Thank you!"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Getting the site path
|
||||
echo
|
||||
while true
|
||||
do
|
||||
read -p "What is the path of the vhost you want to add? /vagrant/www/" path
|
||||
|
||||
if [ -z "$path" ]
|
||||
then
|
||||
error "The path cannot be empty, please retry..."
|
||||
else
|
||||
path="/vagrant/www/$path"
|
||||
vagrant ssh -c "ls $path" > /dev/null 2>&1
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
error "Directory '$path' does not exist on Vagrant"
|
||||
else
|
||||
success "Thank you!"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Getting vhost public document root path
|
||||
echo
|
||||
while true
|
||||
do
|
||||
read -p "What is the public document root path? $path/" public
|
||||
|
||||
if [ -z "$public" ]
|
||||
then
|
||||
public=$path
|
||||
success "Thank you!"
|
||||
break
|
||||
else
|
||||
public="$path/$public"
|
||||
vagrant ssh -c "ls $public" > /dev/null 2>&1
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
error "Directory '$public' does not exist on Vagrant"
|
||||
else
|
||||
success "Thank you!"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# All configuration done, executing...
|
||||
echo
|
||||
success "Thank you, everything is now fine. We are processing your request"
|
||||
echo
|
||||
|
||||
# Managing the /etc/hosts file
|
||||
echo "= ADDING HOSTNAME TO LOCAL HOSTS FILE ="
|
||||
test=`cat /etc/hosts |grep "$hostname"`
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "You will have to enter your password."
|
||||
sudo -- sh -c -e "echo '127.0.0.1 $hostname' >> /etc/hosts"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
error "Could not edit the '/etc/hosts' automatically"
|
||||
error "You should add the following line manually:"
|
||||
error " 127.0.0.1 $hostname"
|
||||
else
|
||||
success "Hostname successfully added to host's file"
|
||||
fi
|
||||
else
|
||||
success "The '$hostname' entry already exists in '/etc/hosts'"
|
||||
fi
|
||||
|
||||
# Managing the Apache configuration
|
||||
echo
|
||||
echo "= ADDING VHOST TO APACHE ="
|
||||
vhost="<VirtualHost *:80>
|
||||
ServerName $hostname
|
||||
DocumentRoot $public
|
||||
<Directory $path>
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
</VirtualHost>"
|
||||
|
||||
sudo -- sh -c -e "echo '$vhost' >> $vagrantroot/apache/conf/$hostname.conf"
|
||||
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
error "Could not create the '$vagrantroot/apache/conf/$hostname.conf' file automatically"
|
||||
error "You should create it with the following line manually:"
|
||||
error " 127.0.0.1 $hostname"
|
||||
else
|
||||
success "Hostname successfully added to host's file"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "= RELOADING APACHE CONFIGURATION ="
|
||||
vagrant ssh -c "sudo service apache2 reload" > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
error "Could not reload Apache's configuration automatically"
|
||||
error "You should reload it manually using the following command:"
|
||||
error " sudo service apache2 reload"
|
||||
else
|
||||
success "Apache successfully reloaded"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
success "END, thank you!"
|
||||
success "You may now access the vhost:"
|
||||
success "http://$hostname:8080/"
|
||||
echo
|
||||
|
206
www/index.php
Normal file
206
www/index.php
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
|
||||
include '_browser/functions.php';
|
||||
include '_browser/parser.php';
|
||||
|
||||
|
||||
$root = __DIR__;
|
||||
$parse = new Parsedown();
|
||||
|
||||
$ignore = array(
|
||||
$root.'/index.php',
|
||||
$root.'/404.html',
|
||||
$root.'/50x.html',
|
||||
$root.'/_browser'
|
||||
);
|
||||
|
||||
processpath($root);
|
||||
|
||||
if (empty($path)) {
|
||||
define('ROOT', true);
|
||||
}
|
||||
else {
|
||||
define('ROOT', false);
|
||||
}
|
||||
|
||||
$title = explode('/', $path);
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>localhost <?php echo implode(' › ', $title); ?></title>
|
||||
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://bootswatch.com/darkly/bootstrap.min.css" crossorigin="anonymous">
|
||||
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" crossorigin="anonymous"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.item.folder:hover:after {
|
||||
content: " »";
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body id="">
|
||||
<div class="container-fluid">
|
||||
<h1><a href="/">Local Development Environment</a></h1>
|
||||
<br />
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
|
||||
<?php if (isset($_GET['error']) && $_GET['error'] == 404): ?>
|
||||
<div class="alert alert-danger" role="alert"><strong>Oooops</strong> the page you requested does not exist. Because we hate white pages, here is the homepage instead...</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php $files = getglob($root.'/*'); ?>
|
||||
|
||||
<fieldset>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Listing documents</h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<?php if (!empty($path) && isset($files['index'])): ?>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<span class="glyphicon glyphicon-play"></span> We have found an "<?php echo $files['index']; ?>" file
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<a class="btn btn-primary btn-xs" href="<?php echo $path; ?>/<?php echo $files['index']; ?>">Run it !</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<br />
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="/">localhost</a></li>
|
||||
<?php $tmp = ''; ?>
|
||||
<?php foreach ($exp as $e): ?>
|
||||
<li><a href="/?p=<?php echo $tmp.$e; ?>"><?php echo $e; ?></a></li>
|
||||
<?php $tmp .= $e.'/'; ?>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
if (count($files) > 0) {
|
||||
echo '<table class="table table-bordered table-hover">';
|
||||
if (isset($files['folders'])) {
|
||||
//echo '<ul class="list-group">';
|
||||
echo '<tr><th>Name</th><th width="10%">Size</th><th width="20%">Modified</th></tr>';
|
||||
foreach ($files['folders'] as $f) {
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
<span class="glyphicon glyphicon-folder-open"></span>
|
||||
<a href="/?p='.$path.'/'.$f.'" class="item folder"><strong>'.$f.'</strong></a>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($files['files'])) {
|
||||
foreach ($files['files'] as $f) {
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
<span class="glyphicon glyphicon-file"></span>
|
||||
<a href="'.$path.'/'.$f.'" class="item file">'.$f.'</a>
|
||||
</td>
|
||||
<td>'.round(filesize(__DIR__.'/'.$path.'/'.$f) / 1000, 2).' ko</td>
|
||||
<td>'.date('D, M Y', filemtime(__DIR__.'/'.$path.'/'.$f)).'</td>
|
||||
</tr>
|
||||
';
|
||||
//echo '<li class="list-group-item"><span class="glyphicon glyphicon-file"></span> <a href="/?f='.$path.'/'.$f.'">'.$f.'</a></li>';
|
||||
}
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
else {
|
||||
if (file_exists($root)) {
|
||||
echo '<div class="alert alert-info" role="alert"><strong>Oooops</strong> This directory is empty...</div>';
|
||||
}
|
||||
else {
|
||||
echo '<div class="alert alert-danger" role="alert"><strong>Oooops</strong> This directory does not exist. Use the breadcrumb to navigate away...</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($files['readme'])): ?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Readme</h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body" style="font-size: 13px;">
|
||||
<?php echo $parse->text(file_get_contents($files['readme'])); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">PHP Informations <small> [ ☛ <a href="/_browser/php.php">Full</a> ]</small></h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body" style="max-height: 250px; overflow: auto;">
|
||||
<table class="table" style="font-size: 11px;">
|
||||
<tr style="font-size: 14px;background-color:#2c3e50;"><td width="30%">PHP Version</td><td><?php echo phpversion(); ?></td></tr>
|
||||
<tr><td width="30%">Loaded INI file</td><td><?php echo php_ini_loaded_file(); ?></td></tr>
|
||||
<tr><td width="30%">Additional INI files</td><td><?php echo php_ini_scanned_files(); ?></td></tr>
|
||||
<tr><td width="30%">PHP API type</td><td><?php echo php_sapi_name(); ?></td></tr>
|
||||
<tr style="font-size:14px;background-color:#2c3e50;"><td colspan="2">Modules</td></tr>
|
||||
<?php $extensions = get_loaded_extensions(); ?>
|
||||
<?php foreach ($extensions as $e): ?>
|
||||
<tr><td width="30%">» <?php echo $e; ?></td><td><?php echo cut(phpversion($e), 35); ?></td></tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Server Informations</h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body" style="max-height: 250px; overflow: auto;">
|
||||
<table class="table"style="font-size: 11px;">
|
||||
<?php foreach ($_SERVER as $k => $v): ?>
|
||||
<tr><td width="30%"> » <?php echo $k; ?></td><td><?php echo cut($v, 35); ?></td></tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</body>
|
||||
</html>
|
||||
|
92
www/mail.php
Normal file
92
www/mail.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
|
||||
if (isset($_POST['to'])) {
|
||||
|
||||
$to = isset($_POST['to']) && !empty($_POST['to']) ? $_POST['to'] : 'noreply@wcie.fr';
|
||||
$from = isset($_POST['from']) && !empty($_POST['from']) ? $_POST['from'] : 'a.devignon@wcie.fr';
|
||||
$subject = isset($_POST['subject']) && !empty($_POST['subject']) ? $_POST['subject'] : 'Test subject';
|
||||
$message = isset($_POST['message']) && !empty($_POST['message']) ? $_POST['message'] : 'This is a test message';
|
||||
|
||||
$headers = 'MIME-Version: 1.0' . "\r\n";
|
||||
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
|
||||
$headers .= 'From: ' . $from . "\r\n" .
|
||||
'Reply-To: ' . $from . "\r\n" .
|
||||
'X-Mailer: PHP/' . phpversion();
|
||||
|
||||
|
||||
|
||||
$result = mail($to, $subject, $message, $headers);
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://bootswatch.com/darkly/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="http://summernote.org/bower_components/summernote/dist/summernote.css" />
|
||||
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
||||
<script src="http://summernote.org/bower_components/summernote/dist/summernote.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="page-header">
|
||||
<h1>Email Sending Form.<br><small>Cought by MailCatcher</small></h1>
|
||||
</div>
|
||||
|
||||
<?php if(isset($result)): ?>
|
||||
<?php if ($result === true): ?>
|
||||
<div class="alert alert-success" role="alert">Your email was properly sent. See : <a href="http://127.0.0.1:1080">here</a></div>
|
||||
<?php else: ?>
|
||||
<div class="alert alert-danger" role="alert">Unable to send your email.</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="mail.php" method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label>From:</label>
|
||||
<input type="email" class="form-control" name="from" value placeholder="noreply@wcie.fr" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>To:</label>
|
||||
<input type="email" class="form-control" name="to" value placeholder="a.devignon@wcie.fr" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Subject:</label>
|
||||
<input type="text" class="form-control" name="subject" value placeholder="The latest annual report" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Message:</label>
|
||||
<textarea name="message" class="form-control editor"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('.editor').summernote({
|
||||
airMode: false
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in a new issue