You are not logged in Log in Join
You are here: Home » Members » dylanr » Running Zope on a Cobalt RaQ

Log in
Name

Password

 

Running Zope on a Cobalt RaQ

So you've rented a shiny new Cobalt RaQ to do some virtual hosting, eh? The first time I rented one of these babies, it didn't take long to realize that there was no management button to install Zope. Now what?

Information on how to proceed is scattered around and is the subject of several mostly unanswered posts on comp.lang.python. Assembling this, I stole shamelessly from several sources, particularly Chris McDonough's excellent HOWTO for installing and upgrading Zope and anser's HOWTO on using ProxyPass with Apache.

Even so, neither of these documents was enough to get going, as the RaQ has a number of special configurations that make setting extra stuff up a very special process. :-)

I wanted to get the start-to-finish process down so that if I ever have to do this again, I'll know where to go. If you're able to use this, please be my guest.

I'm assuming that you have admin and root access to your Raq and that you want Zope started automatically as a daemon. Further, I'm assuming that you're renting this and that all administration needs to be done remotely. I'm using the Raq 4 and Zope 2.5.1. My Raq comes with Apache 2.1.3 installed. If you're using different stuff, your milage may vary.

Typically, you would install Zope in /usr/local, but on my RaQ, only /home has any more than a couple dozen megs to spare. Your provider may have partitioned & mounted yours differently, so adjust accordingly. Assuming that /home is the mount point for most of your HD space, we'll put Zope there.

There are two things you might want to be doing here:

  • Setting up Zope stand-alone
  • Setting up Zope behind Apache
After we get Zope up, I'll branch the HOWTO for each case.

And before we start, you are using SSH to get command line access to your Raq, aren't you? This isn't really a Zope-specific issue, but you really shouldn't use the standard Telnet and FTP tools any more than is strictly necessary. SSH is well-documented elsewhere.

So... however you get command-line access, get it. We'll be switching between admin and root a fair amount. Unless you've configured it otherwise, your root PW is the same as your admin PW. I'll be using # to designate the root prompt and $ to designate the admin prompt.

Here we go...

$ su
password: (enter your root pw)
# mkdir /home/zope
# chown nobody zope
# chgrp admin zope
# chmod 770 zope
# exit
$ cd zope
$ wget http://www.zope.org/Products/Zope/2.5.1/Zope-2.5.1-linux2-x86.tgz
$ tar zxvf Zope-2.5.1-linux2-x86.tgz
$ mv Zope-2.5.1-linux2-x86 2-5-1
$ su
password: (PW)
# chown nobody 2-5-1
# chmod 770 2-5-1
# exit
$ cd 2-5-1
$ ./install
** Pay Attention and write down the admin password that flies by **
$ su
# chown nobody inituser
# chmod 660 inituser
# chown -R nobody var

Take a deep breath, we're almost there. We've got a working installation (hopefully). Next up, we test it and then work on getting it set up to run as a daemon.

# ./start

This will fire up the server such that you can test that it was installed correctly. After the your command kicks out a few lines of reply, point your browser to SERVER_IP:8080/manage

If all is well, you should be able to log in as admin, using the password that was generated when you ran ./install. You wrote it down, right?

Assuming that works, switch back to the shell and kill the zope process by sending a ^z. Now we're ready to add an rc script.

Starting a daemon basically consists of putting some magic incantation into a text file, making that file executable, and putting a symlink (alias) to that executable file in the proper directory. One magic incantation to use is:

#! /bin/sh
#
# processname: zope2
# Source function library
. /etc/rc.d/init.d/functions
# Get config
. /etc/sysconfig/network
# Check networking is up
if [ ${NETWORKING} = "no" ]
then
	exit 0
fi
# See how we were called
case "$1" in
	start)
		echo -n "Starting Zope: "
		daemon /home/zope/2-5-1/start
		;;
	stop)
		echo -n "Stopping Zope: "
		/home/zope/2-5-1/stop
		;;
	reload|restart)
		$0 stop
		$0 start
		;;
	*)
		echo "Usage: zope {start|stop|reload}"
		exit 1
esac
exit 0

Obviously, if you're using a different version of Zope and/or put Zope into a different directory, you'll need to make some changes.

If you're a Linux guru, you're already done by now... but in case you're a total newbie, here's what happens next:

$ su
Password: (pw)
# cd /etc/rc.d/init.d
# vi zope

:startinsert
(type/paste in the magic incantation)
<ESC key>
:wq
# chmod +x zope
# cd ../rc3.d
# ln -s ../init.d/zope S81zope
# cd ../rc6.d
# ln -s ../init.d/zope K35zope

Now we've set up our Raq to start up Zope at boot time and shut down Zope during a system shutdown. Cool. Let's give it a test, shall we?

Log out of your shell and use the web management console to reboot the server. Once that's done, log back in.

If you've gotten to this point and can see your Zope server running on port 8080, log in to Zope and add a VirtualHostMonster to your root Folder. Now it's time to figure out what else we're trying to do here. If you want Zope to run standalone, continue reading. Otherwise skip to the section on Apache.

Running Zope Standone
First off, create a bookmark to your web admin page. If yours is where mine is, that will be:

http://IP_ADDR:81/.cobalt/sysManage/index.html

Where IP_ADDR is your numerical IP address.

Bookmark this, write it down, commit it to memory and don't lose it. The alias IP_ADDR/admin is about to get killed. If you ask me, that's a good thing.

Second, you do have some reliable way of getting in to your server that doesn't depend on the web interface, don't you? Once again, if you're not already working with SSH, you really oughta.

Now then, since we're able to manage the server by at least two means that don't depend on Apache, we're ready to start screwing around.

SSH (or Telnet) in, get root and let's go:

$ su
Password: (PW)
# cd /etc/rc.d/rc3.d
# mv S75httpd s75httpd
# cd ../rc6.d
# mv K75httpd k75httpd
# cd /usr/local/zope/2-5-1
# vi start
:startinsert
(delete the very last line)
(change the last line to:)

$INST_HOME/z2.py -w80
<ESC key>
:wq

And that's it. We've disabled Apache from loading at boot time, we've told Zope to respond to port 80, and we should still be able to do web-based management through the URL that you bookmarked up above. Sweet.

To get virutal hosting going, just open the VHM object we put in your root Folder, click the Mappings tab and follow the instructions.

If you need to re-enable Apache, change the last argument in /home/zope/2-5-1/start from -w80 to -w8080 and then go back in to /etc/rc.d/rc3.d (as root) and change s75httpd back to S75httpd

Using Apache As A Front End
This was a bit touger than it seemed like it should be. The Raq has some funky stuff going on, namely:

  • Apache is configured to run on port 75 but listen on 80.
  • Apache version 1.3.12 is the very last version of Apache that doesn't support the VirtualHost syntax most commonly found in HOWTOs and other docs. A close reading of the docs at apache.org yielded the correct answers, but it wasn't easy.

So here we go.

Brief Digression: Before we go messing with httpd.conf, you may want to look into RCS, a very simple technique for maintaining version control. It's saved me from disaster more times than I can say. If you aren't already fluent in RCS, take five minutes and read about it... you'll thank me later.

OK... let's cd to /etc/httpd/conf and open httpd.conf in your favorite text editor. Add the following to the end of the block of LoadModule directives labeled Extra Modules:

LoadModule proxy_module modules/libproxy.so

And in the block of AddModule directives labeled Extra Modules, add:

AddModule mod_proxy.c

Now it's time to set up the virtual hosts. Before we do this, I should point out that changing this part of the httpd.conf file will break the virutal host management part of your Raq's through-the-web admin tool. From here on, you're only going to be able to manage your virtual hosts by getting in and doing the configuring yourself.

Scroll to the end of your httpd.conf file and check out the virtual hosts section. It begins with a single NameVirtualHost directive that should have your IP address as an argument. Following that are several <VirtualHost>...</VirtualHost> blocks that describe individual hosts. Detailed instructions covering all your options are here. But let's do a sample vhost configuration. Say your IP address is 1.2.3.4 and you're going to host spam.com and eggs.org. Assume further that root folders for each of these virtual hosts (in Zope) is /sites/spam_com and /sites/eggs_org. Here's what the bottom section of httpd.conf should look like:

NameVirtualHost 1.2.3.4:80
<VirtualHost 1.2.3.4:80>
ServerName www.spam.com
ServerAlias spam.com *.spam.com
ProxyPass / http://localhost:8080/VirtualHostBase/http/www.spam.com:80/sites/spam_com/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/www.spam.com:80/sites/spam_com/VirtualHostRoot/
</VirtualHost>
<VirtualHost 1.2.3.4:80>
ServerName www.eggs.org
ServerAlias eggs.org *.eggs.org
ProxyPass / http://localhost:8080/VirtualHostBase/http/www.eggs.org:80/sites/eggs_org/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/www.eggs.org:80/sites/eggs_org/VirtualHostRoot/
</VirtualHost>

On the off chance you want to access your root folder ever (say, to manage the server), you'll need to add something like the following:

<VirtualHost 1.2.3.4:80>
ServerName 1.2.3.4
ServerAlias 1.2.3.4
ProxyPass / http://localhost:8080/VirtualHostBase/http/1.2.3.4:80/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/1.2.3.4:80/VirtualHostRoot/
</VirtualHost>

That should allow Zope administration at http://1.2.3.4/manage

No configuration of your VHM should be necessary. The specially formed URL does it all.

Zope should still be running on port 8080, so all you need to do is restart Apache...

# kill -USR1 `cat /var/run/httpd.pid`

...and you should be good to go. Once you've confirmed that everything works as expected, you may wish to restrict access to Zope on 8080, meaning that Zope will only work through Apache and won't face the web directly. If that is of interest, add this argument to your start script:

-a 127.0.0.1

Feeback
I hope this information was helpful, but if it wasn't, please feel free to let me know where I may have lost you or gone wrong. I'd be happy to let you know what I meant if something here is unclear, but will be unable to provide additional support or troubleshooting, of course.