Installing & Configuring Webware on SME Server 7

From Mophilly Knowledge Base
Jump to: navigation, search

Contents

Introduction

This "how-to" explains the process for installing Webware on SME 7. SME 7 is an "all in one" business server distribution we find useful in many situations. Please visit wiki.contribs.org for the latest information about SME Server.

Webware for Python is a well-tested web application framework that can be applied to a great many business applications. Please visit www.webwareforpython.org for the most current information about Webware. The WebKit Install Guide is a good place to start with Webware.

The information here is a blend of advice from "cactus" on the SME Forums and from Gary Perez and Christoph Zwerschke, who are members of the Webware discussion list. Cactus is a member of the SME documentation team and provided the basic formula for adding the apache mod in a manner appropriate for SME. Gary Perez provided a nice "how to" for installing Webware on CentOS. Christoph, a chief maintainer of the Webware code base, assured me the compile of the apache mod source would work with apache 2.0 and thereby gave me the courage to devote time to this.

Please let us know if you spot any errors or omissions.

Preparation

You are strongly encouraged to build the apache mod on a development machine and not on a production server. You can copy the compiled files over to the your target machine when you are finished.

If you choose to run the compilation on a production server, you must pay close attention to removing the rpm's installed for the compilation of the apache mod. Not removing the additions will open your server to security risks. Conversely, removing the wrong ones will break your operating system.

System Description

As of December 28, 2007

OS: SME 7.2, with all updates including smeserver-yum-1.2.0-41

Web Server: Apache 2.0 (included in the SME 7.2 updated distro)

Python: Python 2.3.4

Webware: 0.9.4

Installation

Logon as root user

Access your SME Server shell as root user. You can set this in the server manager page. Remember to disable this access when you are done to reduce security risks.

Install httpd-devel

This is required to get "apxs" for the compilation of the apache mod. Not all the dependencies will be met in the basic repositories. You have to enable the "smecontribs" repository. This repository is only available on fully up-to-date SME Server 7.2 servers as provided since smeserver-yum-1.2.0-41.

     yum install httpd-devel --enablerepo=smecontribs

Review your yum installation log, /var/log/yum/yum.log, and make a note of precisely what was installed, including the dependent packages. You will need to remove them when you are done with the installation.

Install Webware

For this how-to, we place this in /usr/local.

     cd /usr/local
     tar xzf Webware-0.9.4.tar.gz 
     rm Webware-0.9.4.tar.gz 
     cd Webware-0.9.4/
     python install.py --no-password-prompt

Using the "no-password-prompt" allows the install script to manufacture a password for logging onto the admin page in Webware. You can change this later by editing the Application.Config page.

Now you need a bare minimum working directory for the Webware application. This sets up an application for testing Webware.

     cd bin
     ./MakeAppWorkDir.py /usr/local/wwrun

Compile and Install mod_WebKit2

Change to the direcotry that holds the mod_webkit2 files and check the path to "apxs". BTW, "less" is a small editor to allow you to examine the contents. You can also use "cat" or "pico" if you are more comfortable with them.

     cd ../WebKit/Adapters/mod_webkit2/
     less Makefile

Make sure that the path is correct for your system.

     APXS=/usr/sbin/apxs

Now you are ready to compile and install the mod files. The WebKit mod involves several files so you must follow the "make" command with "make install" to assure proper placement of the necessary files.

     make
     make install

The "make" command will build the modules into the ".libs" directory. Catus pointed out that this is a strange use of a hidden folder but it works in this case. The "make install" moves the required files into /usr/lib/httpd/modules directory.

Configure Apache

Now we need to make it load in the webserver, and for that we need to make an SME template fragment in the httpd.conf template tree. If you haven't added a custom template before, make the necessary directory:

     mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/

Create the template file. I used "pico" but any similar editor you are comfortable with will do. Do not use MS WordPad or Apple TextEdit as these will save the file in an incompatible format.

     pico /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/20LoadModule80webkit

Add this text:

     LoadModule webkit_module modules/mod_webkit.so
     <Location /wk>
         WKServer localhost 8086
         SetHandler webkit-handler
     </Location>


Next, regenerate the configuration file so it is available to SME, and restart the webserver.

     expand-template /etc/httpd/conf/httpd.conf
     sv t httpd-e-smith

Check if your server restarts properly.

     sv s httpd-e-smith

The output should be something like this:

     run: httpd-e-smith: (pid 27802) 174061s, normally down

If it does not return something like that there might be something wrong with the module but in my case the problem was a typo in the file "20LoadModule80webkit". You can easily revert changes by removing the custom template fragment, regenerating your configuration file and reloading the server.

     rm /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/20LoadModule80webkit
     expand-template /etc/httpd/conf/httpd.conf
     sv t httpd-e-smith

Remove Developer Packages

If everything works perfectly you are advised to remove all packages installed at the beginning of this "how-to". Several of the packages installed pose a security risk on your server. You determine all packages installed by looking at your /var/log/yum/yum.log file. Remove them using the "remove" command:

    yum remove package1-name package2-name

Yum will list the packages with a confirmation message. Only answer yes if all packages listed to be removed are exactly the same as those installed! If any other modules are listed by yum, answer no and review your logs again.

In our case, the following packages were removed after the compilation and installation was completed.

    apr-devel.i386
    db4-devel.i386.el4
    cyrus-sasl-devel.i386
    openldap-devel.i386
    pcre-devel.i386
    expat-devel.i386
    apr-util-devel.i386
    httpd-devel.i386

Your situation may be different.

Setup The Test Application

You are now ready to setup the basic Webware application. This will be the basic building blocks of applications you develop.

The first step is to create a directory for your python files to provide the "hook" to invoke Webware. With this made, you can test your installation and begin adding your application files to build on the Webware architecture.

The script "MakeAppWorkDir.py" expects at least one input, which is the name of the "working" directory. E.g. "WorkDir". There are additional parameters you may provide to ease your task. As with many projects, these are declared in the header of the file as well.

 Options:
 -c, --context-name=...  The name for the preinstalled context.
                         By default, it will be "MyContext".
 -d, --context-dir=...   The directory where the context will be located,
                         so you can place it outside of the WorkDir.
 -l, --library=...       Other dirs to be included in the search path.
                         You may specify this option multiple times.
 -i, --cvsignore         This will add .cvsignore files to the WorkDir.
 -u, --user=...          The name or uid of the user to own the WorkDir.
                         This option is supported under Unix only.
 -g, --group=...         The name or gid of the group to own the WorkDir.
                         This option is supported under Unix only.

The most simple invocation looks like this:

    $ python Webware/bin/MakeAppWorkDir.py WorkDir

This creates a directory with the name "WorkDir" and places a number of files and sub-directories in it.

Here is the same statement with one additional option declared, the name of the application context "MyApp":

    python Webware/bin/MakeAppWorkDir.py -cMyApp WorkDir

This adds another directory named MyApp within WorkDir.

Test Webware

You are now ready to test the basic Webware installation. The directions in the Webware documentation for installing Webware has a bit more information.

First step is to start the Webware server...

    ./AppServer

You can stop it with...

    ./AppServer stop

The, open your web browser and type in the appropriate URL. For our example...

    http://www.yourdomain.com/wk/

Production Issues

As time allows, new information will be added here to help you with production Webware applications.

Launch Webware on Boot

There are significant differences for setting up an application like Webware to launch on system boot under SME 7 as compared to CentOS and similar systems. It is not correct to simply modify the init.d files.

Please review the SME Developers Documentation. Specifically, review the sections "Configuration Template Files" and "Process Startup". An older page was found here: Starting up programs automatically on system boot".

The Webware site has a couple of good resources:

  1. Running Webware as User Webware
  2. mod_rewrite Recipes
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox