Permalink
Browse files

added basic project setup script, added sample configurations

  • Loading branch information...
1 parent b5fb2c0 commit bbc3dbfeb712991fdedc9b57c2488751298dd392 @ryanmark ryanmark committed Jan 25, 2012
View
0 sample-data/__init__.py
No changes.
View
11 sample-data/blogs.json
@@ -0,0 +1,11 @@
+{
+ "blogs": [
+ {
+ "slug": "newblog",
+ "name": "My fancy new blog",
+ "options": {
+ "blogdescription": "This blog was automatically generated!"
+ }
+ }
+ ]
+}
View
84 sample-data/development_settings.json
@@ -0,0 +1,84 @@
+{
+ "install": {
+ "weblog_title": "Example Project",
+ "user_name": "admin",
+ "admin_email": "admin@example.com",
+ "public": 1,
+ "admin_password": "password",
+ "no_apache": true,
+
+ "network_id": 1,
+ "hostname": "example.dev",
+ "network_title": "Example network",
+ "base": "/",
+ "subdomain_install": false
+ },
+
+
+ "wp-config": {
+ "DB_NAME": "example",
+ "DB_USER": "example",
+ "DB_PASSWORD": "example",
+ "DB_HOST": "127.0.0.1",
+ "DB_CHARSET": "utf8",
+ "DB_COLLATE": "",
+ "WP_LANG": "",
+ "WP_DEBUG": false,
+ "DEPLOYMENT_TARGET": "development"
+ },
+
+ "network": {
+ "allowed_themes": [
+ "twentyeleven",
+ "twentyten"
+ ],
+ "varnish_server1": "localhost",
+ "dashboard_blog": 1,
+ "registrationnotification": "no",
+ "add_new_users": 0,
+ "registration": "user",
+ "upload_space_check_disabled": 1,
+ "fileupload_maxk": "15000",
+
+ "admin_footer_text": "Thank you for using example project!",
+ "nsm_include_post_type_post": 1
+ },
+
+ "options": {
+ "template": "twentyeleven",
+ "stylesheet": "twentyeleven",
+ "current_theme": "Twenty Eleven",
+ "timezone_string": "America/Chicago",
+ "use_trackback": 1,
+ "comment_registration": 1,
+ "default_ping_status": 1,
+ "comments_notify": 1,
+ "comment_whitelist": 0,
+ "comment_moderation": 0,
+
+ "smtp_pass": "",
+ "smtp_user": "",
+ "smtp_auth": "false",
+ "smtp_ssl": "none",
+ "smtp_port": "1025",
+ "smtp_host": "localhost",
+ "mail_set_return_path": "",
+ "mailer": "smtp",
+ "mail_from_name": "Example",
+ "mail_from": "no-reply@example.dev",
+
+ "wordpress_api_key": "foo",
+ "akismet_discard_month": false,
+ "akismet_show_user_comments_approved": false,
+ "comment_registration": true,
+ "comment_whitelist": false,
+ "comment_moderation": false
+ },
+
+ "root_options": {
+ "template": "twentyeleven",
+ "stylesheet": "twentyeleven",
+ "current_theme": "Twenty Eleven",
+ "timezone_string": "America/Chicago"
+ }
+}
View
100 sample-data/fabsettings.py
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+
+from fabric.api import env, local
+import os
+
+"""
+Base configuration
+"""
+env.project_name = "example"
+env.wpdomain = 'example.dev'
+env.path = os.getcwd()
+
+# Do you want to use git or svn for deployment?
+env.strategy = 'git'
+
+# If you said git, where should I clone from and which branch should I checkout?
+env.gitrepo = 'git@git.example.com:example/example.git'
+env.gitbranch = 'master'
+
+# These are the credentials for the wordpress. They should match your wp-config.php.
+env.db_host = 'localhost'
+env.db_name = env.project_name
+env.db_wpuser_name = env.project_name
+env.db_wpuser_pass = 'example' #make up something complicated for the password
+
+# Super user name and pass for adding users and databases to mysql
+env.db_root_user = "root"
+env.db_root_pass = "root"
+
+# Fix permissions throughout the deployment process. You may need to use this
+# if perms are getting messed up.
+env.fix_perms = False
+
+# Use this prefix when running scripts. (Setup env vars)
+env.prefix = ""
+
+# This defaults the run and sudo functions to local, so we don't have to duplicate
+# code for local development and deployed servers.
+env.sudo = local
+env.run = local
+
+env.cache_servers = ["lb1", "lb2", "lb3"]
+
+"""
+Environments
+"""
+def production():
+ """
+ Work on production environment
+ """
+ env.settings = 'production'
+ env.prefix = "DEPLOYMENT_TARGET=%(settings)s " % env
+ env.hosts = ['admin.wp.example.com']
+ env.user = 'wordpress'
+ env.path = '/home/wordpress/sites/example'
+ env.wpdomain = 'www.example.com'
+ env.db_root_user = "admin"
+ env.db_root_pass = "PassWorD"
+ env.db_host = 'db.wp.example.com'
+ env.fix_perms = True
+
+def staging():
+ """
+ Work on staging environment
+ """
+ env.settings = 'staging'
+ env.prefix = "DEPLOYMENT_TARGET=%(settings)s " % env
+ env.hosts = ['admin.beta.wp.example.com']
+ env.user = 'wordpress'
+ env.path = '/home/wordpress/sites/example'
+ env.wpdomain = 'beta.example.com'
+ env.db_root_user = "admin"
+ env.db_root_pass = "PassWorD"
+ env.db_host = 'db.beta.wp.example.com'
+ env.fix_perms = True
+
+"""
+Branches
+"""
+def stable():
+ """
+ Work on stable branch.
+ """
+ env.gitbranch = 'stable'
+
+def master():
+ """
+ Work on development branch.
+ """
+ env.gitbranch = 'master'
+
+def branch(branch_name):
+ """
+ Work on any specified branch.
+ """
+ env.gitbranch = branch_name
+
+"""
+Functions for this project
+"""
View
5 sample-data/plugins.json
@@ -0,0 +1,5 @@
+{
+ "plugins": [
+ "akismet/akismet.php"
+ ]
+}
View
83 sample-data/production_settings.json
@@ -0,0 +1,83 @@
+{
+ "weblog_title": "Example Project",
+ "user_name": "admin",
+ "admin_email": "admin@example.com",
+ "public": 1,
+ "admin_password": "password",
+ "network_id": 1,
+ "hostname": "example.dev",
+ "network_title": "Example network",
+ "base": "/",
+ "subdomain_install": false,
+ "upload_path": "/media",
+ "upload_url_path": "/media",
+
+ "akismet": {
+ "key": "foo"
+ },
+
+ "mail": {
+ "smtp_pass": "",
+ "smtp_user": "",
+ "smtp_auth": "false",
+ "smtp_ssl": "none",
+ "smtp_port": "1025",
+ "smtp_host": "localhost",
+ "mail_set_return_path": "",
+ "mailer": "smtp",
+ "mail_from_name": "Example",
+ "mail_from": "no-reply@example.dev"
+ },
+
+ "wp-config": {
+ "DB_NAME": "example",
+ "DB_USER": "example",
+ "DB_PASSWORD": "example",
+ "DB_HOST": "127.0.0.1",
+ "DB_CHARSET": "utf8",
+ "DB_COLLATE": "",
+ "WP_LANG": "",
+ "WP_DEBUG": false,
+ "DEPLOYMENT_TARGET": "development"
+ },
+
+ "network": {
+ "allowed_themes": [
+ "twentyeleven",
+ "twentyten"
+ ],
+ "varnish_server1": "localhost",
+ "dashboard_blog": 1,
+ "registrationnotification": "no",
+ "add_new_users": 0,
+ "registration": "user",
+ "upload_space_check_disabled": 1,
+ "fileupload_maxk": "15000",
+ "admin_footer_text": "Thank you for using example project!",
+ "nsm_include_post_type_post": 1
+ },
+
+ "site": {
+ "template": "twentyeleven",
+ "stylesheet": "twentyeleven",
+ "current_theme": "Twenty Eleven",
+ "timezone_string": "America/Chicago",
+ "use_trackback": 1,
+ "comment_registration": 1,
+ "default_ping_status": 1,
+ "comments_notify": 1,
+ "comment_whitelist": 0,
+ "comment_moderation": 0
+ },
+
+ "root_site": {
+ "template": "example",
+ "stylesheet": "example",
+ "current_theme": "Twenty Eleven",
+ "timezone_string": "America/Chicago",
+ "use_trackback": 1,
+ "comment_registration": 1,
+ "default_ping_status": 1,
+ "comments_notify": 1
+ }
+}
View
83 sample-data/staging_settings.json
@@ -0,0 +1,83 @@
+{
+ "weblog_title": "Example Project",
+ "user_name": "admin",
+ "admin_email": "admin@example.com",
+ "public": 1,
+ "admin_password": "password",
+ "network_id": 1,
+ "hostname": "example.dev",
+ "network_title": "Example network",
+ "base": "/",
+ "subdomain_install": false,
+ "upload_path": "/media",
+ "upload_url_path": "/media",
+
+ "akismet": {
+ "key": "foo"
+ },
+
+ "mail": {
+ "smtp_pass": "",
+ "smtp_user": "",
+ "smtp_auth": "false",
+ "smtp_ssl": "none",
+ "smtp_port": "1025",
+ "smtp_host": "localhost",
+ "mail_set_return_path": "",
+ "mailer": "smtp",
+ "mail_from_name": "Example",
+ "mail_from": "no-reply@example.dev"
+ },
+
+ "wp-config": {
+ "DB_NAME": "example",
+ "DB_USER": "example",
+ "DB_PASSWORD": "example",
+ "DB_HOST": "127.0.0.1",
+ "DB_CHARSET": "utf8",
+ "DB_COLLATE": "",
+ "WP_LANG": "",
+ "WP_DEBUG": false,
+ "DEPLOYMENT_TARGET": "development"
+ },
+
+ "network": {
+ "allowed_themes": [
+ "twentyeleven",
+ "twentyten"
+ ],
+ "varnish_server1": "localhost",
+ "dashboard_blog": 1,
+ "registrationnotification": "no",
+ "add_new_users": 0,
+ "registration": "user",
+ "upload_space_check_disabled": 1,
+ "fileupload_maxk": "15000",
+ "admin_footer_text": "Thank you for using example project!",
+ "nsm_include_post_type_post": 1
+ },
+
+ "site": {
+ "template": "twentyeleven",
+ "stylesheet": "twentyeleven",
+ "current_theme": "Twenty Eleven",
+ "timezone_string": "America/Chicago",
+ "use_trackback": 1,
+ "comment_registration": 1,
+ "default_ping_status": 1,
+ "comments_notify": 1,
+ "comment_whitelist": 0,
+ "comment_moderation": 0
+ },
+
+ "root_site": {
+ "template": "example",
+ "stylesheet": "example",
+ "current_theme": "Twenty Eleven",
+ "timezone_string": "America/Chicago",
+ "use_trackback": 1,
+ "comment_registration": 1,
+ "default_ping_status": 1,
+ "comments_notify": 1
+ }
+}
View
93 sample-http/development-nginx.conf
@@ -0,0 +1,93 @@
+server {
+ server_name example.dev;
+ listen 80;
+
+ # This location is automatically setup by runserver.py
+ root /tmp/nginxroot/wordpress;
+ index index.php;
+
+ location = /favicon.ico {
+ log_not_found off;
+ access_log off;
+ }
+
+ location = /robots.txt {
+ allow all;
+ log_not_found off;
+ access_log off;
+ }
+
+ # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
+ location ~ /\. {
+ deny all;
+ access_log off;
+ log_not_found off;
+ }
+
+ # WordPress multisite subdirectory rules.
+ # Designed to be included in any server {} block.
+
+ # This order might seem weird - this is attempted to match last if rules below fail.
+ # http://wiki.nginx.org/HttpCoreModule
+ location / {
+ try_files $uri $uri/ /index.php?$args;
+ }
+
+ location ^~ /wp-content/plugins {
+ alias /tmp/nginxroot/plugins;
+ }
+ location ^~ /wp-content/themes {
+ alias /tmp/nginxroot/themes;
+ }
+ location ^~ /wp-content/blogs.dir {
+ alias /tmp/nginxroot/blogs.dir;
+ }
+ location ^~ /wp-content/uploads {
+ alias /tmp/nginxroot/uploads;
+ }
+ location ^~ /wp-content/media {
+ alias /tmp/nginxroot/media;
+ }
+
+ # Add trailing slash to */wp-admin requests.
+ rewrite /wp-admin$ $scheme://$host$uri/ permanent;
+
+ # Directives to send expires headers and turn off 404 error logging.
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
+ # expires 24h;
+ expires max;
+ log_not_found off;
+ }
+
+ # Pass uploaded files to wp-includes/ms-files.php.
+ rewrite /files/$ /index.php last;
+
+ if ($uri !~ wp-content/plugins) {
+ rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
+ }
+
+ # Rewrite multisite '.../wp-.*' and '.../*.php'.
+ if (!-e $request_filename) {
+ rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
+ rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
+ rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
+ }
+
+ # Pass all .php files onto a php-fpm/php-fcgi server.
+ location ~ \.php$ {
+ # Zero-day exploit defense.
+ # http://forum.nginx.org/read.php?2,88845,page=3
+ # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
+ # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
+ try_files $uri =404;
+
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
+ include /usr/local/etc/nginx/fastcgi_params;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ #fastcgi_intercept_errors on;
+ fastcgi_pass unix:/tmp/php5-fpm.sock;
+ }
+
+}
+
View
24 sample-http/production-apache.conf
@@ -0,0 +1,24 @@
+<VirtualHost *:80>
+ ServerName www.example.com
+ ServerAlias example.com
+
+ ServerSignature Off
+
+ php_value upload_max_filesize 20M
+ php_value max_input_time 60
+
+ DocumentRoot /home/wordpress/sites/example/wordpress
+ <Directory />
+ Options FollowSymLinks
+ AllowOverride None
+ </Directory>
+
+ <Directory /home/wordpress/sites/example/wordpress/>
+ AllowOverride All
+ Order allow,deny
+ allow from all
+ </Directory>
+
+ # need aliases for plugins, blogs.dir, themes
+
+</VirtualHost>
View
91 sample-http/production-nginx.conf
@@ -0,0 +1,91 @@
+server {
+ server_name www.example.com example.com;
+
+ root /home/wordpress/sites/example;
+ index index.html index.php;
+
+ location = /favicon.ico {
+ log_not_found off;
+ access_log off;
+ }
+
+ location = /robots.txt {
+ allow all;
+ log_not_found off;
+ access_log off;
+ }
+
+ # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
+ location ~ /\. {
+ deny all;
+ access_log off;
+ log_not_found off;
+ }
+
+ # WordPress multisite subdirectory rules.
+ # Designed to be included in any server {} block.
+
+ # This order might seem weird - this is attempted to match last if rules below fail.
+ # http://wiki.nginx.org/HttpCoreModule
+ location / {
+ try_files $uri $uri/ /index.php?$args;
+ }
+
+ location ^~ /wp-content/plugins {
+ alias /home/wordpress/sites/example/plugins;
+ }
+ location ^~ /wp-content/themes {
+ alias /home/wordpress/sites/example/themes;
+ }
+ location ^~ /wp-content/blogs.dir {
+ alias /home/wordpress/sites/example/blogs.dir;
+ }
+ location ^~ /wp-content/uploads {
+ alias /home/wordpress/sites/example/uploads;
+ }
+ location ^~ /wp-content/media {
+ alias /home/wordpress/sites/example/media;
+ }
+
+ # Add trailing slash to */wp-admin requests.
+ rewrite /wp-admin$ $scheme://$host$uri/ permanent;
+
+ # Directives to send expires headers and turn off 404 error logging.
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
+ # expires 24h;
+ expires max;
+ log_not_found off;
+ }
+
+ # Pass uploaded files to wp-includes/ms-files.php.
+ rewrite /files/$ /index.php last;
+
+ if ($uri !~ wp-content/plugins) {
+ rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
+ }
+
+ # Rewrite multisite '.../wp-.*' and '.../*.php'.
+ if (!-e $request_filename) {
+ rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
+ rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
+ rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
+ }
+
+ # Pass all .php files onto a php-fpm/php-fcgi server.
+ location ~ \.php$ {
+ # Zero-day exploit defense.
+ # http://forum.nginx.org/read.php?2,88845,page=3
+ # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
+ # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
+ try_files $uri =404;
+
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
+ include fastcgi_params;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ #fastcgi_intercept_errors on;
+ fastcgi_pass unix:/tmp/php5-fpm.sock;
+ }
+
+}
+
View
24 sample-http/staging-apache.conf
@@ -0,0 +1,24 @@
+<VirtualHost *:80>
+ ServerName www.example.com
+ ServerAlias example.com
+
+ ServerSignature Off
+
+ php_value upload_max_filesize 20M
+ php_value max_input_time 60
+
+ DocumentRoot /home/wordpress/sites/example/wordpress
+ <Directory />
+ Options FollowSymLinks
+ AllowOverride None
+ </Directory>
+
+ <Directory /home/wordpress/sites/example/wordpress/>
+ AllowOverride All
+ Order allow,deny
+ allow from all
+ </Directory>
+
+ # need aliases for plugins, blogs.dir, themes
+
+</VirtualHost>
View
91 sample-http/staging-nginx.conf
@@ -0,0 +1,91 @@
+server {
+ server_name www.example.com example.com;
+
+ root /home/wordpress/sites/example;
+ index index.html index.php;
+
+ location = /favicon.ico {
+ log_not_found off;
+ access_log off;
+ }
+
+ location = /robots.txt {
+ allow all;
+ log_not_found off;
+ access_log off;
+ }
+
+ # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
+ location ~ /\. {
+ deny all;
+ access_log off;
+ log_not_found off;
+ }
+
+ # WordPress multisite subdirectory rules.
+ # Designed to be included in any server {} block.
+
+ # This order might seem weird - this is attempted to match last if rules below fail.
+ # http://wiki.nginx.org/HttpCoreModule
+ location / {
+ try_files $uri $uri/ /index.php?$args;
+ }
+
+ location ^~ /wp-content/plugins {
+ alias /home/wordpress/sites/example/plugins;
+ }
+ location ^~ /wp-content/themes {
+ alias /home/wordpress/sites/example/themes;
+ }
+ location ^~ /wp-content/blogs.dir {
+ alias /home/wordpress/sites/example/blogs.dir;
+ }
+ location ^~ /wp-content/uploads {
+ alias /home/wordpress/sites/example/uploads;
+ }
+ location ^~ /wp-content/media {
+ alias /home/wordpress/sites/example/media;
+ }
+
+ # Add trailing slash to */wp-admin requests.
+ rewrite /wp-admin$ $scheme://$host$uri/ permanent;
+
+ # Directives to send expires headers and turn off 404 error logging.
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
+ # expires 24h;
+ expires max;
+ log_not_found off;
+ }
+
+ # Pass uploaded files to wp-includes/ms-files.php.
+ rewrite /files/$ /index.php last;
+
+ if ($uri !~ wp-content/plugins) {
+ rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
+ }
+
+ # Rewrite multisite '.../wp-.*' and '.../*.php'.
+ if (!-e $request_filename) {
+ rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
+ rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
+ rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
+ }
+
+ # Pass all .php files onto a php-fpm/php-fcgi server.
+ location ~ \.php$ {
+ # Zero-day exploit defense.
+ # http://forum.nginx.org/read.php?2,88845,page=3
+ # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
+ # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
+ try_files $uri =404;
+
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
+ include fastcgi_params;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ #fastcgi_intercept_errors on;
+ fastcgi_pass unix:/tmp/php5-fpm.sock;
+ }
+
+}
+
View
45 setup.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# Setup a new WordPress project
+
+PROJECT_DIR=`pwd`
+
+if [[ ! -d $PROJECT_DIR ]]; then
+ mkdir $PROJECT_DIR
+fi
+
+cd $PROJECT_DIR
+
+# Start the repo
+git init
+
+# Get tools
+git submodule add https://ryanmark@github.com/ryanmark/wp-project-tools.git tools
+
+# Get WordPress
+git submodule add https://github.com/WordPress/WordPress.git wordpress
+
+# Setup some project directories
+mkdir lib mu-plugins plugins themes wp-scripts
+
+# Get example configurations
+cp -Rf tools/sample-data data
+cp -Rf tools/sample-http http
+
+# Link up the manage script
+ln -s tools/bin/manage.sh manage.sh
+
+# Move the fabfile stub into position
+cp tools/fabfile.py fabfile.py
+
+# Commit
+git commit -am "WordPress project setup"
+
+echo "----------------------------------------------------"
+echo " Please review the configuration in data/ and http/ "
+echo ""
+echo " When you are satisfied with the configuration, run "
+echo " ./manage.sh setup_env"
+echo " to get the proper libraries installed, then run"
+echo " fab bootstrap"
+echo " to install your WordPress blog"

0 comments on commit bbc3dbf

Please sign in to comment.