Installing Zope/Plone v4.2.1 With The Unified Installer In Centos

This howto will outline how to install Zope and Plone in Centos 6.x using the unified installer from Plone.org without damaging the Centos base system. For the purposes of this howto we’ll be using the latest stable version available at this time, 4.2.1.

Note: Plone is now up to 4.2.1 (stable) Please use this howto as a guide to installing the latest stable Plone release.

Applicable to Centos Versions:

  • Centos 5.x
  • Centos 6.x

Requirements

Explanation of requirements.

  1. Download the Zope/Plone Unified installer from Plone.org here
  2. Root or sudo access to the Centos system
  3. Note: Currently the EPEL software repo packages Zope 2.10-7final and Plone 3.1.6 for use with Centos, due to the Plone projects packaging choices it is unlikely that future versions of Zope or Plone will be included in this repo and will need to be installed using the method below.

Doing the Work

Basic description of what will be done and what is expected.

  1. Download and extract the Plone-4.2.1-UnifiedInstaller.tar.gz into a temp dir:
  2. wget https://launchpad.net/plone/4.2/4.2.1/+download/Plone-4.2.1-UnifiedInstaller.tgz && tar xvfz Plone-4.2.1-UnifiedInstaller.tgz
  3. Change directory to the Plone installer, read the README.txt and start the installation script:
  4. cd Plone-4.2.1-UnifiedInstaller; vi README.txt (use esc :q to exit the editor)
    
    The /opt directory is for "optional" software installs
    The /srv directory is for serving content: mp3s, images, pdfs, etc
    
    each of these directories should be empty on a default normal Centos install.
    
    For this howto we're going to install a zeo cluster into /srv/Plone. /opt/Plone is also a valid choice that will not harm your Centos install. For different install methods, please see the README.txt referred to above. The command below will compile and install into /srv/Plone Plone, Zope and Python.
    This will not harm your existing system Python which Centos needs to operate normally.
    
    Issue the following as root or with the appropriate sudo privileges:
    
    sudo ./install.sh zeo --target=/srv/Plone --password=mypass
    
    This will create the following directories:
    /srv/Plone
    /srv/Plone/buildout-cache /srv/Plone/Python-2.7 /srv/Plone/zeocluster
  5. Next we’ll cd into the zeocluster directory and edit the buildout.cfg file. We’ll add in a few products or addons to test:
  6. cd /srv/Plone/zeocluster; sudo vi buildout.cfg (hit i to insert text, esc :qw to exit and write the changes)
    
    Under the [buildout] section after: eggs = Plone
    add in:
    ############################################
    # Eggs
    # ----
    # Add an indented line to the eggs section for any Python
    # eggs or packages you wish to include.
    #
    eggs =
        Plone
        Pillow
        collective.fancyzoomview
        collective.plonetruegallery
    
    Also under: zcml = 
    add in:
    ############################################
    # ZCML Slugs
    # ----------
    # Some eggs need ZCML slugs to tell Zope to
    # use them. Eggs with names beginning with "Products."
    # usually don't need this.
    zcml =
    #    plone.reload
         collective.fancyzoomview
         collective.plonetruegallery
    
    IMPORTANT: If you get errors on the next command make sure you've used the same leading indentation, values for an option like eggs = subsequent lines should be indented 4 spaces.
    
    Save and exit the file and run this command:
    
    sudo bin/buildout
  7. The output of buildout should be similar to this:
  8. [user@localhost zeocluster]$ sudo bin/buildout
    Uninstalling zopepy.
    Uninstalling client2.
    Uninstalling client1.
    Updating zope2.
    Updating fake eggs.
    Updating productdistros.
    Updating zeoserver.
    Installing client1.
    Getting distribution for 'collective.fancyzoomview'.
    Got collective.fancyzoomview 0.4.2.
    Getting distribution for 'collective.plonetruegallery'.
    Got collective.plonetruegallery 0.7.1.
    Generated script '/srv/Plone/zeocluster/bin/client1'.
    Installing client2.
    Generated script '/srv/Plone/zeocluster/bin/client2'.
    Installing zopepy.
    Generated interpreter '/srv/Plone/zeocluster/bin/zopepy'.
    Updating zopeskel.
    Updating chown.
    chown: Running 
    chmod 600 .installed.cfg
    touch /srv/Plone/zeocluster/var/zeoserver/zeoserver.log
    find /srv/Plone/buildout-cache/eggs -type d -name LC_MESSAGES -exec chown -R zeo \{\} \;
    chown -R zeo /srv/Plone/zeocluster/var/filestorage
    chmod 700 /srv/Plone/zeocluster/var/filestorage
    chown -R zeo /srv/Plone/zeocluster/var/zeoserver
    chmod 700 /srv/Plone/zeocluster/var/zeoserver
    chown -R zeo /srv/Plone/zeocluster/var/client?
    chmod 700 /srv/Plone/zeocluster/var/client?
    Updating backup.
    Updating unifiedinstaller.
    Updating precompile.
    precompiling python scripts in /srv/Plone/zeocluster/products
    precompiling python scripts in /srv/Plone/zeocluster/parts/productdistros
    [user@localhost zeocluster]$
  9. Next we’ll start the zeoserver and client1 in debug mode:
  10. sudo bin/plonectl zeoserver start
    zeoserver: . daemon process started, pid=3975
    
    sudo bin/plonectl client1 fg
    client1: /srv/Plone/zeocluster/parts/client1/bin/runzope -X debug-mode=on
    
    You should see a lot of output here after the initial lines above, the final line that lets us know all is well looks like this: 2009-10-20 17:43:47 INFO Zope Ready to handle requests
  11. One method for adding a separate ZODB Mountpoint to separate your data.fs if you have multiple projects/sites:
  12. First we'll need to create the directory for storing our new data.fs by hand:
    sudo mkdir /srv/Plone/zeocluster/var/filestorage/mysite
    
    Next we'll need to alter our buildout.cfg accordingly, this method will mimic the file structure in the ZMI (Zope Management Interface):
    
    Put this at the very bottom of the buildout.cfg:
    
    [client1]
    zope-conf-additional =
        <zodb_db mysite>
        <filestorage>
        path ${buildout:directory}/var/filestorage/mysite/Data_mysite.fs
        </filestorage>
        mount-point /mysite
        </zodb_db>
    
        <zodb_db mysite2>
        <filestorage>
        path ${buildout:directory}/var/filestorage/mysite2/Data_mysite2.fs
        </filestorage>
        mount-point /mysite2
        </zodb_db>
    
    effective-user = plone (change this to "zeo" like the example below, this gives the proper read/write privileges to the new directory to create the new data.fs)
    effective-user = zeo
    
    save and exit, re-run buildout, restart the zeoserver and client1
    (sudo bin/buildout; sudo bin/plonectl zeoserver start; sudo bin/plonectl client1 fg)
    
    Next, visit your site @ http://ip:port and from the dropdown in the upper right choose ZODB Mountpoint. From there you should see your new mountpoint, select and create it. Click on the newly created folder and from the same dropdown in the upper right select "Plone Site". Give your new site an id and create it.
  13. Adding your new site(s) into your apache (httpd) configuration, this assumes you’re running your client1 on port 8181, if you aren’t, you’ll need to change this along with the obvious “mysite”:
  14. 
    <VirtualHost *:80>
     ServerAdmin admin@mysite.org
     ServerName mysite.org
     ServerAlias www.mysite
     DocumentRoot /var/www/html/mysite.org
     ScriptAlias /cgi-bin/ /var/www/html/mysite.org/cgi-bin/
     SecRuleInheritance Off
     CustomLog logs/mysite.org_access_log combined
     ErrorLog logs/mysite.org_error_log
     RewriteEngine On
     RewriteLog /var/log/httpd/mysite.org_rewrite.log
     RewriteLogLevel 1 #9 for debugging#
     RewriteRule ^/sitemap.xml.gz$ http://127.0.0.1:8181/VirtualHostBase/http/%{SERVER_NAME}:80/mysite/mysite.org/VirtualHostRoot/sitemap.xml.gz [L,P]
     RewriteRule ^/(.*)/$ http://127.0.0.1:8181/VirtualHostBase/http/%{SERVER_NAME}:80/mysite/mysite.org/VirtualHostRoot/$1 [L,P]
     RewriteRule ^/(.*) http://127.0.0.1:8181/VirtualHostBase/http/%{SERVER_NAME}:80/mysite/mysite.org/VirtualHostRoot/$1 [L,P]
    </VirtualHost>
    
    Please see this information on further hardening your server against HTTP attacks and making Zope only listen locally for requests:
    https://weblion.psu.edu/trac/weblion/wiki/SecureZope
  15. Version pinning:
  16. In buildout.cfg at the top under [buildout], for example, we have:
    extends =
            versions.cfg
            versions2.cfg
    If both versions.cfg and versions2.cfg have a collective.foo = $version statement, the one in versions2.cfg is going to preside over versions.cfg. So in versions2.cfg we'll add a line at the top:
    
    [versions]
    collective.plonetruegallery = 0.7.1
    
    The benefit of pinning versions is so we don't wind up with unexpected results when running subsequent buildouts which may break our sites, effectively "pinning" a product to a specific version. We make backups or ideally run on dev servers/instances to test new versions of products/addons with our existing sites.
    
    Also, check out: http://good-py.appspot.com/ 

Troubleshooting & Supplementary Information

How to test

Explanation troubleshooting basics and expectations.

  1. Important directories and files to backup:
  2. Important files and directories: buildout.cfg, versions.cfg, zeocluster/filestorage/* (We're after the Data.fs* files here and any subdirectories) zeocluster/products/*
  3. Getting more products or addons for Plone:
  4. Most products here can be installed like we installed collective.fancyzoomview and collective.plonetruegallery above in the buildout.cfg
    http://plone.org/products
    http://pypi.python.org/pypi
  5. Deleting or removing the install:
  6. With root or sudo privileges, cd /srv; sudo rm -rf Plone
  7. Useful commands:
  8. sudo bin/buildout -n -v (-n tells buildout to get the latest/newest available package, -v is for verbose output)
    sudo bin/plonectl start|stop (this will start/stop the zeoserver and all clients)
    sudo bin/plonectl zeoserver start|stop (this will start/stop the zeoserver only)
    sudo bin/plonectl client1 fg (this starts client1 in debug mode for troubleshooting, use control+c to exit)
    sudo bin/plonectl client1|client2|clients start|stop (this will start/stop client1, client2 or all clients depending on your choice)
  9. BASH backup scripts:
  10. As root, copy and save the scripts below as a text file in:
    /root/plone-backup.sh, chmod +x plone-backup.sh
    /root/repozo-backup.sh, chmod +x repozo-backup.sh
    
    plone-backup.sh click to download
    repozo-backup.sh click to download
    
    To restore a repozo incremental backup here is the general syntax:
    python /srv/Plone/Zope-2.10.9-final-py2.4/lib/python/ZODB/scripts/repozo.py -Rv -r /srv/Plone/backup -D 2009-10-22-21-07-48.fsz -o MyBackup.fs
    
    This assumes your backups are stored in: /srv/Plone/backups and that the repozo python script is in: /srv/Plone/Zope-2.10.9-final-py2.4/lib/python/ZODB/scripts/repozo.py
    You will need to adjust this command to suit your needs as the scripts store the backups in /root/$DATE/$SERVER
    
    To automate and run these scripts for a nightly backup:
    cd /etc/cron.daily

    vi plonebackup and add: bash /root/plone-backup.sh > /dev/null 2>&1
    chmod +x plonebackup or: vi repozobackup and add:
    bash /root/repozo-backup.sh > /dev/null 2>&1 chmod +x repozobackup save and exit. These scripts will make backups of the important Zope & Plone files and directories to: /root/Plone-backup/$DATE/$SERVER /root/Plone-repozo-backup/$DATE/$SERVER For more information and a more verbose explanation see the Zope.org link below
  11. Packing the Zope Database ZODB/Data.fs:
  12. From the Root Zope ZMI (Zope Management Interface):
    1. Click "Control Panel"
    2. Click "Database Management"
    3. Select the database you'd like to pack and the amount of days worth of history (the "days" field here signifies the amount of history you'd like saved in days)
    4. Click the "Pack" button
    Depending on the database size this could take a few seconds or minites to finish. After it's finished you should find a "Data.fs.old" in the same directory as your Data.fs This is a backup of the Data.fs previous to being backed up in case there is a problem you can simply delete the newly created Data.fs and rename the Data.fs.old to Data.fs and restart Zope or your zeoserver and client(s). For more information and a more verbose explanation see the Zope.org link below

Common problems and fixes

Describe common problems here, include links to known common problems if on another site

More Information

Any additional information or notes.

Disclaimer

We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #plone or #centoshelp on irc.freenode.net

Added Reading


© 2012 CentosHelp.org