Open hubrix opened 11 years ago
@hubrix, at the moment, there's no story around developing on a wordpress-on-heroku site. It's just for pushing WP sites to production. I understand this might be a PITA, so I'm definitely open to suggestions.
Can you share how you like to work? If we can come up with a non-crufty approach, I'd consider folding that in to the buildpack
So here's how I have things set up.
I added a wordpress directory to vendor and created a local Apache vhost to point to that.
the wp-content from that directory is symlinked to public/config/wp-content.
I have mysql and memcache installed locally.
there is a local wp-config, at the moment its in the vendor wordpress directory but really should be symlinked out.
this allows pretty decent local work. there are two things which are still missing that i need to script out (I've done them manually)
Mark Friedgan
On Sunday, March 3, 2013 at 10:57 PM, Marc Chung wrote:
@hubrix (https://github.com/hubrix), at the moment, there's no story around developing on a wordpress-on-heroku site. It's just for pushing WP sites to production. I understand this might be a PITA, so I'm definitely open to suggestions. Can you share how you like to work? If we can come up with a non-crufty approach, I'd consider folding that in to the buildpack
— Reply to this email directly or view it on GitHub (https://github.com/mchung/heroku-buildpack-wordpress/issues/14#issuecomment-14364010).
Hey @hubrix, you can use object-cache and batcache locally if you have APC. Just add object-cache.php to the gitignore and substitute it for this one: http://wordpress.org/extend/plugins/apc/
Instead of creating two different wp-config.php files I suggest you to use ENV variables with the same names than Heroku's.
To synchronise the db with cleardb you must change two things, the url and the path directory, but you need to avoid corruption in the serialised data. I do it with this script: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
To push things to s3 I'm using this plugin: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/ I like it more than WPRO.
Thanks to @hubrix and @LuisHerranz, I got a pretty workable local setup. For others who follow their advice, I'd mention two things:
1) if you symlink your wp-content directory link as @hubrix suggests, you might get some plugin activation fatal errors on your local environment if some plugins use wordpress constants to resolve their plugin directory. to fix this you need to add this to your wp-config.php:
define('WP_CONTENT_DIR', realpath($_SERVER['DOCUMENT_ROOT'] . '/wp-content'));
2) the search and replace cli that @LuisHerranz recommended works great. Below is a script to automate the db import (production --> local). Of course replace the XYZs with your own credentials, and grab the searchreplacedb2cli.php
file from github:
https://github.com/interconnectit/Search-Replace-DB
Import script:
CLEAR_DB_HOST="XYZ"
CLEAR_DB_USER="XYZ"
CLEAR_DB_NAME="XYZ"
CLEAR_DB_PASS="XYZ"
LOCAL_DB_NAME="XYZ"
LOCAL_DB_PASS="XYZ"
SEARCH_THIS="XYZ"
REPLACE_WITH="XYZ"
NOW="$(date +"%d-%m-%Y")"
mkdir -p backups
echo "Backing Up ClearDB "$CLEAR_DB_NAME
mysqldump -h $CLEAR_DB_HOST -u $CLEAR_DB_USER -p$CLEAR_DB_PASS $CLEAR_DB_NAME > ./backups/db-$NOW.sql --add-drop-table
echo "Importing ClearDB "$CLEAR_DB_NAME
sudo mysql -u root -p$LOCAL_DB_PASS -h localhost $LOCAL_DB_NAME < ./backups/db-$NOW.sql
echo "Replacing "$SEARCH_THIS" with "$REPLACE_WITH
./searchreplacedb2cli.php --host localhost --user root --database $LOCAL_DB_NAME --pass $LOCAL_DB_PASS --charset utf\-8 --search $SEARCH_THIS --replace $REPLACE_WITH
KEEP_BACKUP_DAYS=15
echo "Removing backups older than "$KEEP_BACKUP_DAYS" days old"
find ./backups -mtime +$KEEP_BACKUP_DAYS -type f -delete
echo "Done!"```
Great script! Thanks @cureau!
I'd like to know how to run this stuff locally. Any way we can get some cut and paste instructions? I'm migrating over from App Fog to Heroku and wp-admin is hanging and I have no idea why.
I've now gone through the exercise twice of setting up a local copy and it's a big pain. I think it's worth trying to make some generic config so that one is able to run a local copy without too much pain. It basically involves having two wp-config.php files and having a vendor copy of wordpress. I have not figured out how to deal with memcachesasl locally yet, i just disable it.
I also had to do this to object-cache.php but it seems hacky