Search · Index

Install OpenACS on Mac OS X 10.5 / 10.6 (Snow Leopard) Using Macports

I worked off the work of Dave Bauer and used Macports.

Unfortunately, the default configuration of Mac OS X does not allow suitable amounts of shared memory to be created to run the database server. 

Therefore you should edit your /etc/sysctl.conf

On a MacBook Pro with 2GB of RAM, the author's sysctl.conf contains:

kern.sysv.shmmax=1610612736

kern.sysv.shmall=393216

kern.sysv.shmmin=1

kern.sysv.shmmni=32

kern.sysv.shmseg=8

kern.maxprocperuid=512

kern.maxproc=2048

Download and install MacPorts from http://www.macports.org/install.php and get the latest version (1.7.1 as of 2009-04-18)

Install PostgreSQL 8.4

sudo port -k install postgresql84
cd `port work postgresql84`/postgresql-8.4.7/contrib/ltree
make all
sudo make install
sudo port install postgresql84-server
This installs expat, gperf, libiconv, ncursesw, ncurses, gettext, m4, bison, zlib, libxml2, libxslt1, openssl, readline, postgresql82. The macports install then says
To create a database instance, after install do
sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb'

Then after initdb postgres says to start postgresql. Before that edit the config file to make it compatible with ACS

sudo emacs -nw /opt/local/var/db/postgresql84/defaultdb/postgresql.conf
Once you have emacs open, change the following config items:
autovacuum = on
add_missing_from = on
default_with_oids = on
regex_flavor = extended

Now start the PostgreSQL Server 

sudo su postgres -c  '/opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/defaultdb' &

Install plpgsql as a language

/opt/local/lib/postgresql84/bin/createlang plpgsql template1 -U postgres

Last but not least, put postgresql under launchctl so you can start and stop it: 

sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist 

To start it from then on just call

sudo launchctl start org.macports.postgresql84-server

To stop it:

sudo launchctl stop org.macports.postgresql84-server

Install AOLserver 4.5

sudo port install tcl +threads +headers

This will install Tcl with threads enabled, which is needed for AOLserver.

sudo port install aolserver
Now we have AOLserver installed into /opt/local/aolserver. You now need to configure the server to your needs. You might want to create another user (e.g. aolserver) to run the server. First get all the files:
    cd /usr/local/src
    mkdir aolserver 
    cd aolserver 
    TCLLIB=1.13
    XOTCL=1.6.7
    # Path for the AOLserver installation 
    NS=/opt/local/aolserver
    cvs -z3 -d:pserver:anonymous@aolserver.cvs.sourceforge.net:/cvsroot/aolserver co nssha1 
    cvs -z3 -d:pserver:anonymous@aolserver.cvs.sourceforge.net:/cvsroot/aolserver co nspostgres
    echo "Getting TDOM ..." 
    git clone git://github.com/tDOM/tdom.git
    echo "Getting TCL modules ..." 
    curl -L -O http://downloads.sourceforge.net/tcllib/tcllib-${TCLLIB}.tar.bz2 
    curl -L -O http://downloads.sourceforge.net/tcl/thread2.6.5.tar.gz 
    curl -L -O http://media.wu-wien.ac.at/download/xotcl-${XOTCL}.tar.gz

Now install nssha1

 
    cd nssha1
    sudo make install NSHOME=${NS} 
    cd ..

Now go for nspostgres

 
    cd nspostgres/

    # Edit the Makefile so it reads (adding the "-lnsdb")
    MODLIBS = -L$(PGLIB) -lpq -lnsdb
    
    sudo make install AOLSERVER=/opt/local/aolserver/ PGCONFIG=/opt/local/lib/postgresql84/bin/pg_config POSTGRES=/opt/local PGINC=/opt/local/include/postgresql84/ PGLIB=/opt/local/lib/postgresql84/ ACS=1
    cd ..

tDOM

 
    cd tDOM-0.8.2/unix
    ../configure    --mandir=/usr/local/share/man    --libdir=/opt/local/aolserver/lib    --with-tcl=/opt/local/lib   --with-aolserver=/opt/local/aolserver
    sudo make install 
    cd ../..

Thread

 
    tar xvfz thread2.6.5.tar.gz 
    cd thread2.6.5/unix 
    ../configure    --mandir=/usr/local/share/man    --libdir=/Library/Tcl    --with-tcl=/System/Library/Frameworks/Tcl.framework    --with-tclinclude=/System/Library/Frameworks/Tcl.framework/Headers    --with-aolserver=/opt/local/aolserver 
    sudo make install
    cd ../..

XOTcl

The private header files of Tcl are missing, therefore I got the source and recompiled Tcl:

  curl -L -O http://downloads.sourceforge.net/tcl/tcl8.5.9-src.tar.gz
  tar xfz tcl8.5.9-src.tar.gz
  cd tcl8.5.9/unix
  ./configure --enable-threads --prefix=/opt/local --disable-corefoundation 
  sudo make install
  cd ../..

  tar xvfz xotcl-1.6.7.tar.gz 
  cd xotcl-1.6.7
  NS=/opt/local/aolserver/ 
  ./configure --enable-threads --enable-symbols --prefix=${NS} --exec-prefix=${NS} --with-tcl=/opt/local/lib
  sudo make install-aol
  cd .. 

Now we finish off with tcllib

 
  tar xvfj tcllib-1.13.tar.bz2 
  cd tcllib-1.13
  ./configure --prefix=/opt/local/aolserver/ 
  sudo make install
Type in terminal before starting nsd
  ulimit -n 256
I would recommend to install the server in ~/Sites/yourserver if you don't intend to run multiple different servers with access rights on your machine. Checkout the OpenACS code and Edit ~/Sites/yourserver/etc/config.tcl and make the following changes
# Change the server root
set serverroot                "~/Sites/${server}"

# Make sure that OpenACS finds PostgreSQL. Add two lines to the $database if statement

if { $database eq "oracle" } {
    set db_password           "mysitepassword"
} else {
    set db_host               localhost
    set db_port               ""
    set db_user               $server
    ns_section "ns/db/driver/postgres"
    ns_param   pgbin              /opt/local/lib/postgresql84/bin/
}

# Change the AOLserver location
set homedir                   /opt/local/aolserver

Now you can start up your server. First try ist with /opt/local/aolserver/bin/nsd -t ~/Sites/yourserver/etc/config.tcl. If this works you might want to create a launchctl entry as you did above for postgresql

Edit /Library/LaunchDaemons/org.openacs.YOURSERVER.plist and enter the following

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.openacs.YOURSERVER</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/youruser/Sites/yourserver/etc/daemontools/run</string>
        </array>
        <key>ServiceDescription</key>
        <string>OpenACS Service</string>
        <key>UserName</key>
        <string>youruser</string>
        <key>GroupName</key>
        <string>staff</string>
    </dict>
</plist>

Now put yourserver under launchctl so you can start and stop it: 

sudo launchctl load -w /Library/LaunchDaemons/org.openacs.yourserver.plist 

To start it from then on just call

sudo launchctl start org.openacs.yourserver

To stop it:

sudo launchctl stop org.openacs.yourserver 

It is a good idea to schedule regular backups for your server(s). To do this create a shell script, e.g. backup.sh which executes your backups and then create a launchdaemon plist to run your backups nightly

Edit /Library/LaunchDaemons/org.openacs.backup.plist and enter the following

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.openacs.backup</string>
        <key>ProgramArguments</key>
        <array>
        <string>/Users/youruser/Sites/backup.sh</string>
        </array>
        <key>LowPriorityIO</key>
                <true/>
                <key>Nice</key>
                <integer>1</integer>
                <key>StartCalendarInterval</key>
                <dict>
                        <key>Hour</key>
                        <integer>3</integer>
                        <key>Minute</key>
                        <integer>15</integer>
                </dict>
    </dict>
</plist>

