apache_conf 适用于Mac的SASS /指南针简单编译错误哔声。要听取样本,请在终端中运行:`afplay / System / Library / Sounds / Basso.aiff`

适用于Mac的SASS /指南针简单编译错误哔声。要听取样本,请在终端中运行:`afplay / System / Library / Sounds / Basso.aiff`

config.rb
# Play sound Basso upon error
on_stylesheet_error do
  system('afplay /System/Library/Sounds/Basso.aiff')
end

apache_conf 设置标题到期时间为.htacess <br/> <br/>来自http://www.paulund.co.uk/set-expire-headers-in-htaccess

设置标题到期时间为.htacess <br/> <br/>来自http://www.paulund.co.uk/set-expire-headers-in-htaccess

.htaccess
# ----------------------------------------------------------------------
# Expires headers (for better cache control)
# ----------------------------------------------------------------------
 
#
# These are pretty far-future expires headers
# They assume you control versioning with cachebusting query params like:
#   <script src="application.js?20100608">
# Additionally, consider that outdated proxies may miscache
#
#   www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
 
#
# If you don`t use filenames to version, lower the css and js to something like "access plus 1 week"
#
 
<IfModule mod_expires.c>
  ExpiresActive on
 
# Perhaps better to whitelist expires rules? Perhaps.
  ExpiresDefault                          "access plus 1 month"
 
# cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
  ExpiresByType text/cache-manifest       "access plus 0 seconds"
 
 
 
# Your document html
  ExpiresByType text/html                 "access plus 0 seconds"
   
# Data
  ExpiresByType text/xml                  "access plus 0 seconds"
  ExpiresByType application/xml           "access plus 0 seconds"
  ExpiresByType application/json          "access plus 0 seconds"
 
# RSS feed
  ExpiresByType application/rss+xml       "access plus 1 hour"
 
# Favicon (cannot be renamed)
  ExpiresByType image/x-icon              "access plus 1 week"
 
# Media: images, video, audio
  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpg                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"
  ExpiresByType video/ogg                 "access plus 1 month"
  ExpiresByType audio/ogg                 "access plus 1 month"
  ExpiresByType video/mp4                 "access plus 1 month"
  ExpiresByType video/webm                "access plus 1 month"
   
# HTC files  (css3pie)
  ExpiresByType text/x-component          "access plus 1 month"
   
# Webfonts
  ExpiresByType font/truetype             "access plus 1 month"
  ExpiresByType font/opentype             "access plus 1 month"
  ExpiresByType application/x-font-woff   "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
     
# CSS and JavaScript
  ExpiresByType text/css                  "access plus 1 year"
  ExpiresByType application/javascript    "access plus 1 year"
  ExpiresByType text/javascript           "access plus 1 year"
   
  <IfModule mod_headers.c>
    Header append Cache-Control "public"
  </IfModule>
   
</IfModule>

apache_conf WP-Stack的自定义配置文件,从db-tasks.rb和shared-tasks.rb加载一组新任务。

WP-Stack的自定义配置文件,从db-tasks.rb和shared-tasks.rb加载一组新任务。

shared-tasks.rb
# These tasks assume that your local and remote deploy users are both sudoers.

namespace :shared do

  desc "Pull uploaded files from remote location."
	task :pull do
		current_host = capture("echo $CAPISTRANO:HOST$").strip
		run "cd #{remote_uploads_folder}; sudo zip -r uploads .;"
		system "cd #{local_uploads_folder};  sudo mkdir #{release_name}; sudo mkdir ../#{release_name}; sudo mv * ../#{release_name}/; sudo scp #{user}@#{current_host}:#{remote_uploads_folder}/uploads.zip #{local_uploads_folder}; sudo unzip uploads.zip; sudo rm -rf uploads.zip ../#{release_name};"
		run "cd #{remote_uploads_folder}; sudo rm -f uploads.zip"
	end

	desc "Push uploaded files to remote location."
	task :push do
		current_host = capture("echo $CAPISTRANO:HOST$").strip
		puts "Current user is #{user}"
		system "cd #{local_uploads_folder}; sudo zip -r uploads .;"
		run "cd #{remote_uploads_folder};  sudo mkdir #{release_name}; sudo mkdir ../#{release_name}; sudo mv * ../#{release_name}/"
		system "sudo scp #{local_uploads_folder}/uploads.zip #{user}@#{current_host}:#{remote_uploads_folder}"
		run "cd #{remote_uploads_folder}; sudo unzip uploads.zip; sudo rm -rf uploads.zip ../#{release_name}; sudo chown -R #{user}:#{user} #{remote_uploads_folder}"
		system "cd #{local_uploads_folder}; sudo rm -f uploads.zip"
	end

end
db-tasks.rb
namespace :localdb do

  desc "Backup MySQL Local Database"
	task :mysqlbackup, :roles => :web do

		puts "Backing up MySQL local database..."

		filename = "#{release_name}-#{local_env_name}.sql"

		# Create folder for dumps, in case that it doesn't exist
		system "mkdir -p #{local_dump_dir}"

		if system "mysqldump -u#{db_local_user} -p#{db_local_password} #{db_local_name} > #{local_dump_dir}/#{filename}" then
			puts "MySQL local database saved to #{local_dump_dir}/#{filename}"
		else
			puts "MySQL local database could not be saved."
		end

	end

	desc "Restore Local MySQL Database"
  	task :mysqlrestore, :roles => :web do

		puts "Searching for available local backups..."

		# List contents from dumps folder
    		backups = `ls -1 #{local_dump_dir}/`.split("\n")
		# Define default backup
    		default_backup = backups.last

    		puts "Available backups: "
    		puts backups

    		backup = Capistrano::CLI.ui.ask "Which backup would you like to restore? [#{default_backup}] "
    		backup_file = default_backup if backup.empty?

		if system "mysql -u#{db_local_user} -p#{db_local_password} #{db_local_name} < #{local_dump_dir}/#{backup_file}" then
			puts "Local database restored to backup saved in #{local_dump_dir}/#{backup_file}."
		else
			puts "Local database could not be restored from backup."
		end

	end

	desc "Push local MySQL database backup to remote"
	task :mysqlpushdump, :roles =>  :web do

		puts "Searching for available local backups..."

		# List contents from dumps folder
    		backups = `ls -1 #{local_dump_dir}/`.split("\n")
		# Define default backup
    		default_backup = backups.last

    		puts "Available backups: "
    		puts backups

    		backup = Capistrano::CLI.ui.ask "Which backup would you like to push? [#{default_backup}] "
    		backup_file = default_backup if backup.empty?

		current_host = capture("echo $CAPISTRANO:HOST$").strip

		if system "scp #{local_dump_dir}/#{backup_file} #{user}@#{current_host}:#{remote_dump_dir}" then
			puts "Local database uploaded to remote host at #{remote_dump_dir}/#{backup_file}."
		else
			puts "Local database could not be pushed from backup."
		end

	end

	desc "Pull remote MySQL database backup to local"
	task :mysqlpulldump, :roles =>  :web do

		puts "Searching for available remote backups..."

		# List contents from dumps folder
    		backups = capture("ls -1 #{remote_dump_dir}").split("\n")
		# Define default backup
    		default_backup = backups.last

    		puts "Available backups: "
    		puts backups

    		backup = Capistrano::CLI.ui.ask "Which backup would you like to pull? [#{default_backup}] "
    		backup_file = default_backup if backup.empty?

		current_host = capture("echo $CAPISTRANO:HOST$").strip

		if system "scp #{user}@#{current_host}:#{remote_dump_dir}/#{backup_file} #{local_dump_dir}" then
			puts "Remote database saved to local host at #{local_dump_dir}/#{backup_file}."
		else
			puts "Remote database could not be pulled from backup."
		end

	end
end

namespace :remotedb do

	desc "Initialize database repository"
	task :repoinit, :roles => :web do

		begin
			run "cd #{remote_dump_dir}; git init; git remote add origin #{db_repository}; git config --global user.name \"#{git_user_name}\"; git config --global user.email \"#{git_user_email}\""
		rescue Exception => error
		end

	end

	desc "Backup remote MySQL database"
	task :mysqlbackup, :roles => :web do

		puts "Backing up remote MySQL database..."

		filename = "#{release_name}-#{remote_env_name}.sql"

		# Create folder for dumps, in case that it doesn't exist
		run "mkdir -p #{remote_dump_dir}"

		begin 
			run "mysqldump -u#{db_remote_user} -p#{db_remote_password} #{db_remote_name} > #{remote_dump_dir}/#{filename}"
			puts "Remote MySQL database saved to #{remote_dump_dir}/#{filename}"
			puts "Cleaning #{remote_dump_dir} to show only the last 5 files."
			run "cd #{remote_dump_dir}; (ls -t|head -n 5;ls)|sort|uniq -u|xargs rm;"
			begin
				run "cd #{remote_dump_dir}; git pull origin master; git add --all; git commit -m \"Cleaned dir and added #{filename}\"; git push -u origin master"
				puts "#{remote_dump_dir}/#{filename} was added to Git repository."
			rescue Exception => error
				puts "No Git repository was found. You should run cap remotedb:repoinit before this command."
			end
		rescue Exception => error
			puts "Remote MySQL database could not be saved."
		end

	end

	desc "Restore MySQL Production Database"
  	task :mysqlrestore, :roles => :web do

		puts "Searching for available remote backups..."

		# List contents from dumps folder
    		backups = capture("ls -1 #{remote_dump_dir}").split("\n")
		# Define default backup
    		default_backup = backups.last

    		puts "Available backups: "
    		puts backups

    		backup = Capistrano::CLI.ui.ask "Which backup would you like to restore? [#{default_backup}] "
    		backup_file = default_backup if backup.empty?
 
		begin
			run "mysql -u#{db_remote_user} -p#{db_remote_password} #{db_remote_name} < #{remote_dump_dir}/#{backup_file}"
			puts "Remote database restored to backup saved in #{local_dump_dir}/#{backup_file}."
		rescue Exception => error
			puts "Remote database could not be restored from backup."
		end
	end
end
config.rb
# Customize according to your needed configuration

set :application, "Application Name"
set :repository,  "git@github.com:user/repo.git"
set :db_repository, 'git@github.com:user/repo-db.git'
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

# This assumes you're using Git. Needed to run tasks in db-tasks.rb
set :git_user_name, "user"
set :git_user_email, "user@mail.com"

# Using Git Submodules?
set :git_enable_submodules, 1

# This should be the same as :deploy_to in production.rb
# This folder should be owned by user "deploy"
set :production_deploy_to, '/path/to/deploy'

# The domain name or IP address used for your staging environment
set :staging_domain, '127.0.0.1'

# Remote database credentials. Change to your username and database name.
set :db_remote_host, 'remote_host' # Generally "localhost"
set :db_remote_user, 'remote_user'
set :db_remote_password, 'remote_password'
set :db_remote_name, 'remote_name'

# Local database credentials. Change to your username and database name.
set :db_local_host, 'local_host' # Generally "localhost"
set :db_local_user, 'local_user'
set :db_local_password, 'local_password'
set :db_local_name, 'local_name'

# Places where you'd like to save your database dumps
# These folders should be owned by user "deploy"
set :local_dump_dir, '/local/path/to/dumps'
set :remote_dump_dir, '/remote/path/to/dumps'

# Path to your uploads folder
set :local_uploads_folder, '/local/path/to/uploads'
set :remote_uploads_folder, '/remote/path/to/uploads'

# Avoid tty fatal error
default_run_options[:pty] = true

# Environment names
# Needed to run tasks in db-tasks.rb
set :local_env_name, 'local_environment'
set :remote_env_name, 'remote_environment'

# Database
# Set the values for host, user, pass, and name for both production and staging.
set :wpdb do
  {
		:production => {
			:host     => "production_localhost",
			:user     => "production_user",
			:password => "production_password",
			:name     => "production_name",
		},
		:staging => {
			:host     => "local_host",
			:user     => "local_user",
			:password => "local_password",
			:name     => "local_name",
		}
	}
end

# Backup remote database before make symbolic link to current release
before "deploy:symlink", "remotedb:mysqlbackup"

# Load database specific tasks
loadFile 'lib/db-tasks.rb'

# Load tasks for shared files
loadFile 'lib/shared-tasks.rb'

apache_conf 基本的Auth Middleman和Heroku

基本的Auth Middleman和Heroku

config.ru
# This is a snippet to add to middleman's config.ru file if you want to add basic auth to your middleman app on heroku
# NOTE: you need to stick this above the build script like shown below

use Rack::Auth::Basic, "Restricted Area" do |username, password|
  [username, password] == ['username', 'password']
end

# This part below is just what builds the static site. you only need to add lines 4 - 6 above any build command like shown below.
use Rack::TryStatic, :root => "build", :urls => %w[/], :try => ['.html', 'index.html', '/index.html']

apache_conf Reestringir Directorio

Reestringir Directorio

Reestriccion con .htaccess
<LIMIT GET>
order deny,allow
deny from all
</LIMIT>

apache_conf .htaccess在Media Temple上以HTML5模式使用AngularJS

.htaccess在Media Temple上以HTML5模式使用AngularJS

.htaccess
Options +FollowSymLinks

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !index
    RewriteRule (.*) index.html [L]
</ifModule>

apache_conf 配置

配置

config
#use origin without https, otherwise it will ask for login/pass

git config remote.origin.url git@github.com:the_repository_username/your_project.git

apache_conf config.yaml

config.yaml
name: P-M-ServerStatus-Lite
version: 1.00

plack_middlewares:
  - name: ServerStatus::Lite
    options:
      - key: path
        value: /server-status
      - key: allow
        value:
          - 127.0.0.1
          - 192.168.0.0/16
      - key: counter_file
        value: /tmp/counter_file
      - key: scoreboard
        value: /tmp/mt-run/server
    apply_to:
      - cms

apache_conf config.yaml

config.yaml
name: P-M-AliasedSearch
version: 1.00
description: This plugin creates aliases to search-parameter.

plack_middlewares:
  - name: MT::AliasedSearch
    options:
      - key: recipes
        value:
          - from: food
            to: search=food&IncludeBlogs=1&limit=20
          - from: event
            to: search=event&IncludeBlogs=1&limit=20
    apply_to:
      - new_search

apache_conf config.yaml

config.yaml
name: P-M-DebugRequestParams
version: 1.00

plack_middlewares:
  - name: DebugRequestParams
    condition: sub { MT->config->DebugMode }
    apply_to:
      - all