Skip to content

Commit

Permalink
applied the 32-bit ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
buonzz committed Aug 7, 2014
1 parent cc4b6c3 commit 4ddf543
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.vagrant
21 changes: 21 additions & 0 deletions Homestead.yaml
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
Empty file modified README.md
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions Vagrantfile
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
18 changes: 18 additions & 0 deletions aliases
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
}

66 changes: 66 additions & 0 deletions scripts/homestead.rb
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
42 changes: 42 additions & 0 deletions scripts/serve.sh
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

0 comments on commit 4ddf543

Please sign in to comment.