If you intend to run AOLserver on a continous basis remember that it is a great idea to make sure it responds properly. To do this you can run a keepalive service.

Edit /Library/LaunchDaemons/org.openacs.keepalive.plist and enter the following

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.openacs.keepalive.plist</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/youruser/Sites/keepalive.sh</string>
	    <string>yourserver</string>
            <string>yourport</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StartInterval</key>
        <integer>180</integer>
</dict>
</plist>

Your keepalive.sh could look like this

#!/bin/bash 
GREP=/usr/bin/grep
HEAD="/usr/bin/head -1"

INSTANCE="$1";
PORT="$2"

[ -z "$1" ] && exit
[ -z "$2" ] && exit

MAIL_ADDR=""
WGET_FILE=/tmp/.output-keepalive-${INSTANCE}
URL_TEST="http://127.0.0.1:${PORT}/SYSTEM/dbtest"
[ -f ${WGET_FILE} ] && rm -f ${WGET_FILE}  

_restartwebserver ()
{

/bin/launchctl start org.openacs.$INSTANCE
sleep 3
/bin/launchctl start org.openacs.$INSTANCE
}

_sendmail ()
{
echo "${1}" |mailx -s AolWebserver ${MAIL_ADDR}
}

while [ 1 -eq 1 ];
do
        [ -f ${WGET_FILE} ] && /bin/rm -f ${WGET_FILE}
        /usr/bin/curl -s -o $WGET_FILE --connect-timeout 3 --retry 3 "${URL_TEST}"

        if [ -f ${WGET_FILE} ] 
                then
                FIRST_LINE=`${HEAD} ${WGET_FILE} | ${GREP} -i "success"`
                [ -z "${FIRST_LINE}" ] && _restartwebserver && _sendmail "I just restarted the $INSTANCE webserver on `uname -n`" && echo "`date +'%D-%H:%M'` :: FAILURE" || echo "`date +'%D-%H:%M'` :: success $INSTANCE" >>/Users/malte/Sites/keepalive.log 
                else
                _restartwebserver && _sendmail "I just restarted the $INSTANCE webserver on `uname -n`"
#               _restartwebserver
                echo "`date +'%D-%H:%M'` :: FAILURE"
        fi
done

If you intend to run AOLserver on a continous basis remember that it is a great idea to restart your server once per night, otherwise the memory footprint will grow and grow and grow.

Edit /Library/LaunchDaemons/org.openacs.restart.plist and enter the following

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.openacs.restart</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/youruser/Sites/restart.sh</string>
        </array>
         <key>LowPriorityIO</key>
        <true/>
                <key>Nice</key>
                <integer>1</integer>
                <key>StartCalendarInterval</key>
                <dict>
                        <key>Hour</key>
                        <integer>4</integer>
                        <key>Minute</key>
                        <integer>15</integer>
                </dict>
</dict>
</plist>

Now put scripts under launchctl so they will run in the night: 

sudo launchctl load -w /Library/LaunchDaemons/org.openacs.backup.plist

sudo launchctl load -w /Library/LaunchDaemons/org.openacs.restart.plist

sudo launchctl load -w /Library/LaunchDaemons/org.openacs.keepalive.plist

Your restart.sh could look like this

  #!/bin/bash
  echo "cognovis"
  sudo launchctl stop org.openacs.yourserver
  sleep 10
  sudo launchctl start org.openacs.yourserver 
Previous Month May 2017
Sun Mon Tue Wed Thu Fri Sat
30 (3) 1 2 3 (1) 4 5 6
7 (1) 8 9 10 11 (1) 12 13
14 15 16 (1) 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 1 2 3

Popular tags

17 , 5.9.0 , 5.9.1 , ad_form , ADP , ajax , aolserver , asynchronous , bgdelivery , bootstrap , bugtracker , CentOS , COMET , CSP , CSRF , cvs , debian , emacs , fedora , FreeBSD , hstore , includelets , install , installation , installers , install-ns , javascript , libthread , linux , monitoring
No registered users in community xowiki
in last 30 minutes
Contributors

OpenACS.org