Can Yildirim's Blog

Publish Wordpress with Heroku app

March 01, 2016

1. Download Wordpress

Download wordpress to local.

curl -sS https://wordpress.org/latest.zip > wordpress.zip // if cannot unzip wordpress.zip cd wordpress touch Procfile touch composer.json touch ngnix.conf mv wp-config-sample.php wp-config.php

2. Configuration

Add below line to Procfile contains config parameter.

web: vendor/bin/heroku-hhvm-nginx -C nginx.conf

Add to composer.json that

{ "name": "can/heroku-wp", "description": "A template for installing and running WordPress on Heroku", "license": "MIT", "repositories":{ "packagist":{ "type":"composer", "url":"http://wpackagist.org" } }, "require": { "hhvm": "~3.2" }, "extra": { "heroku": { "php-config": \[ "post\_max\_size=200M" \], "nginx-includes": \["nginx.conf"\] } } }

And ngnix.conf

location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?q=$uri&$args; }

And finally wp-config.php

// \*\* MySQL settings - You can get this info from your web host \*\* // $url = parse\_url(getenv('DATABASE\_URL') ? getenv('DATABASE\_URL') : getenv('CLEARDB\_DATABASE\_URL')); /\*\* The name of the database for WordPress \*/ define('DB\_NAME', trim($url\['path'\], '/')); /\*\* MySQL database username \*/ define('DB\_USER', $url\['user'\]); /\*\* MySQL database password \*/ define('DB\_PASSWORD', $url\['pass'\]); /\*\* MySQL hostname \*/ define('DB\_HOST', $url\['host'\]); /\*\* Database Charset to use in creating database tables. \*/ define('DB\_CHARSET', 'utf8'); /\*\* The Database Collate type. Don't change this if in doubt. \*/ define('DB\_COLLATE', '');   define('AUTH\_KEY', getenv('AUTH\_KEY')); define('SECURE\_AUTH\_KEY', getenv('SECURE\_AUTH\_KEY')); define('LOGGED\_IN\_KEY', getenv('LOGGED\_IN\_KEY')); define('NONCE\_KEY', getenv('NONCE\_KEY')); define('AUTH\_SALT', getenv('AUTH\_SALT')); define('SECURE\_AUTH\_SALT', getenv('SECURE\_AUTH\_SALT')); define('LOGGED\_IN\_SALT', getenv('LOGGED\_IN\_SALT')); define('NONCE\_SALT', getenv('NONCE\_SALT'));

3. Push & Deploy

Git init & attach addon

composer update --ignore-platform-reqs #generated composer.lock file git init git add . git commit -m "initial commit" heroku create # do not forget login with "heroku login" command heroku addons:create cleardb heroku addons:create sendgrid

Add env variables

heroku config:set AUTH\_KEY\='' heroku config:set SECURE\_AUTH\_KEY\='' heroku config:set LOGGED\_IN\_KEY\='' heroku config:set NONCE\_KEY\='' heroku config:set AUTH\_SALT\='' heroku config:set SECURE\_AUTH\_SALT\='' heroku config:set LOGGED\_IN\_SALT\='' heroku config:set NONCE\_SALT\=''

Push & open your page

git push heroku master # it will check & deploy your code heroku open # it will open page on browser

 And your wordpress is ready !!!

 

I imporved and addded some tips K.Sylvestre’s blog post and create this post.


Can Yildirim

Written by Can Yildirim who lives in London. Full Stack Software Engineer. Follow me on Twitter Linkedin

© 2023,