WordPress configurations for Heroku
Starting…
Download the last version of wordpress, then create a directory called “wordpress” (or anything you want else to call it) and extract the content of the zip to the directory.
WordPress Configuration
Jump to your directory and create the Procfile with this line
[cce]
web: vendor/bin/heroku-php-apache2 /
[/cce]
Add a file for composer, named composer.json
[cce_php]
{
“name” : “WordPress”,
“require” : {
“php” : “>=5.3.3”,
“ext-mbstring” : “*”
}
}
[/cce_php]
Edit the wp-config.php file and replace the first lines with
[cce_php]
$db = parse_url(getenv(‘CLEARDB_DATABASE_URL’));
define(‘DB_NAME’, str_replace(‘/’, ”, $db[‘path’]));
define(‘DB_USER’, $db[‘user’]);
define(‘DB_PASSWORD’, $db[‘pass’]);
define(‘DB_HOST’, $db[‘host’]);
define(‘AUTH_KEY’, ‘{%AUTH_KEY%}’);
define(‘SECURE_AUTH_KEY’, ‘{%SECURE_AUTH_KEY%}’);
define(‘LOGGED_IN_KEY’, ‘{%LOGGED_IN_KEY%}’);
define(‘NONCE_KEY’, ‘{%NONCE_KEY%}’);
define(‘AUTH_SALT’, ‘{%AUTH_SALT%}’);
define(‘SECURE_AUTH_SALT’, ‘{%SECURE_AUTH_SALT%}’);
define(‘LOGGED_IN_SALT’, ‘{%LOGGED_IN_SALT%}’);
define(‘NONCE_SALT’, ‘{%NONCE_SALT%}’);
[/cce_php]
Git repository
[cce_bash]
$ git init
Initialized empty Git repository
$ echo “/wp-content/plugins/” >> .gitignore
$ echo “/wp-content/themes/” >> .gitignore
$ git add .
$ git commit -am ‘First commit’
[master (root-commit) 83b5792] First commit
1014 files changed, 384288 insertions(+)
create mode 100644 .gitignore
….
create mode 100644 xmlrpc.php
[/cce_bash]
Configure Heroku
Create an App with heroku toolbelt setting up the app name my-wordpress-app and the region eu
[cce_bash]
$ heroku apps:create –region eu my-wordpress-app
[/cce_bash]
Database
Creating the database, this will create a free cleardb on heroku and add the system variable CLEARDB_DATABASE_URL:
[cce_bash]
$ heroku addons:create cleardb:ignite
Creating giving-gently-8505… done, (free)
Adding giving-gently-8505 to my-wordpress-app… done
Setting CLEARDB_DATABASE_URL and restarting my-wordpress-app… done, v3
Use heroku addons:docs cleardb
to view documentation.
[/cce_bash]
The Deploy
[cce_bash]
git push heroku master
Counting objects: 1101, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1079/1079), done.
Writing objects: 100% (1101/1101), 4.61 MiB | 282.00 KiB/s, done.
Total 1101 (delta 63), reused 0 (delta 0)
remote: Compressing source files… done.
remote: Building source:
remote:
remote: —–> PHP app detected
remote: —–> Resolved composer.json requirement for PHP to version 5.6.11.
remote: —–> Installing system packages…
remote: – PHP 5.6.11
remote: – Apache 2.4.10
remote: – Nginx 1.6.0
remote: —–> Installing PHP extensions…
remote: – mbstring (composer.json; bundled)
remote: – zend-opcache (automatic; bundled)
remote: —–> Installing dependencies…
remote: Composer version 1.0.0-alpha10 2015-04-14 21:18:51
remote: Loading composer repositories with package information
remote: Installing dependencies
remote: Nothing to install or update
remote: Writing lock file
remote: Generating optimized autoload files
remote: —–> Preparing runtime environment…
remote: —–> Discovering process types
remote: Procfile declares types -> web
remote:
remote: —–> Compressing… done, 77.0MB
remote: —–> Launching… done, v4
remote: https://my-wordpress-app.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy… done.
To https://git.heroku.com/my-wordpress-app.git
83b2946..4274dc2 master -> master
[/cce_bash]
Finally, load your website and finish the wordpress configurations.
I hope it was usefull.