forked from buonzz/homestead32
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text eol=lf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.vagrant |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
ip: "192.168.10.10" | ||
memory: 2048 | ||
cpus: 1 | ||
|
||
authorize: /Users/me/.ssh/id_rsa.pub | ||
|
||
keys: | ||
- /Users/me/.ssh/id_rsa | ||
|
||
folders: | ||
- map: /Users/me/Code | ||
to: /home/vagrant/Code | ||
|
||
sites: | ||
- map: homestead.app | ||
to: /home/vagrant/Code/Laravel/public | ||
|
||
variables: | ||
- key: APP_ENV | ||
value: local |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
VAGRANTFILE_API_VERSION = "2" | ||
|
||
path = "#{File.dirname(__FILE__)}" | ||
|
||
require 'yaml' | ||
require path + '/scripts/homestead.rb' | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
Homestead.configure(config, YAML::load(File.read(path + '/Homestead.yaml'))) | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
alias ..="cd .." | ||
alias ...="cd ../.." | ||
|
||
alias h='cd ~' | ||
alias c='clear' | ||
|
||
function serve() { | ||
if [[ "$1" && "$2" ]] | ||
then | ||
sudo dos2unix /vagrant/scripts/serve.sh | ||
sudo bash /vagrant/scripts/serve.sh "$1" "$2" | ||
else | ||
echo "Error: missing required parameters." | ||
echo "Usage: " | ||
echo " serve domain path" | ||
fi | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
class Homestead | ||
def Homestead.configure(config, settings) | ||
# Configure The Box | ||
config.vm.box = "antoniofrignani/laravel-homestead-settler-32" | ||
config.vm.hostname = "homestead32" | ||
|
||
# Configure A Private Network IP | ||
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10" | ||
|
||
# Configure A Few VirtualBox Settings | ||
config.vm.provider "virtualbox" do |vb| | ||
vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"] | ||
vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"] | ||
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] | ||
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | ||
end | ||
|
||
# Configure Port Forwarding To The Box | ||
config.vm.network "forwarded_port", guest: 80, host: 8000 | ||
config.vm.network "forwarded_port", guest: 3306, host: 33060 | ||
config.vm.network "forwarded_port", guest: 5432, host: 54320 | ||
|
||
# Configure The Public Key For SSH Access | ||
config.vm.provision "shell" do |s| | ||
s.inline = "echo $1 | tee -a /home/vagrant/.ssh/authorized_keys" | ||
s.args = [File.read(File.expand_path(settings["authorize"]))] | ||
end | ||
|
||
# Copy The SSH Private Keys To The Box | ||
settings["keys"].each do |key| | ||
config.vm.provision "shell" do |s| | ||
s.privileged = false | ||
s.inline = "echo \"$1\" > /home/vagrant/.ssh/$2 && chmod 600 /home/vagrant/.ssh/$2" | ||
s.args = [File.read(File.expand_path(key)), key.split('/').last] | ||
end | ||
end | ||
|
||
# Copy The Bash Aliases | ||
config.vm.provision "shell" do |s| | ||
s.inline = "cp /vagrant/aliases /home/vagrant/.bash_aliases" | ||
end | ||
|
||
# Register All Of The Configured Shared Folders | ||
settings["folders"].each do |folder| | ||
config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil | ||
end | ||
|
||
# Install All The Configured Nginx Sites | ||
settings["sites"].each do |site| | ||
config.vm.provision "shell" do |s| | ||
s.inline = "bash /vagrant/scripts/serve.sh $1 $2" | ||
s.args = [site["map"], site["to"]] | ||
end | ||
end | ||
|
||
# Configure All Of The Server Environment Variables | ||
if settings.has_key?("variables") | ||
settings["variables"].each do |var| | ||
config.vm.provision "shell" do |s| | ||
s.inline = "echo \"\nenv[$1] = '$2'\" >> /etc/php5/fpm/php-fpm.conf && service php5-fpm restart" | ||
s.args = [var["key"], var["value"]] | ||
end | ||
end | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
block="server { | ||
listen 80; | ||
server_name $1; | ||
root $2; | ||
index index.html index.htm index.php; | ||
charset utf-8; | ||
location / { | ||
try_files \$uri \$uri/ /index.php?\$query_string; | ||
} | ||
location = /favicon.ico { access_log off; log_not_found off; } | ||
location = /robots.txt { access_log off; log_not_found off; } | ||
access_log off; | ||
error_log /var/log/nginx/$1-error.log error; | ||
error_page 404 /index.php; | ||
sendfile off; | ||
location ~ \.php$ { | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass unix:/var/run/php5-fpm.sock; | ||
fastcgi_index index.php; | ||
include fastcgi_params; | ||
} | ||
location ~ /\.ht { | ||
deny all; | ||
} | ||
} | ||
" | ||
|
||
echo "$block" > "/etc/nginx/sites-available/$1" | ||
ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1" | ||
service nginx restart | ||
service php5-fpm restart |