Created
May 25, 2016 13:40
-
-
Save annalinneajohansson/de9861f8b165c66d5d5a269226611dc2 to your computer and use it in GitHub Desktop.
Basic LAMP Vagrant provision script for Ubuntu servers
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
#!/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