Skip to content

Instantly share code, notes, and snippets.

@adamaltman
Created March 12, 2016 00:55
Show Gist options
  • Save adamaltman/8bb819a3deeb2baeb552 to your computer and use it in GitHub Desktop.
Save adamaltman/8bb819a3deeb2baeb552 to your computer and use it in GitHub Desktop.
Masterclass Vagrant Setup w/ rasmus/php7dev
server {
listen 80;
server_name dev.masterclass.com;
root /vagrant/public/;
index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
error_page 500 502 503 504 /50x.html;
sendfile off;
location = /50x.html {
root /var/www/default;
}
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^(.*)$ /index.php;
}
location ~ \.php {
include fastcgi_params;
fastcgi_keep_conn on;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php-fpm.sock;
}
}
## first install vagrant hostmanager:
# `$ vagrant plugin install vagrant-hostmanager`
$script = <<SCRIPT
echo I am provisioning...
date > vagrant_provisioned_at
echo I am setting up nginx vhost configuration ...
cp -rp /vagrant/masterclass.nginx.conf /etc/nginx/conf.d/
service nginx restart
echo web server is ready, access at http://dev.masterclass.com
echo mysql setup database dev
mysql -uroot -pvagrant -e 'CREATE DATABASE IF NOT EXISTS `dev` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci'
echo create initial mysql schema
mysql -uroot -pvagrant dev < /vagrant/schema.sql
echo Ready for mastery.
SCRIPT
Vagrant.configure(2) do |config|
config.vm.box = "rasmus/php7dev"
config.vm.network "private_network", ip: "10.0.99.12"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.aliases = 'dev.masterclass.com'
config.vm.synced_folder ".", "/vagrant", owner: "vagrant", group: "www-data", mount_options: ['dmode=775']
config.vm.provision "shell", inline: $script
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment