CentOS Upgrade
Contents
Upgrade from CentOS 6 to CentOS 7
Desire to upgrade aging CentOS 6 vm to CentOS 7
- SSL all the things
- mediawiki current versions wanted newer PHP version
- Implement VisualEditor which is very cool.
- implement virtual domain / email accounts
- Administer with postfixadmin
- SSL secure
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
Moving the email
Email on the current, soon to be old CentOS 6 server, host0.redacted.net, is in unix passwd Mbox format. The new CentOS 7 server, host1.redacted.net, is in Maildir format. dediserve0 has multiple ~ thirteen (13) email addresses in the Mbox by nature of the postfix main.cf mydestination configuration setting. I want them all into separate virtual mailboxes on dediserve1.
IMAP sync utilities
- dsync - Dovecot's mailbox synchronization utility (is there a more official man page say at dovecot?)
- imapsync on github with recent activity (four months)
Preparation for moving email
- purge unneeded messages in folders
- deleted-messages
- spam
- Create new maiboxes on new server
- imapsync ...
- Change MX records
- imapsync again for a few days until MX record change propagates.
#!/bin/sh
# jha 1/24/2018
# getting ready for the big move! :-)
# Testing syntax...
#
# --justfolders make the folders on remote but no msg sync
# --dry dry run (test)
#
imapsync --host1 dediserve0.jhalbrecht.net --user1 sampson --password1 'poit' \
--search1 'TO "sampson@jeffa.org"' \
--host2 dediserve1.jhalbrecht.net --user2 sampson@jeffa.org--password2 'bonk' \
--automap --delete1 --noexpungeaftereach
Software Considerations
- IUS Community Project Inline with Upstream Stable php56u
- nodejs from node.js repositories
AutoMySQLBackup
Automate mysqldump with daily, weekly etc. rotatins... Download AutoMySQLBackup from SourceForge.
# Add this line to myserver.conf to eliminate "mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user" errors
CONFIG_db_exclude=( 'information_schema' 'performance_schema')
# typical crontab
/usr/local/bin/automysqlbackup /etc/automysqlbackup/myserver.conf
Build bacula from source for compatibility with my bacula[-fd|-sd|-dir] server
groupadd useradd -r -s /sbin/nologin -d /var/spool/bacula -M -c 'Bacula Backup System' bacula
groupadd -r bacula
[root@dediserve1 systemd]# systemctl cat bacula-fd
# /etc/systemd/system/bacula-fd.service
[Unit]
Description=Bacula-FileDaemon, a Backup-client
Documentation=man:bacula-fd(8)
After=network.target nss-lookup.target
[Service]
Environment=CONFIG=/etc/bacula/bacula-fd.conf
EnvironmentFile=-/etc/sysconfig/bacula-fd
ExecStart=/usr/sbin/bacula-fd -f $OPTS -c $CONFIG -u $FD_USER -g $FD_GROUP
IOSchedulingClass=idle
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@dediserve1 systemd]#
MediaWiki Move
upgrade and move
- upgrade php to allow mediawiki upgrade
- upgrade mediawik to allow for contact page, VisualEditor etc...
- Implement short URLs for better SEO and they're pretty.
Backup and restore
Backup db on oldwiki, restore on newwiki Note; many tutorials get the syntax wrong for the restore -p to mysql invokes a password prompt. Use the --password form from the command line except that can leave your user credentials in the shell history. Execute from a .sh script.
[root@oldwiki]# mysqldump --user=thewikidbuser --password=poit thewikidbname > nameforbackup.sql
[root@oldwiki]# cd images
[root@oldwiki]# tar cvf wikiimages.tar *
[root@oldwiki]# scp, ftp or whatever to the new site the .tar and .sql files
[root@newwiki]# cd images
[root@newwiki]# tar xf wikiimages.tar
# edit your nameforbackup.sql file placing "use thewikidbname;" at top.
[root@newwiki]# mysql -u thewikidbuser --password=poit < nameforbackup.sql
[root@newwiki]# cd maintenance
[root@newwiki]# ./update.php
current soon to be old wiki version info
Installed software
Product Version
MediaWiki 1.21.1
PHP 5.3.3 (apache2handler)
MySQL 5.1.73
Entry point URLs
Entry point URL
Article path /wiki/index.php/$1
Script path /wiki
index.php /wiki/index.php
api.php /wiki/api.php
load.php /wiki/load.php
Installed extensions
Special pages
ContactPage (Version 2.2) Contact form for visitors Daniel Kinzler and Sam Reed
Renameuser Adds a special page to rename a user (need renameuser right) Ævar Arnfjörð Bjarmason and Aaron Schulz
Parser hooks
ParserFunctions (Version 1.5.1) Enhance parser with logical functions Tim Starling, Robert Rohde, Ross McClure and Juraj Simlovic
SyntaxHighlight (Version 1.0.8.11) Provides syntax highlighting <syntaxhighlight> using GeSHi - Generic Syntax Highlighter Brion Vibber, Tim Starling, Rob Church and Niklas Laxström
Media handlers
PDF Handler Handler for viewing PDF files in image mode. Martin Seidel and Mike Połtyn
Other
Gadgets Lets users select custom CSS and JavaScript gadgets in their preferences Daniel Kinzler and Max Semenik
WikiEditor (Version 0.3.1) Provides an extendable wikitext editing interface and many feature-providing modules Trevor Parscal, Roan Kattouw, Nimish Gautam and Adam Miller
Parser extension tags
<gallery>, <nowiki>, <pre>, <source> and <syntaxhighlight>
Parser function hooks
anchorencode, basepagename, basepagenamee, canonicalurl, canonicalurle, defaultsort, displaytitle, expr, filepath, formatdate, formatnum, fullpagename, fullpagenamee, fullurl, fullurle, gender, grammar, if, ifeq, iferror, ifexist, ifexpr, int, language, lc, lcfirst, localurl, localurle, namespace, namespacee, namespacenumber, ns, nse, numberingroup, numberofactiveusers, numberofadmins, numberofarticles, numberofedits, numberoffiles, numberofpages, numberofusers, numberofviews, padleft, padright, pagename, pagenamee, pagesincategory, pagesize, plural, protectionlevel, rel2abs, special, speciale, subjectpagename, subjectpagenamee, subjectspace, subjectspacee, subpagename, subpagenamee, switch, tag, talkpagename, talkpagenamee, talkspace, talkspacee, time, timel, titleparts, uc, ucfirst and urlencode
New server version info
Installed software
Product Version
MediaWiki 1.30.0
PHP 5.6.33 (apache2handler)
MariaDB 5.5.56-MariaDB
ICU 50.1.2
Entry point URLs
Entry point URL
Article path /wiki/$1
Script path /w
index.php /w/index.php
api.php /w/api.php
load.php /w/load.php
Installed skins
Skin Version License Description Authors
Cologne Blue – GPL-2.0+ A lightweight skin with minimal formatting Lee Daniel Crocker and others
Modern – GPL-2.0+ A blue/gray theme with sidebar and top bar. Derived from MonoBook River Tarnell and others
MonoBook – GPL-2.0+ The classic MediaWiki skin since 2004, named after the black-and-white photo of a book in the page background Gabriel Wicke and others
Vector – GPL-2.0+ Modern version of MonoBook with fresh look and many usability improvements Trevor Parscal, Roan Kattouw and others
Installed extensions
Special pages
Extension Version License Description Authors
CiteThisPage – GPL-2.0+ Adds a citation special page and toolbox link Ævar Arnfjörð Bjarmason and James D. Forrester
Interwiki 3.1 20160307 GPL-2.0+ Adds a special page to view and edit the interwiki table Stephanie Amanda Stevens, Alexandre Emsenhuber, Robin Pepermans, Siebrand Mazeland, Platonides, Raimond Spekking, Sam Reed, Jack Phoenix, Calimonius the Estrange and others
Parser hooks
Extension Version License Description Authors
Cite – GPL-2.0+ Adds <ref[ name=id]> and <references/> tags, for citations Ævar Arnfjörð Bjarmason, Andrew Garrett, Brion Vibber, Ed Sanders, Marius Hoch, Steve Sanbeg, Trevor Parscal and others
ImageMap – GPL-2.0+ Allows client-side clickable image maps using <imagemap> tag Tim Starling
ParserFunctions 1.6.0 GPL-2.0+ Enhance parser with logical functions Tim Starling, Robert Rohde, Ross McClure and Juraj Simlovic
Poem – CC0-1.0 Adds <poem> tag for poem formatting Nikola Smolenski, Brion Vibber and Steve Sanbeg
SyntaxHighlight 2.0 GPL-2.0+ Provides syntax highlighting <syntaxhighlight> using Pygments - Python syntax highlighter Brion Vibber, Tim Starling, Rob Church, Niklas Laxström, Ori Livneh and Ed Sanders
Media handlers
Extension Version License Description Authors
PDF Handler – GPL-2.0+ Handler for viewing PDF files in image mode Martin Seidel and Mike Połtyn
Other
Extension Version License Description Authors
Gadgets – GPL-2.0+ Lets users select custom CSS and JavaScript gadgets in their preferences Daniel Kinzler and Max Semenik
VisualEditor 0.1.0 (61f161a) 11:07, 2 October 2017 MIT Visual editor for MediaWiki Alex Monk, Bartosz Dziewoński, Christian Williams, Ed Sanders, Inez Korczyński, James D. Forrester, Moriel Schottlender, Roan Kattouw, Rob Moen, Timo Tijhof, Trevor Parscal, C. Scott Ananian and others
WikiEditor 0.5.1 GPL-2.0+ Provides an extendable wikitext editing interface and many feature-providing modules Derk-Jan Hartman, Trevor Parscal, Roan Kattouw, Nimish Gautam and Adam Miller
Installed libraries
Library Version License Description Authors
composer/semver 1.4.2 MIT Semver library that offers utilities, version constraint parsing and validation. Nils Adermann, Jordi Boggiano and Rob Bast
cssjanus/cssjanus 1.2.0 Apache-2.0 Convert CSS stylesheets between left-to-right and right-to-left.
firebase/php-jwt 4.0.0 BSD-3-Clause A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec. Neuman Vong and Anant Narayanan
james-heinrich/getid3 1.9.14 GPL PHP script that extracts useful information from popular multimedia file formats
justinrainbow/json-schema 5.2.1 MIT A library to validate a json schema. Bruno Prieto Reis, Justin Rainbow, Igor Wiedler and Robert Schönthal
liuggio/statsd-php-client 1.0.18 MIT Statsd (Object Oriented) client library for PHP Giulio De Donato
mediawiki/at-ease 1.1.0 GPL-2.0+ Safe replacement to @ for suppressing warnings. Tim Starling and MediaWiki developers
monolog/monolog 1.22.1 MIT Sends your logs to files, sockets, inboxes, databases and various web services Jordi Boggiano
mustangostang/spyc 0.6.2 MIT A simple YAML loader/dumper class for PHP mustangostang
nmred/kafka-php 0.1.5 BSD-3-Clause Kafka client for php
oojs/oojs-ui 0.23.0 MIT Provides library of common widgets, layouts, and windows. Timo Tijhof, Bartosz Dziewoński, Ed Sanders, James D. Forrester, Kirsten Menger-Anderson, Rob Moen, Roan Kattouw, Trevor Parscal, Kunal Mehta and Prateek Saxena
oyejorge/less.php 1.7.0.14 Apache-2.0 PHP port of the Javascript version of LESS http://lesscss.org (Originally maintained by Josh Schmidt) Matt Agar, Martin Jantošovič and Josh Schmidt
pear/console_getopt 1.4.1 BSD-2-Clause More info available on: http://pear.php.net/package/Console_Getopt Greg Beaver, Andrei Zmievski and Stig Bakken
pear/mail 1.4.1 BSD-2-Clause Class that provides multiple interfaces for sending emails. Chuck Hagenbuch, Richard Heyes and Aleksander Machniak
pear/mail_mime 1.10.1 BSD-3-clause Mail_Mime provides classes to create MIME messages Cipriano Groenendal and Aleksander Machniak
pear/mail_mime-decode 1.5.5.2 BSD-2-Clause More info available on: http://pear.php.net/package/Mail_mimeDecode Cipriano Groenendal and Aleksander Machniak
pear/net_smtp 1.7.3 PHP-3.01 An implementation of the SMTP protocol Jon Parise and Chuck Hagenbuch
pear/net_socket 1.2.1 BSD-2-Clause More info available on: http://pear.php.net/package/Net_Socket Chuck Hagenbuch, Aleksander Machniak and Stig Bakken
pear/pear-core-minimal 1.10.3 BSD-3-Clause Minimal set of PEAR core files to be used as composer dependency Christian Weiske
pear/pear_exception 1.0.0 BSD-2-Clause The PEAR Exception base class. Helgi Thormar and Greg Beaver
pimple/pimple 3.0.2 MIT Pimple, a simple Dependency Injection Container Fabien Potencier
psr/log 1.0.2 MIT Common interface for logging libraries PHP-FIG
ruflin/elastica 5.1.0 MIT Elasticsearch Client Nicolas Ruflin
stil/gd-text 1.0.0 MIT A class drawing multiline and aligned text on pictures. Uses GD extension.
symfony/process 3.2.6 MIT Symfony Process Component Fabien Potencier and Symfony Community
wikimedia/assert 0.2.2 MIT Provides runtime assertions Daniel Kinzler
wikimedia/avro 1.7.7 Apache-2.0 A library for using Apache Avro with PHP. Michael Glaesemann, Andy Wick, Saleem Shafi, A B, Doug Cutting and Tom White
wikimedia/base-convert 1.0.1 GPL-2.0+ Convert an arbitrarily-long string from one numeric base to another, optionally zero-padding to a minimum column width. Brion Vibber and Tyler Romeo
wikimedia/cdb 1.4.1 GPL-2.0+ Constant Database (CDB) wrapper library for PHP. Provides pure-PHP fallback when dba_* functions are absent. Daniel Kinzler, Tim Starling, Chad Horohoe and Ori Livneh
wikimedia/cldr-plural-rule-parser 1.0.0 GPL-2.0+ Evaluates plural rules specified in the CLDR project notation. Tim Starling and Niklas Laxström
wikimedia/composer-merge-plugin 1.4.1 MIT Composer plugin to merge multiple composer.json files Bryan Davis
wikimedia/css-sanitizer 1.0.2 Apache-2.0 Classes to parse and sanitize CSS Brad Jorsch
wikimedia/html-formatter 1.0.1 GPL-2.0+ Performs transformations of HTML by wrapping around libxml2 and working around its countless bugs. MediaWiki contributors
wikimedia/ip-set 1.1.0 GPL-2.0+ Efficiently match IP addresses against a set of CIDR specifications. Brandon Black
wikimedia/php-session-serializer 1.0.4 GPL-2.0+ Provides methods like PHP's session_encode and session_decode that don't mess with $_SESSION Brad Jorsch
wikimedia/purtle 1.0.6 GPL-2.0+ Fast streaming RDF serializer Daniel Kinzler, Thiemo Mättig and Stanislav Malyshev
wikimedia/relpath 2.0.0 MIT Compute a relative filepath between two paths. Ori Livneh
wikimedia/remex-html 1.0.1 MIT Fast HTML 5 parser Tim Starling
wikimedia/running-stat 1.1.0 GPL-2.0+ PHP implementations of online statistical algorithms Ori Livneh
wikimedia/scoped-callback 1.0.0 GPL-2.0+ Class for asserting that a callback happens when a dummy object leaves scope Aaron Schulz
wikimedia/testing-access-wrapper 1.0.0 GPL-2.0+ A simple helper class to access non-public elements of a class when testing. Adam Roses Wight, Brad Jorsch and Gergő Tisza
wikimedia/textcat 1.2.0 LGPL-2.1 PHP port of the TextCat language guesser utility, see http://odur.let.rug.nl/~vannoord/TextCat/. Stanislav Malyshev and Trey Jones
wikimedia/timestamp 1.0.0 GPL-2.0+ Creation, parsing, and conversion of timestamps Tyler Romeo
wikimedia/utfnormal 1.1.0 GPL-2.0+ Contains Unicode normalization routines, including both pure PHP implementations and automatic use of the 'intl' PHP extension when present Brion Vibber
wikimedia/wait-condition-loop 1.0.1 GPL-2.0+ Wait loop that reaches a condition or times out Aaron Schulz
wikimedia/wrappedstring 2.2.0 MIT Automatically compact sequentially-outputted strings that share a common prefix / suffix pair. Timo Tijhof
zordius/lightncandy 0.23 MIT An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ). Zordius Chen
Parser extension tags
<gallery>, <imagemap>, <indicator>, <nowiki>, <poem>, <pre>, <ref>, <references>, <source> and <syntaxhighlight>
Parser function hooks
anchorencode, basepagename, basepagenamee, bidi, canonicalurl, canonicalurle, cascadingsources, defaultsort, displaytitle, expr, filepath, formatdate, formatnum, fullpagename, fullpagenamee, fullurl, fullurle, gender, grammar, if, ifeq, iferror, ifexist, ifexpr, int, language, lc, lcfirst, localurl, localurle, namespace, namespacee, namespacenumber, ns, nse, numberingroup, numberofactiveusers, numberofadmins, numberofarticles, numberofedits, numberoffiles, numberofpages, numberofusers, padleft, padright, pageid, pagename, pagenamee, pagesincategory, pagesize, plural, protectionexpiry, protectionlevel, rel2abs, revisionday, revisionday2, revisionid, revisionmonth, revisionmonth1, revisiontimestamp, revisionuser, revisionyear, rootpagename, rootpagenamee, special, speciale, subjectpagename, subjectpagenamee, subjectspace, subjectspacee, subpagename, subpagenamee, switch, tag, talkpagename, talkpagenamee, talkspace, talkspacee, time, timel, titleparts, uc, ucfirst and urlencode
Wordpress Move
Utilities
wp-cli
wp-cli Where have you been all my life? Gee hate to revert to marketeering speak but it is a must have!
vhost...conf
For .htaccess to work be sure to AllowOverride All in your wordpress site vhost...conf file(s).
DocumentRoot /var/www/example.com
# [...]
<Directory /var/www/example.com>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Procedure with wp-cli
On new server cd to vhost root and download wordpress. wp core download
You can run commands from a some.sh script file under the permission of the web user / group su -s /bin/bash -c ./a webrw
this keeps your credentials out of the bash history and keeps permissions you'll run the site under
$ mysql -u adminusername -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname" IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> EXIT
Bye
$
wp core config --dbname=databasename --dbuser=wordpressusername --dbpass=password
On your old server wp db export /tmp/yourblogname.sql
and copy to your new vm server host
On your new vm server switch to new vhost root and restore db. wp will use the permissions in the newly created config. wp db import /tmp/yourblogname.sql
You may find this helpful wp search-replace "http://oldurl.com" "https://newurl.com"
YMMV
On the old server cd to your wp-content tar cvf oldcontent.tar *
copy that .tar file to your new server and tar xf oldcontent.tar
from the wp-content directory.
Run wp-cli as server user
You can run wp-cli as the owner of the web site. I used this syntax when upgrading to https. Test it with --dry-run and remove when you're ready to actually do it.
[root@thehost thesite]# sudo -u webrw -s -- <<EOF
/usr/local/bin/wp search-replace 'http://www.thesite.com' 'https://www.thesite.com' --dry-run
echo
EOF
[root@thehost thesite]#