Skip to content

Instantly share code, notes, and snippets.

@becw
Last active December 16, 2015 07:18
Show Gist options
  • Save becw/5397477 to your computer and use it in GitHub Desktop.
Save becw/5397477 to your computer and use it in GitHub Desktop.
LAMP server using Vagrant. This is a work in progress.
#!/usr/bin/env bash
# Update packages
apt-get -yq update
# Set up LAMP stack
# Install mysql
debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password root'
debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password root'
apt-get -yq install mysql-server-5.5
# Delete the anonymous mysql user and the test database; add test@localhost.
mysql -u root -proot -e "DROP USER ''@'localhost'; DROP USER ''@'precise32'; DROP DATABASE test; CREATE USER 'test'@'localhost' IDENTIFIED BY 'test'; GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';"
echo "[mysqld]" > /etc/mysql/conf.d/charset.cnf
echo "character-set-server = utf8" >> /etc/mysql/conf.d/charset.cnf
# Install the PHP; the php5 package installs Apache 2.2
apt-get -yq install php5 php5-gd php5-memcache php5-xdebug
# Use the vagrant directory as the web root
rm -rf /var/www
ln -fs /vagrant/www /var/www
# Add PPA to get a more recent version of git ??
#apt-get -yq install python-software-properties
#add-apt-repository ppa:git-core/ppa
#apt-get -yq update
# Set up development tools
apt-get -yq install curl git php-pear
# Install Drush
pear channel-discover pear.drush.org
pear install --alldeps drush/drush
# Un-declared drush dependency
pear install Console_Table
# Install PHPUnit
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony.com
pear install --alldeps phpunit/PHPUnit
# Install Composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin
ln /usr/local/bin/composer.phar /usr/local/bin/composer
# @todo Configure XDebug
# http://pietervogelaar.nl/php-xdebug-netbeans-vagrant/
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.provision :shell, :path => "vagrant-setup.sh"
config.vm.network :forwarded_port, guest: 80, host: 8080
#config.vm.network :private_network, ip: "192.168.3.141"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment