Skip to content

Instantly share code, notes, and snippets.

@asaelx
Created April 17, 2015 15:06
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 asaelx/416c52bed58fc831eb3f to your computer and use it in GitHub Desktop.
Save asaelx/416c52bed58fc831eb3f to your computer and use it in GitHub Desktop.
Provision for LEMP
#!/usr/bin/env bash
#Config
NAME="app"
USER="asaelx"
MYSQL_PASSWORD="secret"
echo "=====Configuring Virtual Machine..."
echo "=====Getting last updates..."
apt-get update
echo "=====Installing git..."
apt-get install git -y
echo "=====Installing nginx..."
apt-get install nginx -y
echo "=====Updating PHP repository..."
apt-get install python-software-properties build-essential -y
add-apt-repository ppa:ondrej/php5 -y
apt-get update
echo "=====Installing PHP..."
apt-get install php5-common php5-dev php5-cli php5-fpm -y
echo "=====Installing PHP extensions..."
apt-get install curl php5-curl php5-gd php5-mcrypt php5-mysql -y
echo "=====Setting up MySQL..."
apt-get install debconf-utils -y
debconf-set-selections <<< "mysql-server mysql-server/root_password password $MYSQL_PASSWORD"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $MYSQL_PASSWORD"
echo "=====Installing MySQL..."
apt-get install mysql-server -y
echo "=====Configuring Nginx..."
cp /vagrant/nginx_config /etc/nginx/sites-available/$NAME.dev
ln -s /etc/nginx/sites-available/$NAME.dev /etc/nginx/sites-enabled/$NAME.dev
rm -rf /etc/nginx/sites-available/default
service nginx restart
echo "=====Creating database..."
echo "CREATE DATABASE $NAME;" | mysql -u root -p$MYSQL_PASSWORD
echo "CREATE USER '$USER'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';" | mysql -u root -p$MYSQL_PASSWORD
echo "GRANT ALL PRIVILEGES ON * . * TO '$USER'@'localhost';" | mysql -u root -p$MYSQL_PASSWORD
echo "FLUSH PRIVILEGES;" | mysql -u root -p$MYSQL_PASSWORD
echo "=====Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment