Skip to content

Instantly share code, notes, and snippets.

@annalinneajohansson
Created May 25, 2016 13:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save annalinneajohansson/de9861f8b165c66d5d5a269226611dc2 to your computer and use it in GitHub Desktop.
Save annalinneajohansson/de9861f8b165c66d5d5a269226611dc2 to your computer and use it in GitHub Desktop.
Basic LAMP Vagrant provision script for Ubuntu servers
#!/usr/bin/env bash
# update / upgrade
sudo apt-get update > /dev/null 2>&1
sudo apt-get -y upgrade > /dev/null 2>&1
# Install Apache and PHP
sudo apt-get install -y apache2 php5 php5-curl > /dev/null 2>&1
# install mysql and give password to installer
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root"
sudo apt-get -y install mysql-server php5-mysql php5-mcrypt > /dev/null 2>&1
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available > /dev/null 2>&1
sudo php5enmod mcrypt
# restart apache
sudo service apache2 restart
# install phpmyadmin and give password(s) to installer
# for simplicity I'm using the same password for mysql and phpmyadmin
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true"
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password root"
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password root"
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password root"
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2"
sudo apt-get -y install phpmyadmin
# setup hosts file
VHOST=$(cat <<EOF
<VirtualHost *:80>
DocumentRoot "/vagrant"
<Directory "/vagrant">
AllowOverride All
Require all granted
</Directory>
ErrorLog /vagrant/error.log
</VirtualHost>
EOF
)
# Ubuntu version
echo "${VHOST}" > /etc/apache2/sites-available/000-default.conf
# Debian version
# echo "${VHOST}" > /etc/apache2/sites-available/default
# enable mod_rewrite
sudo a2enmod rewrite
# restart apache
sudo service apache2 restart
# install git and add autocomplete for it
sudo apt-get -y install git
curl -O --silent https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
echo 'if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi' >> ~/.bashrc
# install wp-cli and add autocomplete for it
curl -O --silent https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
curl -O --silent https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash
echo 'if [ -f ~/wp-completion.bash ]; then
. ~/wp-completion.bash
fi' >> ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment