Inspired by jubalm's version
3. Deploying
{
"scripts": {
"post-install-cmd": [
"chmod -R 777 wp-content"
]
},
"extra": {
"heroku": {
"newrelic": "false",
"nginx-includes": ["nginx.conf"]
}
}
}
Do not bother with composer, do not make composer.lock
, only make composer.json
in app root with suggested contents.
# in /nginx.conf
index index.php;
location ~ /\. {
deny all;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
#OPTIONAL block below
client_max_body_size 100M;
#jetpack connection
fastcgi_buffers 8 32k;
fastcgi_buffer_size 64k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
# enable gzip compression
gzip on;
# Minimum file size in bytes (really small files aren’t worth compressing)
gzip_min_length 1000;
# Compression level, 1-9
gzip_comp_level 2;
gzip_buffers 4 32k;
gzip_types text/plain application/javascript text/xml text/css image/svg+xml;
# Insert `Vary: Accept-Encoding` header, as specified in HTTP1.1 protocol
gzip_vary on;
# in /Procfile
web: vendor/bin/heroku-php-nginx -C nginx.conf
Linking dokku app to db will set an envrionmental variable DATABASE_URL
to something like mysql://mariadb:2c82a31766b3bdcd@dokku-mariadb-blog:3306/blog
Use this single variable to set wp config.
Try a wp-config.php with this content (change the secret phrases a bit)
<?php
$url = parse_url(getenv('DATABASE_URL'));
define('DB_NAME', str_replace('/','',$url['path']));
define('DB_USER', $url['user']);
define('DB_PASSWORD', $url['pass']);
define('DB_HOST', $url['host'].":".$url['port']);
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
define('AUTH_KEY', 'c8M/}-ZU+GFsTQ])/Cb-+xV=3n#$}*v{y^t|m-zno?xSiiQjk:+u|~1{,m-;~4d-');
define('SECURE_AUTH_KEY', 'cyjMEY.L%O`LA^1o>?P_~qSdmZ_c@$O|``($*C~!2h`iG|]~QQKZkC,vt|3ofV]r');
define('LOGGED_IN_KEY', 'g|-qy;K!+W|S*5`rrhnq%J(yD)U`)wST63Dkz+&l-Uszx:;hDygnN.&`~ZR#>MM[');
define('NONCE_KEY', 'SlQ)4*Put{<(c],Z?;oWPbMC0Q9-I) ukHi]$)XO?/a1&J*sL./Xo3u#u%I:kVhn');
define('AUTH_SALT', 'lr@,Z&Y`4ykd{%b$*ds5w/+j64 mVQ2NS!`07om0Tiy,lT5-`Wp<~LLd$kH?aF[?');
define('SECURE_AUTH_SALT', '|+rEr-hi,E39o;*x^I:sdw;A<!@mm ]G3gWw+J#kw,vcEH<! y7K(Brw}<iJUu5H');
define('LOGGED_IN_SALT', '[kq(@!>>Eg1 ~~IwLzkh,!6N-8Jc<s9<eq?.9Tizx/BOqYx%7tA=pi3GS8|~4=$`');
define('NONCE_SALT', ' 5@t( 25Op#DfC1c9ilvgj T$Vn@EfX;f<7ov;nNJ %T.X+Vl#s|0t(ODemft1>U');
$table_prefix = 'wp_';
define('WP_DEBUG', false);
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');
Install the official MariaDB plugin
dokku plugin:install https://github.com/dokku/dokku-mariadb.git mariadb
git clone https://github.com/CreativeGS/creative_wordpress_template.git blog
dokku apps:create blog
dokku mariadb:create blog
dokku mariadb:link blog blog
cat ~/.ssh/id_rsa.pub | ssh root@<IP> "sudo sshcommand acl-add dokku <key name>"
# e.g.
cat ~/.ssh/id_rsa.pub | ssh [email protected] "sudo sshcommand acl-add dokku deployer"
git remote rm dokku
git remote add dokku [email protected]:blog
# or via IP
git remote add dokku [email protected]:blog
git push dokku dokku:master
# 0. remove wrong existing options
dokku docker-options blog
dokku docker-options:remove blog deploy,run "-v /home/dokku/persistance/blog/wp-content:/app/wp-content"
# 1. make a persistance folder in dokku root
mkdir /home/dokku/persistance/blog
# 2. define the linking option, both on deploy and run phases
dokku docker-options:add blog deploy,run "-v /home/dokku/persistance/blog/uploads:/app/wp-content/uploads"
in /home/dokku/blog/VHOST
blog.blogs2.creative.gs
blog.example.com
PHP NewRelic comes as a debian package. Use dokku-apt plugin to manage those.
newrelic-daemon, newrelic-php5-common, and newrelic-php5
https://download.newrelic.com/debian/dists/newrelic/non-free/binary-amd64/
See the installation documentation if links are broken.
You must also rename the packages, so they are executed in specific order:
- newrelic-php-common
- newrelic-daemon
- newrelic-php
This file controlls the configuration of package installation.
It must contain two lines, one for configuring the app name, the other for the license.
newrelic-php5 newrelic-php5/application-name string "<app name>"
newrelic-php5 newrelic-php5/license-key string "<newrelic license key>"
e.g.
newrelic-php5 newrelic-php5/application-name string "test blog"
newrelic-php5 newrelic-php5/license-key string "1ae8e02b0d25axce858201g14f6946fe6d97ba1f"
dokku plugin:install https://github.com/F4-Group/dokku-apt
While deploying, dokku-apt should be verbose about the packages it installed.
After deploy enter the container
# get containers by running `sudo docker ps`
sudo docker run -it dokku/wp:latest /bin/bash
And run
$ /etc/init.d/newrelic-daemon start
#=> New Relic Daemon: newrelic-daemon already running
NB, unfortunately neither ps aux or other process debuggers will show the daemon as running.
PHP Buildpack issue, downgrade to stable version Unconfirmed, v102 also fixes
# per app, recommended
dokku config:set <app> BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php.git#v95
# global, may break things
dokku config:set --global BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php.git#v95
Replace root index.php with
<?php
phpinfo();
?>
Consult nginx templating docs
Create a nginx.conf.sigil
file in app root for dokku to pick up when building container nginx
Populate the file with basic template
Add a client_max_body_size 100M;
line in the server
block or top level if it is absent
Use .user.ini
as suggested in heroku docs
Root level .user.ini
will set "local" value for all app
extension=gd.so
memory_limit=256M
Delete the plugin from /var/lib/dokku/plugins
.
Consult this thread
Consult documentation