Skip to content

Instantly share code, notes, and snippets.

@davidjguru
Created December 26, 2017 18:47
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 davidjguru/aefe382779a48b73cccfd9002d5f2e47 to your computer and use it in GitHub Desktop.
Save davidjguru/aefe382779a48b73cccfd9002d5f2e47 to your computer and use it in GitHub Desktop.
## Getting Vagrant
wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb?_ga=2.82700054.164498689.1514303275-2027648582.1514303275
## Installing a provider
sudo apt-get install virtualbox
## Installing Vagrant
sudo dpkg -i vagrant_2.0.1_x86_64.deb
## Creating the Vagrantfile
vim vagrantfile
## Within vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provision "shell", path: "provisioner.sh"
end
## Esc + :wq! (exit from Vim and save)
## Creating the provisioner.sh configuration script
## Beware: MySQL password by default
#!/bin/bash
sudo apt-get install python-software-properties -y
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y
sudo apt-get --purge autoremove -y
sudo service php7.0-fpm restart
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 mysql-client
sudo service mysql start
sudo apt-get install nginx -y
sudo cat > /etc/nginx/sites-available/default <<- EOM
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /vagrant;
index index.php index.html index.htm;
server_name server_domain_or_IP;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location ~ \.php\$ {
try_files \$uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_
name;
include fastcgi_params;
}
}
EOM
sudo service nginx restart
## Ok, now launch Vagrant
vagrant up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment