Last active
October 9, 2015 18:48
-
-
Save ziadoz/3559314 to your computer and use it in GitHub Desktop.
Web Development Setup (Bash, SSH, Ruby)
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
# Bash Profile | |
# File: ~/.bash_profile | |
# Set $WEB_DIR and $SCRIPTS_DIR to the appropriate directories. | |
export PATH="./vendor/bin:$PATH" | |
export EDITOR=nano | |
export WEB_DIR="/var/www/vhosts" | |
export SCRIPTS_DIR="~/.web" | |
alias reloadhosts="dscacheutil -flushcache" | |
alias reloadbash="source ~/.bash_profile" | |
alias editbash="subl ~/.bash_profile" | |
alias webdir="cd $WEB_DIR" | |
alias webvhosts="subl $WEB_DIR/vhosts.conf" | |
alias webstart="sudo apachectl start" | |
alias webstop="sudo apachectl stop" | |
alias webrestart="sudo apachectl restart" | |
alias webconfigtest="sudo apachectl configtest" | |
alias webupdate="ruby $SCRIPTS_DIR/webupdate.rb" | |
alias webpull="ruby $SCRIPTS_DIR/hgupdate.rb" |
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
# Mercurial Deployment | |
# File: /path/to/repository/.hg/hgrc | |
# $ hg push staging | |
# $ hg push live | |
[paths] | |
live = ssh://<username>@<server>//var/www/vhosts/<live-website> | |
staging = ssh://<username>@<server>//var/www/vhosts/<staging-website> | |
[hooks] | |
changegroup = hg update |
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
# SSH Config Example | |
# File: ~/.ssh/config | |
# Usage: $ ssh foobar | |
# SSH Identities: | |
# $ ssh-keygen -f ~/.ssh/<identity> -C "<identity>" | |
# $ ssh-add ~/.ssh/<identity> | |
# $ ssh-add -l | |
Host foobar | |
Compression yes | |
HostName 127.0.0.1 | |
User username | |
Port 22 |
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
#! /usr/bin/env ruby | |
# Mercurial Update | |
# File: ~/.web/hgupdate.rb | |
$VERBOSE = nil | |
VHOST_DIRECTORY = ENV['WEB_DIR'] ||= "/var/www/vhosts" | |
DIR_PATTERN = File.join(VHOST_DIRECTORY, "/**") | |
require "shellwords" | |
Dir.glob(DIR_PATTERN).each do |dir| | |
hg = File.join(dir, ".hg") | |
dir = Shellwords.escape(dir) | |
system("cd #{dir} && hg pull -u") if File.exists?(hg) | |
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
#! /usr/bin/env ruby | |
# Web Udpate | |
# File: ~/.web/webupdate.rb | |
$VERBOSE = nil | |
VHOST_DIRECTORY = ENV['WEB_DIR'] ||= "/var/www/vhosts" | |
VHOST_PATTERN = File.join(VHOST_DIRECTORY, "/**/dev.conf") | |
VHOST_FILE = File.join(VHOST_DIRECTORY, "vhosts.conf") | |
confs = Dir.glob(VHOST_PATTERN) | |
open(VHOST_FILE, "w") do |file| | |
includes = confs.map{ |conf| "Include #{conf}" }.join("\n") | |
file.write(includes) | |
end | |
system("sudo apachectl configtest") | |
system("sudo apachectl restart") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment