|
| 1 | +# WordPress Heroku |
| 2 | + |
| 3 | +This project is a template for installing and running [WordPress](http://wordpress.org/) on [Heroku](http://www.heroku.com/). The repository comes bundled with: |
| 4 | +* [PostgreSQL for WordPress](http://wordpress.org/extend/plugins/postgresql-for-wordpress/) |
| 5 | +* [Amazon S3 and Cloudfront](https://wordpress.org/plugins/amazon-s3-and-cloudfront/) |
| 6 | +* [WP Sendgrid](https://wordpress.org/plugins/wp-sendgrid/) |
| 7 | +* [Wordpress HTTPS](https://wordpress.org/plugins/wordpress-https/) |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +Clone the repository from Github |
| 12 | + |
| 13 | + $ git clone git://github.com/itsiky/heroku-wordpress.git |
| 14 | + |
| 15 | +With the [Heroku gem](http://devcenter.heroku.com/articles/heroku-command), create your app |
| 16 | + |
| 17 | + $ cd heroku-wordpress |
| 18 | + $ heroku create |
| 19 | + Creating strange-bird-1234... done, stack is cedar |
| 20 | + http://strange-bird-1234.herokuapp.com/ | [email protected]:strange-bird-1234.git |
| 21 | + Git remote heroku added |
| 22 | + |
| 23 | +Add a database to your app |
| 24 | + |
| 25 | + $ heroku addons:create heroku-postgresql |
| 26 | + Creating HEROKU_POSTGRESQL_INSTANCE... done, (free) |
| 27 | + Adding HEROKU_POSTGRESQL_INSTANCE to strange-bird-1234... done |
| 28 | + Setting DATABASE_URL and restarting strange-bird-1234... done, v3 |
| 29 | + Database has been created and is available |
| 30 | + ! This database is empty. If upgrading, you can transfer |
| 31 | + ! data from another database with pgbackups:restore |
| 32 | + Use `heroku addons:docs heroku-postgresql` to view documentation. |
| 33 | + |
| 34 | +Promote the database (replace HEROKU_POSTGRESQL_INSTANCE with the name from the above output) |
| 35 | + |
| 36 | + $ heroku pg:promote HEROKU_POSTGRESQL_INSTANCE |
| 37 | + Promoting HEROKU_POSTGRESQL_INSTANCE to DATABASE_URL... done |
| 38 | + Ensuring an alternate alias for existing DATABASE... done, HEROKU_POSTGRESQL_COLOR |
| 39 | + Promoting HEROKU_POSTGRESQL_INSTANCE to DATABASE_URL on strange-bird-1234... done |
| 40 | + |
| 41 | +Add the ability to send email (i.e. Password Resets etc) |
| 42 | + |
| 43 | + $ heroku addons:create sendgrid:starter |
| 44 | + Creating SENDGRID_INSTANCE... done, (free) |
| 45 | + Adding SENDGRID_INSTANCE to strange-bird-1234... done |
| 46 | + Setting SENDGRID_PASSWORD, SENDGRID_USERNAME and restarting strange-bird-1234... done, v7 |
| 47 | + Use `heroku addons:docs sendgrid` to view documentation. |
| 48 | + |
| 49 | +Create a new branch for any configuration/setup changes needed |
| 50 | + |
| 51 | + $ git checkout -b production |
| 52 | + |
| 53 | +Store unique keys and salts in Heroku environment variables. Wordpress can provide random values [here](https://api.wordpress.org/secret-key/1.1/salt/). |
| 54 | + |
| 55 | + heroku config:set AUTH_KEY='put your unique phrase here' \ |
| 56 | + SECURE_AUTH_KEY='put your unique phrase here' \ |
| 57 | + LOGGED_IN_KEY='put your unique phrase here' \ |
| 58 | + NONCE_KEY='put your unique phrase here' \ |
| 59 | + AUTH_SALT='put your unique phrase here' \ |
| 60 | + SECURE_AUTH_SALT='put your unique phrase here' \ |
| 61 | + LOGGED_IN_SALT='put your unique phrase here' \ |
| 62 | + NONCE_SALT='put your unique phrase here' |
| 63 | + |
| 64 | +Deploy to Heroku |
| 65 | + |
| 66 | + $ git push heroku production:master |
| 67 | + -----> Deleting 0 files matching .slugignore patterns. |
| 68 | + -----> PHP app detected |
| 69 | + |
| 70 | + ! WARNING: No composer.json found. |
| 71 | + Using index.php to declare PHP applications is considered legacy |
| 72 | + functionality and may lead to unexpected behavior. |
| 73 | + |
| 74 | + -----> No runtime requirements in composer.json, defaulting to PHP 5.6.2. |
| 75 | + -----> Installing system packages... |
| 76 | + - PHP 5.6.2 |
| 77 | + - Apache 2.4.10 |
| 78 | + - Nginx 1.6.0 |
| 79 | + -----> Installing PHP extensions... |
| 80 | + - zend-opcache (automatic; bundled, using 'ext-zend-opcache.ini') |
| 81 | + -----> Installing dependencies... |
| 82 | + Composer version 1.0-dev (ffffab37a294f3383c812d0329623f0a4ba45387) 2014-11-05 06:04:18 |
| 83 | + Loading composer repositories with package information |
| 84 | + Installing dependencies |
| 85 | + Nothing to install or update |
| 86 | + Generating optimized autoload files |
| 87 | + -----> Preparing runtime environment... |
| 88 | + NOTICE: No Procfile, defaulting to 'web: vendor/bin/heroku-php-apache2' |
| 89 | + -----> Discovering process types |
| 90 | + Procfile declares types -> web |
| 91 | + |
| 92 | + -----> Compressing... done, 78.5MB |
| 93 | + -----> Launcing... done, v5 |
| 94 | + http://strange-bird-1234.herokuapp.com deployed to Heroku |
| 95 | + |
| 96 | + To git@heroku:strange-bird-1234.git |
| 97 | + * [new branch] production -> master |
| 98 | + |
| 99 | +After deployment WordPress has a few more steps to setup and thats it! |
| 100 | + |
| 101 | +## Usage |
| 102 | + |
| 103 | +Because a file cannot be written to Heroku's file system, updating and installing plugins or themes should be done locally and then pushed to Heroku. |
| 104 | + |
| 105 | +## Updating |
| 106 | + |
| 107 | +Updating your WordPress version is just a matter of merging the updates into |
| 108 | +the branch created from the installation. |
| 109 | + |
| 110 | + $ git pull # Get the latest |
| 111 | + |
| 112 | +Using the same branch name from our installation: |
| 113 | + |
| 114 | + $ git checkout production |
| 115 | + $ git merge master # Merge latest |
| 116 | + $ git push heroku production:master |
| 117 | + |
| 118 | +WordPress needs to update the database. After push, navigate to: |
| 119 | + |
| 120 | + http://your-app-url.herokuapp.com/wp-admin |
| 121 | + |
| 122 | +WordPress will prompt for updating the database. After that you'll be good |
| 123 | +to go. |
| 124 | + |
| 125 | +## Deployment optimisation |
| 126 | + |
| 127 | +If you have files that you want tracked in your repo, but do not need deploying (for example, *.md, *.pdf, *.zip). Then add path or linux file match to the `.slugignore` file & these will not be deployed. |
| 128 | + |
| 129 | +Examples: |
| 130 | +``` |
| 131 | +path/to/ignore/ |
| 132 | +bin/ |
| 133 | +*.md |
| 134 | +*.pdf |
| 135 | +*.zip |
| 136 | +``` |
0 commit comments