Skip to content

Instantly share code, notes, and snippets.

@chssweb
Last active September 5, 2016 07:51
Show Gist options
  • Save chssweb/1dac9b42be3887deba64918ae5215de0 to your computer and use it in GitHub Desktop.
Save chssweb/1dac9b42be3887deba64918ae5215de0 to your computer and use it in GitHub Desktop.
Puphpet setup

#PUPHPET VM

Ok - this seems like a pretty good setup so far. It properly handles permissions, and allows for extra vhosts. Samba is setup on this - \\UBUNTUOS in explorer to get access

  • Save the config.yaml to local machine - then drag it onto the PUPHPET site https://puphpet.com/ and download the archive
  • Put all the bash script APART FROM 'samba-start.sh' & 'add-vagrant-pw.sh' into the puphpet/files/exec_once folder.
  • Put 'samba-start.sh' into the 'start_once' folder
  • Put 'add-vagrant-pw.sh' into 'start-always'
  • Make sure vagrant is up to date at https://www.vagrantup.com/downloads.html
  • Make sure you default location for VirtualBoxes VM machines is set 1) your local machine and 2) a drive with enough space
  • 'vagrant up' - you should see an elephant in 10minutes or so if all went well :)
  • If you want solr simply modify the config yaml to "install: '1'" before the first time your 'up' the machine, or 'vagrant provision' if already running
  • Add vm.dev to your hosts file on the host machine. Alternatively use IP addresses and change the port from 80 to 8080 in the yaml

Links

{IP} - default vhost

{IP}/adminer - alt to phpmyadmin (find a good css file to run with it as it looks awful out the box)

{IP}:8080 - vhost called vagrant. This is the 'real' development vhost

{IP}:8025 - Mailhog - where all those emails will go from apps on the VM

{IP}:8984 - SOLR

Tips

SOLR: if you add solr after the first build my script to create the cores will not fire. NP - just vagrant ssh into the VM and run this command

 /opt/solr/solr-5.4.1/bin/solr create -c new_core

Rename 'new_core' if that isn't to your taste ;)

##TODOs

  • chown vagrant:www-data /var/www -R (before chown'ing the vhost folder)
  • If you prefer to acccess the site via the IP then you have to use another port as PUPHPUT hard codes the default site to port 80. Ok, but a bit of a pain. Alternatively we could turn this of in the yaml file - 'default_vhost: false', and then maybe create a vhost using the same directories as the default vhost, but making this use 8080, allowing the development vhost to use port 80.
#!/bin/bash
#
echo 'vagrant:vagrant' | chpasswd
vagrantfile:
target: local
vm:
provider:
local:
box: puphpet/ubuntu1404-x64
box_url: puphpet/ubuntu1404-x64
box_version: '0'
chosen_virtualizer: virtualbox
virtualizers:
virtualbox:
modifyvm:
natdnshostresolver1: false
showgui: 0
vmware:
numvcpus: 1
parallels:
use_linked_clone: 0
check_guest_tools: 0
update_guest_tools: 0
machines:
vflm_oyqn0nq1lviz:
id: ubuntuos
hostname: ubuntuos.vm
network:
private_network: 192.168.56.101
forwarded_port:
vflmnfp_shlxgsdmpa5k:
host: '5305'
guest: '22'
memory: '512'
cpus: '1'
provision:
puppet:
manifests_path: puphpet/puppet/manifests
module_path: puphpet/puppet/modules
options:
- '--verbose'
- '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
synced_folder: { }
usable_port_range:
start: 10200
stop: 10500
post_up_message: ''
ssh:
host: 'false'
port: 'false'
private_key_path: 'false'
username: vagrant
guest_port: 'false'
keep_alive: '1'
forward_agent: 'false'
forward_x11: 'false'
shell: 'bash -l'
insert_key: 'false'
vagrant:
host: detect
proxy:
http: ''
https: ''
ftp: ''
no_proxy: ''
server:
install: '1'
packages:
- vim
- tig
- samba
users_groups:
install: '1'
groups: { }
users: { }
locale:
install: '1'
settings:
default_locale: en_GB.UTF-8
locales:
- en_GB.UTF-8
timezone: Europe/London
firewall:
install: '1'
rules:
fr_atcx82tkg7d4:
port:
- '137'
- '138'
priority: '100'
proto: udp
action: accept
fr_v3wy9vogastu:
port:
- '139'
- '445'
- '10000'
priority: '100'
proto: tcp
action: accept
cron:
install: '1'
jobs: { }
nginx:
install: '0'
settings:
default_vhost: 1
proxy_buffer_size: 128k
proxy_buffers: '4 256k'
proxy_connect_timeout: 600s
proxy_send_timeout: 600s
proxy_read_timeout: 600s
names_hash_bucket_size: 128
upstreams: { }
vhosts:
nxv_krzmrtr1zahs:
server_name: awesome.dev
server_aliases:
- www.awesome.dev
www_root: /var/www/awesome
listen_port: '80'
index_files:
- index.html
- index.htm
- index.php
client_max_body_size: 1m
ssl: '0'
ssl_cert: ''
ssl_key: ''
ssl_port: '443'
ssl_protocols: ''
ssl_ciphers: ''
rewrite_to_https: '1'
spdy: '1'
locations:
nxvl_uuq8pq58dz7u:
location: /
try_files:
- $uri
- $uri/
- /index.php$is_args$args
fastcgi: ''
fastcgi_index: ''
fastcgi_split_path: ''
proxy: ''
proxy_redirect: ''
nxvl_qxoni91s3gzw:
location: '~ \.php$'
try_files:
- $uri
- $uri/
- /index.php$is_args$args
fastcgi: '127.0.0.1:9000'
fastcgi_index: index.php
fastcgi_split_path: '^(.+\.php)(/.*)$'
fast_cgi_params_extra:
- 'SCRIPT_FILENAME $request_filename'
- 'APP_ENV dev'
set:
- '$path_info $fastcgi_path_info'
proxy: ''
proxy_redirect: ''
proxies: { }
apache:
install: '1'
settings:
version: 2.4
user: www-data
group: www-data
default_vhost: true
manage_user: false
manage_group: false
sendfile: 0
modules:
- proxy_fcgi
- rewrite
vhosts:
av_x6cx0enu8bkn:
servername: vagrant.dev
serveraliases:
- vm.dev
docroot: /var/www/vhosts/vagrant/public_html
port: '80'
setenv:
- 'APP_ENV dev'
setenvif:
- 'Authorization "(.*)" HTTP_AUTHORIZATION=$1'
custom_fragment: ''
ssl: '0'
ssl_cert: ''
ssl_key: ''
ssl_chain: ''
ssl_certs_dir: ''
ssl_protocol: ''
ssl_cipher: ''
directories:
avd_zfky0j8syh50:
path: /var/www/vhosts/vagrant/public_html
options:
- Indexes
- FollowSymlinks
- MultiViews
- ExecCGI
allow_override:
- All
require:
- 'all granted'
custom_fragment: ''
files_match:
avdfm_0ogp1ugln46k:
path: \.php$
sethandler: 'proxy:fcgi://127.0.0.1:9001'
custom_fragment: ''
provider: filesmatch
provider: directory
letsencrypt:
install: '1'
settings:
email: ''
domains: { }
php:
install: '1'
settings:
version: '56'
modules:
php:
- cli
- intl
- ldap
- mbstring
- xml
- mcrypt
- zip
pear: { }
pecl: { }
ini:
display_errors: 'On'
error_reporting: '-1'
session.save_path: /var/lib/php/session
date.timezone: Europe/London
post_max_size: 50M
upload_max_filesize: 50M
fpm_ini:
error_log: /var/log/php-fpm.log
fpm_pools:
phpfp_n95bhq2d537j:
ini:
prefix: www
listen: '127.0.0.1:9000'
security.limit_extensions: .php
user: vagrant
group: www-data
phpfp_s1oykwzq24dv:
ini:
prefix: vagrant
listen: '127.0.0.1:9001'
security.limit_extensions: .php
user: vagrant
group: vagrant
pm: dynamic
pm.max_children: '5'
pm.start_servers: '2'
pm.min_spare_servers: '1'
pm.max_spare_servers: '3'
composer: '1'
composer_home: ''
xdebug:
install: '0'
settings:
xdebug.default_enable: '1'
xdebug.remote_autostart: '0'
xdebug.remote_connect_back: '1'
xdebug.remote_enable: '1'
xdebug.remote_handler: dbgp
xdebug.remote_port: '9000'
blackfire:
install: '0'
settings:
server_id: ''
server_token: ''
agent:
http_proxy: ''
https_proxy: ''
log_file: stderr
log_level: '1'
php:
agent_timeout: '0.25'
log_file: ''
log_level: '1'
xhprof:
install: '0'
wpcli:
install: '1'
version: v0.23.1
drush:
install: '1'
version: 8.1.3
ruby:
install: '1'
versions:
rv_1nt6v4e0yxof:
default: '1'
bundler: '1'
version: 2.3.1
gems:
- deep_merge
- activesupport
- vine
python:
install: '1'
packages: { }
versions: { }
nodejs:
install: '1'
settings:
version: '6'
npm_packages:
- bower
- gulp
- grunt
hhvm:
install: '0'
nightly: 0
composer: '1'
composer_home: ''
settings: { }
server_ini:
hhvm.server.host: 127.0.0.1
hhvm.server.port: '9000'
hhvm.log.use_log_file: '1'
hhvm.log.file: /var/log/hhvm/error.log
php_ini:
display_errors: 'On'
error_reporting: '-1'
date.timezone: UTC
mariadb:
install: '0'
settings:
version: '10.1'
root_password: '123'
override_options: { }
adminer: 0
users:
mariadbnu_7r1mzfshzefe:
name: dbuser
password: '123'
databases:
mariadbnd_xfi0y56v04ch:
name: dbname
sql: ''
grants:
mariadbng_razxiyfzizs4:
user: dbuser
table: '*.*'
privileges:
- ALL
mysql:
install: '1'
settings:
version: '5.6'
root_password: '123'
override_options: { }
adminer: 1
users:
mysqlnu_astkl4zc6yb8:
name: dbuser
password: '123'
databases:
mysqlnd_zmlje494znv0:
name: db01
sql: ''
grants:
mysqlng_61nmz48iq21t:
user: dbuser
table: '*.*'
privileges:
- ALL
postgresql:
install: '0'
settings:
global:
encoding: UTF8
version: '9.4'
server:
postgres_password: '123'
databases: { }
users: { }
grants: { }
adminer: 0
mongodb:
install: '0'
settings:
bind_ip: 127.0.0.1
port: '27017'
globals:
version: 2.6.0
databases: { }
redis:
install: '0'
settings:
port: '6379'
sqlite:
install: '1'
adminer: 0
databases: { }
mailhog:
install: '1'
settings:
smtp_ip: 0.0.0.0
smtp_port: 1025
http_ip: 0.0.0.0
http_port: '8025'
path: /usr/local/bin/mailhog
beanstalkd:
install: '0'
settings:
listenaddress: 0.0.0.0
listenport: '11300'
maxjobsize: '65535'
maxconnections: '1024'
binlogdir: /var/lib/beanstalkd/binlog
binlogfsync: null
binlogsize: '10485760'
beanstalk_console: 0
rabbitmq:
install: '0'
settings:
port: '5672'
users: { }
vhosts: { }
plugins: { }
elastic_search:
install: '0'
settings:
version: 2.3.1
java_install: true
instances:
esi_5xrf2a7ehq1p:
name: es-01
solr:
settings:
version: 5.4.1
port: '8984'

Note: Adminer is installed in this setup. If that, or Heidi or equivalent, does what you need then don't go any further.

** THIS IS A WORK IN PROGRESS - Not everything will work as expected **

The official Ubuntu repo install seems to break the apache setup. Fixable if you turn of the apache workflow module and turn on mpm-prefork, but not worth the hassle. And the git way is pretty easy.

Install

First two steps really should be done in the scripts as useful in the long run:

  • sudo chown vagrant:www-data -R /var/www/html
  • sudo chmod 2755 /var/www/html -R (the 2 is sticky bit that forces any file to now be owned by vagrant and group www-data - might be terrible idea ;) )
  1. cd /var/www/html
  2. git clone --depth=1 --branch=STABLE git://github.com/phpmyadmin/phpmyadmin.git
  3. cd phpmyadmin
  4. nano/vim config.inc.php
  5. Copy the code below and save
  6. You can modify this in http://your-ip/phpmyadmin/setup in the future by creating a folder config and copying the config.inc.php into this
