Skip to content

Instantly share code, notes, and snippets.

@rizkysyazuli
Forked from alettieri/Vagrantfile
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rizkysyazuli/4b7e025a997da72b25c9 to your computer and use it in GitHub Desktop.
Save rizkysyazuli/4b7e025a997da72b25c9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
printf "\nCopying default.vhost file to /etc/apache2/sites-available/default\n"
cp /vagrant/default.vhost /etc/apache2/sites-available/default
printf "\nReloading apache\n"
service apache2 reload
#!/usr/bin/env bash
# Compass project path
scss_path=/vagrant/application/wp-content/themes/theme_name/assets/compass_dir
# First compile the project, so that we get style.css
printf "Compiling Project\n"
compass compile $scss_path
# Now, watch the project for changes
compass watch $scss_path > /dev/null 2>/dev/null &
cid=$! > ./cwatch.pid
printf "Compass is watcing your project - PID: $cid\n"
printf "\n\nDevelopment environment is up and running."
printf "\nOpen the following url in your browser: http://192.168.33.10 (Cmd + Click)"
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName local.websitename.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
#!/usr/bin/env bash
# Determine if this machine has already been provisioned
# Basically, run everything after this command once, and only once
if [ -f "/var/vagrant_provision" ]; then
exit 0
fi
function say {
printf "\n--------------------------------------------------------\n"
printf "\t$1"
printf "\n--------------------------------------------------------\n"
}
db='databasename'
# Install Apache
say "Installing Apache and setting it up."
# Update aptitude library
apt-get update >/dev/null 2>&1
# Install apache2
apt-get install -y apache2 >/dev/null 2>&1
# Remove /var/www path
rm -rf /var/www
# Symbolic link to /vagrant/site path
ln -fs /vagrant/application /var/www
# Enable mod_rewrite
a2enmod rewrite
# Install mysql
say "Installing MySQL."
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y mysql-server >/dev/null 2>&1
sed -i -e 's/127.0.0.1/0.0.0.0/' /etc/mysql/my.cnf
restart mysql
mysql -u root mysql <<< "GRANT ALL ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;"
say "Installing handy packages"
apt-get install -y curl git-core ftp unzip imagemagick vim colordiff gettext graphviz >/dev/null 2>&1
say "Creating the database '$db'"
mysql -u root -e "create database $db"
#
# There is a shared 'sql' directory that contained a .sql (database dump) file.
# This directory is part of the project path, shared with vagrant under the /vagrant path.
# We are populating the msyql database with that file. In this example it's called databasename.sql
#
say "Populating Database"
mysql -u root -D $db < /vagrant/sql/$db.sql
say "Installing PHP Modules"
# Install php5, libapache2-mod-php5, php5-mysql curl php5-curl
apt-get install -y php5 php5-cli php5-common php5-dev php5-imagick php5-imap php5-gd libapache2-mod-php5 php5-mysql php5-curl >/dev/null 2>&1
# Restart Apache
say "Restarting Apache"
service apache2 restart
# Installing Ruby
say "Installing rvm - preparing for ruby and compass"
curl -L https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm requirements
say "Installing ruby now... wish me luck"
rvm install ruby
rvm use ruby --default
rvm rubygems current
say "Installing SASS + COMPASS"
gem install sass
gem install compass
say "Installing WordPress Cli"
curl https://raw.github.com/wp-cli/wp-cli.github.com/master/installer.sh | bash
# Let this script know not to run again
touch /var/vagrant_provision
# -*- 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 = "lucid32"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
# 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"
#Provision script - run once
config.vm.provision "shell", path: "provision.sh"
# Copy the vhost file to default and reload apache - run every vagrant up
config.vm.provision "shell", path: "apache.sh"
# Compass watch - don't run as sudo
config.vm.provision "shell", path: 'compass.sh', privileged: false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment