Middlebury

Difference between revisions of "WordPress Development"

(Copying production database to development)
Line 35: Line 35:
 
"s#chisel\.middlebury\.edu','/#chisel.middlebury.edu','/~yourname/wordpress/#gi" yourname_wordpress.sql</code>
 
"s#chisel\.middlebury\.edu','/#chisel.middlebury.edu','/~yourname/wordpress/#gi" yourname_wordpress.sql</code>
 
# Import updated sql into your development database<pre>mysql -u testuser -ptestpassword -D yourname_wordpress < yourname_wordpress.sql</pre>
 
# Import updated sql into your development database<pre>mysql -u testuser -ptestpassword -D yourname_wordpress < yourname_wordpress.sql</pre>
 +
 +
[[Category:WordPress]]

Revision as of 11:26, 11 November 2011

WordPress is used at Middlebury by a variety of individuals and groups including faculty, staff, students, administrators, designers, developers, librarians, technologists, academic and administrative departments, offices, student organizations, courses, initiatives, projects and so on. This document compiles recommendations about how Wordpress at Middlebury should be configured, updated and maintained.

Initial Setup

The initial setup of WordPress requires:

  1. cloning the Midd WordPress git repository
  2. editing the config.php and .htaccess files
  3. copying production database

Cloning the central repository

Your ssh keys must be authorized to access the central repository. All chisel accounts' ssh keys have been authorized to do so at the time of this writing. Contact Adam to add ssh keys for other machines (such as your desktop) if desired.

  1. cd to your public_html directory on chisel:
    cd ~/public_html/
  2. clone the repository and create a working directory with git-clone:
    git clone git@chisel.middlebury.edu:wordpress-mu.git wordpress
  3. cd into new wordpress directory
    cd wordpress
  4. initialize submodules and then update:
    git submodule init
    git submodule update

Configuring WordPress

  1. cd to your wordpress directory:
    cd ~/public_html/wordpress/
  2. Create a local copy of your WordPress configuration
    cp wp-config.php-midd wp-config.php
  3. Update local copy of WordPress configuration
    -define('DB_NAME', 'username_wordpress');
    +define('DB_NAME', 'yourname_wordpress');
    -$base'/';
    +$base'/~yourname/wordpress/';
  4. Create a local copy of your .htaccess file:
    cp .htaccess-midd .htaccess
  5. Update local copy of .htaccess file:
    -RewriteBase
    +RewriteBase /~yourname/wordpress/

Copying production database to development

  1. Create a database, (e.g. yourname_wordpress) on development server
  2. Dump the production database

mysqldump -h snipe -u wordpress -p --lock-tables=false --skip-extended-insert wordpress > yourname_wordpress.sql

  1. Re-write server specific values in SQL using perl scripts

perl -p -i -e 's#http://blogs.middlebury.edu#http://chisel.middlebury.edu/~yourname/wordpress#gi' yourname_wordpress.sql perl -p -i -e 's#blogs.middlebury.edu#chisel.middlebury.edu#gi' yourname_wordpress.sql perl -p -i -e "s#chisel\.middlebury\.edu','/#chisel.middlebury.edu','/~yourname/wordpress/#gi" yourname_wordpress.sql

  1. Import updated sql into your development database
    mysql -u testuser -ptestpassword -D yourname_wordpress < yourname_wordpress.sql