<?php
/*
 * Generated configuration file
 * Generated by: phpMyAdmin 4.6.4 setup script
 * Date: Fri, 02 Sep 2016 16:36:32 +0100
 */

/* Servers configuration */
$i = 0;

/* Server: VM [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'VM';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['nopassword'] = true;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '123';

/* End of servers configuration */

$cfg['blowfish_secret'] = '_e&-2pHK]zPS<RDaah2hnwv/39N{&m^U';
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>
#!/bin/bash
#
VAGRANT_CORE_FOLDER=$(cat '/.puphpet-stuff/vagrant-core-folder.txt')
OS=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" ID)
RELEASE=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" RELEASE)
CODENAME=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" CODENAME)
echo 'Adding user password'
if [ "${OS}" == 'debian' ] || [ "${OS}" == 'ubuntu' ]; then
echo vagrant:vagrant | chpasswd
elif [[ "${OS}" == 'centos' ]]; then
echo vagrant | passwd vagrant --stdin
fi
if ! grep -R "\[root\]" "/etc/samba/smb.conf"; then
echo 'Adding Samba config'
printf "\n[root]\n force user = root\n force group = root\n comment = Samba share\n read only = no\n browseable = yes\n writable = yes\n delete readonly = yes\n public = yes\n guest ok = yes\n create mode = 664\n directory mask = 0775\n path = /" >> /etc/samba/smb.conf
fi
if ! grep -R "\[www\]" "/etc/samba/smb.conf"; then
echo 'Adding Samba config'
printf "\n[www]\n force user = www-data\n force group = www-data\n comment = Samba share\n read only = no\n browseable = yes\n writable = yes\n delete readonly = yes\n public = yes\n guest ok = yes\n create mode = 664\n directory mask = 0775\n path = /var/www" >> /etc/samba/smb.conf
fi
if ! grep -R "\[vagrant\]" "/etc/samba/smb.conf"; then
echo 'Adding Samba config'
printf "\n[vhosts]\n force user = vagrant\n force group = vagrant\n comment = Samba share\n read only = no\n browseable = yes\n writable = yes\n delete readonly = yes\n public = yes\n guest ok = yes\n create mode = 664\n directory mask = 0775\n path = /var/www/vhosts" >> /etc/samba/smb.conf
fi
echo 'Adding Samba user/password'
(echo "vagrant"; echo "vagrant") | smbpasswd -s -a vagrant
echo 'Setting share directory permissions'
chown vagrant:vagrant /var/www/vhosts -R
#!/bin/bash
#
VAGRANT_CORE_FOLDER=$(cat '/.puphpet-stuff/vagrant-core-folder.txt')
OS=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" ID)
RELEASE=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" RELEASE)
CODENAME=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" CODENAME)
echo 'Restarting Samba'
if [ "${OS}" == 'debian' ] || [ "${OS}" == 'ubuntu' ]; then
service smbd restart
elif [[ "${OS}" == 'centos' ]]; then
/sbin/service smb restart
fi
#!/bin/bash
#
if [ -d "/opt/solr/solr-5.4.1/bin" ]; then
echo 'Creating new cores in SOLR'
/opt/solr/solr-5.4.1/bin/solr create -c new_core
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment