[:en]Switch wordpress installation from ubuntu repositories to official version[:]

[:en]Installing WordPress on current Ubuntu versions is reasonably easy when using the repositories. There is, however, one drawback to using the repos: The wordpress version you will get tends to be somewhat out of date and some plugins may refuse to work with it. Regarding security updates, I guess it boils down to whom you trust more: the WordPress developers or the Ubuntu repository maintainers. As for me, I found that after upgrading Ubuntu to 14.04 the wordpress version I got was pre-4.0 and I wanted 4.0 at least. I could have apt-get remove wordpress, but I didn’t want to lose my existing configuration. So I had to find out how to switch from the Ubuntu version out of the repositories to the official WordPress release. Luckily, there is an easy mechanism one can use: WordPress can update itself via the dashboard. Unfortunately, this functionality is disabled in a default Ubuntu installation. Note, that there is a good reason for that: The Ubuntu package manager will not be aware of any updates installed without its help. This may lead to inconsistencies, when wordpress and apt are both trying to keep the installation up-to-date. There are three issues to be resolved in order to switch to the official WordPress release:

  1. Re-enable the built-in WordPress update system
  2. Change file permissions, so that WordPress can update itself
  3. Unregister the wordpress package from the package manager

Re-enable the built-in WordPress update system

It took me a while to find out, but actually this is rather easy. Just make sure that the PHP-Variable WP_CORE_UPDATE is set to true. Either in wp-config.php or in /etc/wordpress/config-$YOURDOMAINNAME.php, make sure the following line exists and is set to true:

define('WP_CORE_UPDATE', true);

 Change file permissions, so that WordPress can update itself

This is a more complicated step, unfortunately. The easiest way forward is to give file-ownership of the entire wordpress installation to the webserver-user. There is a small stumbling block hidden there: Some of the files in the Ubuntu wordpress installation are actually symlinks to files in other packages. On my server, this was the case for the following files:

/usr/share/wordpress/wp-includes/js/crop/cropper.css
/usr/share/wordpress/wp-includes/js/crop/cropper.js
/usr/share/wordpress/wp-includes/js/crop/marqueeHoriz.gif
/usr/share/wordpress/wp-includes/js/crop/marqueeVert.gif
/usr/share/wordpress/wp-includes/class-phpmailer.php
/usr/share/wordpress/wp-includes/class-smtp.php
/usr/share/wordpress/wp-includes/class-snoopy.php

You can find out which files are symlinks (and which files they link to) with the following command:

find /usr/share/wordpress/wp-includes/ -type l -exec ls -l \{\} \;

The symlinks should be replaced with the real files to avoid clobbering files from unrelated packages. Just remove the symlinks and copy the real files in their place. Afterwards, the following command will grant ownership of the entire wordpress installation to the webserver-user („www-data“):

chown www-data /usr/share/wordpress -R

Note, that allowing access for www-data may be a security problem. Either switch ownership of the installation before and after each update (i.e., back to root, once the update is complete), or look for a more secure solution. Once file ownership has been adjusted, you can log in to WordPress, and the dashboard should indicate the latest update and ask you to install it. Voila – you are now on the bleeding edge :) There is one final step to perform, though:

Unregister the wordpress package from the package manager

This is necessary, as otherwise you would run the risk of having the Ubuntu package manager inadvertently downgrade your wordpress installation, again. The tricky thing here is, that the package manager should forget about the package, but not remove any file. This seems to be an unsupported operation in the Debian package system. Effectively, it seems you have to edit a file by hand (heed the warnings in the chosen solution there). I opened /var/lib/dpkg/status with a text editor and (carefully) removed all wordpress-related packages (if you follow this, make a backup of that file, beforehand). The following command shows which packages to take care of:

root@balanceofcowards:/usr/share/wordpress# dpkg -l *wordpress*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                           Version                      Architecture                 Description
+++-==============================================-============================-============================-=================================================================================================
ii  wordpress                                      3.8.2+dfsg-1ubuntu0.1        all                          weblog manager
ii  wordpress-l10n                                 3.8.2+dfsg-1ubuntu0.1        all                          weblog manager - language files
ii  wordpress-theme-twentyfourteen                 3.8.2+dfsg-1ubuntu0.1        all                          weblog manager - twentyfourteen theme files
ii  wordpress-theme-twentytwelve                   3.8.2+dfsg-1ubuntu0.1        all                          weblog manager - twentyttwelve theme files

So, it’s four packages. I removed the respective paragraphs from the file. Running the above command again showed me that wordpress is now unknown and not installed. Bingo!

Discussion

What is the rationale of doing this? I had a preexisting installation with quite some configuration put into it (down to modified themes, etc.) and I didn’t want to lose any of that. I could have saved the respective files, uninstalled wordpress, manually install the official version, and copy the files I needed, but I figured this way would be easier. Any way, for a new server, just go for the official WordPress installation. Surprisingly, I couldn’t find any info on this on the internet – so I decided to document the way myself. Maybe there’s others who also have the same problem :)

Anything I forgot? Any oversights? Feel free to leave comments.

[:]

Dieser Eintrag wurde veröffentlicht in Sys und getaggt als , , . Fügen Sie den permalink zu Ihren Favoriten hinzu.

One Response to [:en]Switch wordpress installation from ubuntu repositories to official version[:]

Kommentare sind geschlossen.