Migrate Zope/Plone from CentOS to Ubuntu

I don’t use Zope and Plone anymore, but if you’ve played with Zope/Plone you know they are highly proprietary, fragile, missing a lot of desirable functionality, and overall pretty painful to manage. About the only thing I really ever liked about them was the relative ease of integrating Python libraries and code. Regardless, I sometimes had to move Zope installs around between servers, so this is one of the procedures I used.

In this case, I needed to migrate an old Zope 2.9/Plone 2.5.5 instance and its back-end PostgreSQL 8.1 database hosted on two separate CentOS 6 servers to a single Ubuntu 12.04 system. The Zope/Plone instance was created with the Plone universal installer, so it had its own version of Python (2.4.4) with which its plug-in products were compiled. The PostgreSQL database was on the second server, and the Zope/Plone instance spoke to Postgres using the ZPsycopgDA2 Zope/PostgreSQL database connector, a Zope product built on the Python psycopg2 library.

The process went as follows:

  • On the Ubuntu system, installed postgresql 8.4, changed password for database superuser (postgres), and adjusted configuration files in /etc/postgresql to make it listen on correct ports. Then I dumped the database from the PostgreSQL 8.1 instance, imported the SQL dump into the new PostgreSQL 8.4 instance, and connected with pgAdmin to ensure all the data was there.
  • Stopped the zeo and posgresql services on the two CentOS systems.
  • Copied the original Zope instance to /opt/Plone-2.5.5 on the Ubuntu box, added a plone user, adjusted permissions on Plone directory to match the original, and ensured the cache and port settings in the zope.conf configuration file were correct.
  • On the Ubuntu server, started the zeocluster to ensure it works — it did, mostly, with a couple of broken products:
    File "/opt/Plone-2.5.5/Python-2.4.4/lib/python2.4/site-packages/psycopg2/__init__.py", line 55, in ?
        from psycopg2 import tz
    ImportError: cannot import name tz
    
  • Installed the libpq-dev Python/PostgreSQL library, then ran the Zope version of the Python interpreter and tried to import psycopg2, with the following error:
    ImportError: libpq.so.4: cannot open shared object file: No such file or directory
    
  • Created a symbolic link from the new libpq library to the old one:
    ln -s /usr/lib/libpq.so.5 /usr/lib/libpq.so.4
    
  • Restarted the zeocluster again, then discovered that the CAS authentication we use for logins was also broken, with the errors:
    2013-01-18T17:09:47 ERROR Zope.SiteErrorLog http://redacted/index_html
    Traceback (innermost last):
      Module ZPublisher.Publish, line 106, in publish
      Module ZPublisher.BaseRequest, line 452, in traverse
      Module Products.PluggableAuthService.PluggableAuthService, line 234, in validate
      Module Products.PluggableAuthService.PluggableAuthService, line 560, in _extractUserIds
      Module Products.CAS4PAS.CASAuthHelper, line 147, in extractCredentials
      Module Products.CAS4PAS.CASAuthHelper, line 164, in validateTicket
      Module urllib, line 187, in open
      Module urllib, line 199, in open_unknown
    IOError: [Errno url error] unknown url type: 'https' 
    

    The Python 2.4.4 shell in the Zope instance showed the following:

    >>> import httplib
    >>> hasattr(httplib, 'HTTPS')
    False
    >>> import socket
    >>> hasattr(socket, 'ssl')
    False
    >>> import _ssl
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    ImportError: libssl.so.6: cannot open shared object file: No such file or directory 
    
  • Set two more symbolic links to fix the authentication problems:
    ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so libcrypto.so.6
    ln -s /usr/lib/x86_64-linux-gnu/libssl.so libssl.so.6 
    

    CAS authentication then worked properly.

  • On the Ubuntu system, installed apache2 to act as proxy for the Zope instance. Added a few Apache modules:
    $ a2enmod rewrite
    $ a2enmod proxy
    $ a2enmod proxy_balancer
    $ a2enmod proxy_http
    
  • Created a virtual host configuration file in /etc/apache2/sites-available/mysite.com:
    <VirtualHost *:80>
      ServerAdmin webmaster@localhost
      ServerName mysite.com
    
      ProxyVia On
    
      # prevent global HTTP proxy
      <LocationMatch "^[^/]">
          Deny from all
      </LocationMatch>
    
      <Proxy *>
          Order deny,allow
          Allow from all
      </Proxy>
    
      RewriteEngine on
      RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/mysite.com:80/mysite/VirtualHostRoot/$1 [P,L]
    </VirtualHost>
    
  • Then enabled the site and restarted Apache:
    $ a2ensite mysite.com
    $ service apache2 restart
    
  • Finally, added a link to the zeo startup script in /etc/rc.local so Zope will run when the Ubuntu box starts up.

(Compare this to Drupal, which runs on a very standard technology stack and offers the ability to clone web sites and databases from one box to another with Drush.)

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *