Skip to content

Instantly share code, notes, and snippets.

@ahmednuaman
Created May 22, 2015 18:52
Show Gist options
  • Save ahmednuaman/5e21f7e26d7437eae578 to your computer and use it in GitHub Desktop.
Save ahmednuaman/5e21f7e26d7437eae578 to your computer and use it in GitHub Desktop.
LAMP on vagrant
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/vivid64"
config.vm.network "forwarded_port", guest: 80, host: 8000
config.vm.synced_folder ".", "/var/www/html"
config.ssh.forward_agent = true
config.vm.provision "shell", inline: <<-SHELL
export DEBIAN_FRONTEND=noninteractive
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "Europe/London" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH & MySQL Ports
ufw enable
ufw allow 22
ufw allow 3306
# Install essential packages
apt-get -y install zsh htop
# Install MySQL Server in a Non-Interactive mode. Default root password will be "root"
echo "mysql-server-5.6 mysql-server/root_password password root" | sudo debconf-set-selections
echo "mysql-server-5.6 mysql-server/root_password_again password root" | sudo debconf-set-selections
apt-get -y install mysql-server-5.6
# Run the MySQL Secure Installation wizard
mysql_secure_installation
sed -i 's/127\.0\.0\.1/0\.0\.0\.0/g' /etc/mysql/my.cnf
mysql -uroot -p -e 'USE mysql; UPDATE `user` SET `Host`="%" WHERE `User`="root" AND `Host`="localhost"; DELETE FROM `user` WHERE `Host` != "%" AND `User`="root"; FLUSH PRIVILEGES;'
service mysql restart
# Install Apache and PHP
sudo apt-get install -y apache2 php5 libapache2-mod-php5 php5-mcrypt libapache2-mod-auth-mysql php5-mysql php5-curl
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment