Skip to content

Instantly share code, notes, and snippets.

@ciscoheat
Last active May 21, 2016 01:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciscoheat/d57f4d1788476fbe9493 to your computer and use it in GitHub Desktop.
Save ciscoheat/d57f4d1788476fbe9493 to your computer and use it in GitHub Desktop.
Vagrant setup for c5
#!/usr/bin/env bash
# Use a Vagrantfile based on hashicorp/precise64
cd /vagrant
mkdir www
chown vagrant:vagrant www
echo "=== Installing Apache..."
apt-get update >/dev/null 2>&1
apt-get install -y apache2
# Enable mod_rewrite, allow .htaccess and fix a virtualbox bug according to
# https://github.com/mitchellh/vagrant/issues/351#issuecomment-1339640
a2enmod rewrite
sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/sites-enabled/000-default
echo EnableSendFile Off > /etc/apache2/conf.d/virtualbox_bugfix
# Link to www dir
rm -rf /var/www
ln -fs /vagrant/www /var/www
echo "=== Installing curl..."
apt-get install -y curl
echo "=== Installing PHP..."
apt-get install -y php5 php5-gd php5-mysql php5-curl
echo "=== Installing PHP utilities (Composer)..."
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin
echo "=== Installing PHP utilities (phing)..."
wget -q -O /usr/local/bin/phing.phar http://www.phing.info/get/phing-latest.phar && chmod 755 /usr/local/bin/phing.phar
echo "=== Installing Mysql..."
export DEBIAN_FRONTEND=noninteractive
apt-get -q -y install mysql-server mysql-client
echo "=== Creating Mysql DB for concrete5..."
mysql -u root -e "create database c5"
echo "=== Restarting Apache..."
service apache2 restart
if [ ! -f concrete5.* ]; then
echo "=== Downloading concrete5..."
wget -q -O concrete5.latest.zip http://www.concrete5.org/download_file/-/view/66159/8497/
fi
echo "=== Unzipping concrete5..."
apt-get -y install unzip
# Become vagrant user to set file ownership correctly:
su vagrant -c 'unzip -q concrete5.*'
mv -n concrete5.*/* www
rm -rf concrete5.*/*
rmdir concrete5.*
echo "=== Installing concrete5..."
wget -q --no-check-certificate https://raw.githubusercontent.com/concrete5/concrete5/master/cli/install-concrete5.php
chmod 755 ./install-concrete5.php
./install-concrete5.php --db-server=localhost --db-username=root --db-database=c5 \
--admin-password=admin --admin-email=admin@example.com \
--starting-point=standard --target=./www
rm ./install-concrete5.php
# Enable pretty URL:s in the DB
mysql -u root -e "use c5; INSERT INTO Config (cfKey, timestamp, cfValue) VALUES ('URL_REWRITING', NOW(), 1)"
# Write a .htaccess file for pretty URL:s
cat > ./www/.htaccess <<EOL
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
EOL
echo "=== Done!"
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "hashicorp/precise64"
# 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.
config.vm.network "forwarded_port", guest: 80, host: 4567
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# 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"
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
# 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 "./www", "/var/www"
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 512] # Set memory to 512MB
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] # Use NAT DNS host resolver
end
config.vm.provision :shell, path: "provision.sh"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment