Last active
January 14, 2019 19:38
-
-
Save DDynamic/afd1cc378fbd470d66fd718425b3b52e to your computer and use it in GitHub Desktop.
LEMP Stack Vagrantfile on Ubuntu 18
This file contains 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
#!/bin/bash | |
# Update | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
# Install Zip and Unzip | |
sudo apt-get -y install zip unzip | |
# Install Nginx | |
sudo apt-get -y install nginx | |
# Allow Nginx Through Firewall | |
sudo ufw allow 'Nginx Full' | |
# Install MySQL | |
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 | |
# Install PHP and Modify Configuration | |
sudo apt-get -y install php-fpm php-mysql php-mbstring php-xml php-gd php-curl php-zip | |
sudo sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.2/fpm/php.ini | |
sudo service php7.2-fpm restart | |
# Install Certbot | |
sudo apt-get install -y software-properties-common | |
sudo add-apt-repository ppa:certbot/certbot -y | |
sudo apt-get update | |
sudo apt-get install -y python-certbot-nginx | |
# Edit Default Nginx Configuration to Support PHP | |
sudo tee /etc/nginx/sites-available/default << END | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/html; | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name localhost; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php7.2-fpm.sock; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
END | |
sudo service nginx reload | |
# Add an info.php Page | |
sudo tee /var/www/html/info.php << END | |
<?php | |
phpinfo(); | |
END | |
# Download Adminer Database Manager | |
sudo curl -o /var/www/html/adminer.php -L https://github.com/vrana/adminer/releases/download/v4.6.2/adminer-4.6.2.php | |
# Set Webserver Permissions | |
sudo adduser $USER www-data | |
sudo chown -R www-data:www-data /var/www | |
sudo chmod -R g+srwX /var/www | |
exec sg www-data newgrp `id -gn` | |
# Install Composer Globally | |
wget https://raw.githubusercontent.com/composer/getcomposer.org/1b137f8bf6db3e79a38a5bc45324414a6b1f9df2/web/installer -O - -q | php -- --quiet | |
sudo mv composer.phar /usr/local/bin/composer | |
IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') | |
# Configure Nano | |
sudo sed -i -e "s/# set tabsize 8/set tabsize 4/" /etc/nanorc | |
sudo sed -i -e "s/# set tabstospaces/set tabstospaces/" /etc/nanorc | |
# Store Git credientials globally | |
git config --global credential.helper store | |
# Echo Complete Message | |
echo "" | |
echo -e "\033[0;32mYour VM has been provisioned with Nginx, MySQL, PHP, Composer, and Adminer.\033[0m" | |
echo "" | |
echo -e "\033[0;32mPHP Info: http://$IP/info.php\033[0m" | |
echo -e "\033[0;32mAdminer Database Manager: http://$IP/adminer.php\033[0m" | |
echo "" | |
echo -e "\033[0;32mMySQL Username: root\033[0m" | |
echo -e "\033[0;32mMySQL Password: root\033[0m" | |
echo -e "\033[0;33mYou may wish to secure your MySQL installation: sudo mysql_secure_installation\033[0m" |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/bionic64" | |
config.vm.network "public_network" | |
config.vm.provision "shell", privileged: false, path: "https://gist.githubusercontent.com/DDynamic/afd1cc378fbd470d66fd718425b3b52e/raw/provision.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment