Wordpress Site and Pantheon
DRAFT
Here are some tips and tricks to using WordPress on Pantheon + Kalabox 2 & 1.
Migrating Old Site
Easiest way is to use the Duplicator plugin: https://wordpress.org/plugins/duplicator/
Also, follow Pantheon's article here: https://pantheon.io/blog/importing-your-wordpress-blog-pantheon
Note: Follow the articles lead and watch out for Large files, you may have to go back to exclude certain extensions or directories.
Settings for Duplicator are here: /admin.php?page=duplicator-settings&tab=general
Check PHP Version
Pantheon automagically select PHP 5.5, this can cause some problems like this fun error: Search and Replace WordPress URLs Failed. Probably need to change Pantheon down to 5.3.
If you don't have server level access on the old platform, install he Display PHP (It is old but still works on WP 4.2+). When you go to the landing page of the dashboard, it tell you your PHP version there.
IMPORTANT: CHECK FOR short_tag_open = on
Pantheon DOES NOT support this WP common setting. What this does is lets devs use <? instead of <?php. Check the config/php/php.ini and see if this is et to on. If it is you have to hunt a peck and replace all the <? with <?php, FUN!
PANTHEON PLUGINS REQUIRED
- https://wordpress.org/plugins/wp-native-php-sessions/ This is a must have, some modules will give you a WSOD due to session_start errors
PANTHEON GOING LIVE
- Talk about DNS CNAME stuff when it is a subdomain
Talk about changing the configs in wp-config.
Kalabox 2 Install
At the time of writing this, there was no WP app for KB2, just use the D7 app example.
- Remove the files from shares, drush + conf variables. You will have something like this:
{ "appName": "APPNAME", "appPlugins": [ "kalabox-plugin-dbenv", "kalabox-plugin-git", "kalabox-plugin-php", "kalabox-plugin-rsync" ], "shareIgnores": [ ".git" ], "pluginConf": { "kalabox-plugin-php": { "php-version": "5.3.29" }, "kalabox-plugin-git": { "git-username": "Your Name", "git-email": "YOURNAME@kalamuna.com" } }, "appComponents": { "appserver": { "image": { "name": "php-appserver", "srcRoot": ":appRoot:" }, "proxy": [ { "port": "80/tcp", "default": true } ] }, "db": { "image": { "name": "mariadb", "srcRoot": ":appRoot:" } } } }
2. After you install the app, do this with your Pantheon instance files. You can do this now add a wp-config-local.php file to your document root. (Pantheon's .gitignore will keep this from getting committed):
<?php // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'kalabox'); /** MySQL database username */ define('DB_USER', 'kalabox'); /** MySQL database password */ define('DB_PASSWORD', ''); /** MySQL hostname */ define('DB_HOST', 'mysite.kbox'); /** 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', ''); /** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each a unique * prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_'; // local URLs define('WP_HOME','http://mysite.kbox'); define('WP_SITEURL','http://mysite.kbox');
Kalabox 1 Install
Here is how to get WP to install on Kalabox
- Take a backup of the WP Pantheon Site
- in your /var/www do a git pull of the code
- cd /etc/kalastack/vhosts/sites-available
Create a file (call it the name of your site)
$ nano mysite
copy paste this in (replace MYSITE of course):
server { server_name MYSITE.kala; root /var/www/MYSITE; client_max_body_size 100M; fastcgi_read_timeout 1800; index index.php; # No reading git files location ~ /\.git { autoindex on; } # Protect /private (for private code) location ~ ^/private/ { return 403; } # Protect /sites/default/files/private (for private files) location ~ ^/sites/default/files/private/ { return 403; } # Protect /sites/default/config (for configuration) location ~ ^/sites/default/config/ { return 403; } location / { try_files $uri $uri/ @cleanurl; } location @cleanurl { rewrite ^/(.*)$ /index.php?q=$1 last; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/tmp/php-fpm.sock; } location ~ /\.ht { deny all; } }
Then:
$ ln -s /etc/kalastack/vhosts/sites-available/YOURSITE /etc/kalastack/vhosts/sites-enabled/YOURSITE $ sudo nano /etc/hosts add this: 127.0.0.1 NAMEOFSITE.kala $ sudo service nginx restart
You may need to add the site outside of your kalabox, repeat the steps above to edi the hosts file, but use ip 1.3.3.7
Now take the mysql dump, go to php.kala and create the DB with the name you put in the hosts file, ie MYSITE_kala, then import the site
- Add a wp-config-local.php file to your document root. (Pantheon's .gitignore will keep this from getting committed):
<?php // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'MYSITE_kala'); /** MySQL database username */ define('DB_USER', 'root'); /** MySQL database password */ define('DB_PASSWORD', 'password'); /** MySQL hostname */ define('DB_HOST', 'localhost'); /** 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', ''); /** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each a unique * prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_'; // local URLs define('WP_HOME','http://MYSITE.kala'); define('WP_SITEURL','http://MYSITE.kala');
Make sure the .gitignore contains the following:
# WordPress # ############ wp-config-local.php wp-content/uploads wp-content/blogs.dir/ wp-content/upgrade/ wp-content/backup-db/ wp-content/advanced-cache.php wp-content/wp-cache-config.php sitemap.xml sitemap.xml.gz *.log # @TODO writable paths wp-content/cache/ wp-content/backups/
Related articles