Using Subversion to manage WordPress sites

Table of contents:

versione italiana

Versione Italiana
Se gestisci vari siti realizzati con WordPress ti sarai accorto che aggiornarli via FTP ogni volta che esce una nuova versione è faticoso e dispersivo. Si può però usare Subversion per fare aggiornamenti più veloci e sicuri, e per mantenere eventuali personalizzazioni del codice attraverso le nuove versioni.

Per cominciare, il server su cui si trova il sito deve avere accesso SSH e Subversion. Un articolo di Scott Yang spiega come usare SVN per fare checkout e aggiornamenti di WordPress, e per creare una selezione dei propri plugin preferiti. In sintesi:

Fai un checkout dell’ultima versione stabile di WP nella root directory del tuo sito:

svn checkout http://svn.automattic.com/wordpress/tags/2.0.4/

Quando esce una nuova versione, per esempio la prossima 2.1, fai uno switch della tua working copy:

svn switch http://svn.automattic.com/wordpress/tags/2.1/

Lo switch è più veloce di un nuoco checkout e tiene conto di file e directory aggiunti o rimossi.
Per mantenere i propri plugin preferiti, puoi usare svn:externals in wp-content/plugins: leggi tutto l’eccellente tutorial di Scott Yang

Se vuoi mantenere eventuali personalizzazioni fatte al codice, devi creare un tuo repositorydal quale fate checkout. leggi Alex King’s WordPress updates via Subversion, che nei commenti introduce il concetto di vendor branch.
Crea una vendor branch nel tuo repository, nella quale metti il codice originale WP. Aggiornerai il tuo trunk (con le personalizzazioni) dalla vendor branch ogni volta che saranno rilasciate delle nuove versioni stabili; l’installazione in produzione avverrà con i checkout e switch descritti sopra.

Infine, con i sistemi descritti qui Subversin creerà una directory .svn nella tua working copy, cioé nella document root del sito. E’ preferibile non renderla pubblica, perciò aggiungi una regola ad .htaccess come spiegato da Martin Tomes:

RedirectMatch 404 /\.svn(/|$)

english version

Enlish Version

When managing several WordPress websites, you may realize that FTP is not the ideal tool to upgrade each of them every time a new release or security fix is released. You can use Subversion to do all the upgrades easily and safely, and to maintain your own customizations to the code.

On the server that hosts your sites, you need SSH access and Subversion. Scott Yang explains how to use SVN to checkout and update wordpress, even maintaining your favorite plugins. In a nutshell:

Checkout the latest stable version of WP in the root directory of your website:

svn checkout http://svn.automattic.com/wordpress/tags/2.0.4/

When a new version of WP is released, say 2.1, switch your working copy:

svn switch http://svn.automattic.com/wordpress/tags/2.1/

Switching is faster than a new checkout and keeps track of added/delete files/dirs.
To keep your favorite plugins updated, you can use svn:externals on wp-content/plugins: read all of Scott Yang’s excellent tutorial

If you want to keep customizations you made on the code, you should create your own repository and checkout from there. Read Alex King’s WordPress updates via Subversion, in the comments the key concept of vendor branch is introduced.
Create a vendor branch in your repository, where you put the original WP code. Update your trunk (that has customizations) from the vendor branch when new versions are released, and install to production with the usual checkout/switch .

Last, using the above techniques will create a .svn directory in your working copy. You don’t want to disclose that information, so read Martin Tomes post and add an .htaccess rule like this:

RedirectMatch 404 /\.svn(/|$)

No related posts.

2 pensieri su “Using Subversion to manage WordPress sites

  1. Articolo molto interessante, però devo dire che penso che sia poco “utilizzabile”: è assai tecnico e si basa su concetti che il webmaster dovrebbe già aver acquisito.

    O almeno per il sottoscritto risulta così :-P poi ci sta benissimo il problema di comprendonio sia mio e di pochi altri :)

    Comunque ci studierò su.

  2. Non ho capito se li ritieni concetti difficili, esposti troppo in fretta, oppure se son cose che sai già e quindi non ti dicono nulla di nuovo.

    Sono appunti che ho scritto mentre cercavo di risolvere i miei problemi, quando in rete non ho reperito molto materiale e soprattutto nulla in italiano.

    Dimmi, son tutt’orecchie :-)