This answer presumes you're willing to maintain MediaWiki yourself from now on.
Also, it will install MediaWiki in the real document root of your web server. Previously, that will have been an alias, and the real installation path will have been under /var/lib/mediawiki
, but as it's now up to you to maintain it instead of the Debian/Ubuntu maintainers, it's simplest to put it under its real path.
In this answer, the website's document root is /srv/apache2/public_html
and the location of the wiki on the web server is /wiki
(e.g. http://myserver/wiki
), making the full path /srv/apache2/public_html/wiki
. You'll need to adapt these paths to fit your own setup.
Download the latest MediaWiki and unpack it directly to the path it should have on your web server.
wget https://releases.wikimedia.org/mediawiki/1.26/mediawiki-1.26.2.tar.gz
tar xvf mediawiki-1.26.2.tar.gz
mv mediawiki-1.26.2 /srv/apache2/public_html/wiki
cd /srv/apache2/public_html/wiki
chown -R www-data:www-data .
Edit the file LocalSettings.php
and change the settingMW_INSTALL_PATH
from /var/lib/mediawiki
to the new path.
Do the same in the file /etc/apache2/conf-available/mediawiki.conf
If you uploaded any images to your wiki, you'll have an images
directory in /var/lib/mediawiki
. Copy it to the new installation directory:
cp -a /var/lib/mediawiki/images .
You'll find that several of the PHP packages that MediaWiki relies on aren't installed for PHP 7, which is the new standard PHP version for Ubuntu 16.04. MediaWiki works fine with PHP 7, but you need to install these packages manually and enable them:
apt-get install libapache2-mod-php7.0 php-apcu php-gd php-json php-mysql php-xml
phpenmod apcu gd json pdo_mysql dom
a2enmod php7.0
a2enconf mediawiki
I used APC for caching, and I found that MediaWiki uses the traditional APC module, which isn't included with PHP 7. I fixed this by using the APCu module instead. In MediaWiki's code, replace apc_*
calls with apcu_*
calls:
sed -i 's/apc_/apcu_/g' includes/libs/objectcache/APCBagOStuff.php
sed -i 's/apc_/apcu_/g' includes/objectcache/ObjectCache.php
Run the upgrade script to update MediaWiki's database structure:
cd maintenance/
php update.php
If the database user you use for the wiki doesn't have the permissions to modify the database structure, the script will fail. Use the script's --dbuser
and --dbpass
options to supply a MySQL user with more privileges. If you have an AdminSettings.php
file, use the details in there -- MediaWiki no longer reads this file itself, and you should delete this file from now on.
Now it should be possible to restart Apache and see your wiki on your website:
service apache2 restart
One last problem I had appeared when visiting my wiki: MediaWiki 1.25+ disabled skin auto-discovery and I was told to add an explicit wfLoadSkin( 'Vector' );
to my LocalSettings.php
.