Last active
July 23, 2018 09:07
-
-
Save aurmil/3c2516be8cfb7d7913ae to your computer and use it in GitHub Desktop.
Vagrant box based on Debian 8 with Apache 2.4 + mod_rewrite ; PHP 5.6 + composer ; MySQL 5.5 ; git, node, npm, bower, yarn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# author Aurélien Millet | |
# license MIT | |
# configuration | |
time_zone = "Europe/Paris" | |
Vagrant.configure("2") do |config| | |
config.vm.box = "debian/jessie64" | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.ssh.forward_agent = true | |
config.vm.synced_folder ".", "/vagrant", type: "virtualbox", | |
owner: "www-data", group: "www-data" | |
config.vm.provider "virtualbox" do |vb| | |
vb.name = "vagrant_debian8" | |
vb.memory = 1024 | |
vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000] | |
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | |
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] | |
end | |
config.vm.provision "shell" do |s| | |
s.args = [time_zone] | |
s.inline = <<-SHELL | |
# configuration | |
TIME_ZONE=$1 | |
# disable queries for user manual interactions | |
export DEBIAN_FRONTEND=noninteractive | |
# update time zone | |
echo "$TIME_ZONE" > /etc/timezone | |
dpkg-reconfigure -f noninteractive tzdata | |
# update packages | |
apt-get update -q | |
# install Vim and Git | |
apt-get install -q -y vim git | |
# install Apache, PHP and MySQL | |
apt-get install -q -y apache2 apache2.2-common | |
apt-get install -q -y php5 libapache2-mod-php5 | |
apt-get install -q -y php5-curl php5-gd php5-mcrypt php5-mysqlnd php-soap php5-xdebug | |
apt-get install -q -y mysql-server-5.5 | |
a2enmod rewrite headers | |
service apache2 restart | |
# set Vagrant folder as Apache root folder and go to it | |
dir='/vagrant/www' | |
if [ ! -d "$dir" ]; then | |
mkdir "$dir" | |
fi | |
if [ ! -L /var/www/html ]; then | |
rm -rf /var/www/html | |
ln -fs "$dir" /var/www/html | |
fi | |
cd "$dir" | |
# vhost | |
file='/etc/apache2/sites-available/dev.conf' | |
if [ ! -f "$file" ]; then | |
SITE_CONF=$(cat <<EOF | |
<Directory /var/www/html> | |
AllowOverride All | |
Options +Indexes -MultiViews +FollowSymLinks | |
AddDefaultCharset utf-8 | |
SetEnv ENVIRONMENT "development" | |
php_flag display_errors On | |
EnableSendfile Off | |
</Directory> | |
EOF | |
) | |
echo "$SITE_CONF" > "$file" | |
fi | |
a2ensite dev | |
service apache2 reload | |
# Composer | |
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)" | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")" | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then | |
>&2 echo 'ERROR: Invalid installer signature (Composer)' | |
rm composer-setup.php | |
else | |
php composer-setup.php --quiet | |
rm composer-setup.php | |
mv composer.phar /usr/local/bin/composer | |
chmod +x /usr/local/bin/composer | |
sudo -H -u vagrant bash -c 'composer global require hirak/prestissimo' | |
fi | |
# phpinfo script | |
file='phpinfo.php' | |
if [ ! -f "$file" ]; then | |
echo '<?php phpinfo();' > "$file" | |
fi | |
# OPcache gui script | |
file='opcache.php' | |
if [ ! -f "$file" ]; then | |
wget -nv -O "$file" https://raw.githubusercontent.com/amnuts/opcache-gui/master/index.php | |
fi | |
# Adminer script | |
file='adminer.php' | |
if [ ! -f "$file" ]; then | |
wget -nv -O "$file" http://www.adminer.org/latest.php | |
wget -nv https://raw.githubusercontent.com/vrana/adminer/master/designs/pepa-linha/adminer.css | |
fi | |
# node, npm, bower, yarn | |
apt-get install curl | |
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | |
apt-get install -y nodejs | |
npm install -g bower | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
sudo apt-get update && sudo apt-get install yarn | |
SHELL | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment