|
|||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||
I worked off the work of Dave Bauer and used Macports.
Download and install MacPorts from http://www.macports.org/install.php and get the latest version (1.7.1 as of 2009-04-18)
(or 8.3 if you want to use the latest OpenACS HEAD?)
sudo port install postgresql82-serverthis 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/postgresql82/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/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/postgresql82/defaultdb/postgresql.confOnce you have emacs open, change the following config items:
stats_start_collector = on
stats_command_string = on
stats_row_level = on
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/postgresql82/bin/postgres -D /opt/local/var/db/postgresql82/defaultdb'
Install plpgsql as a language
/opt/local/lib/postgresql82/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.postgresql82-server.plist
To start it from then on just call
sudo launchctl start org.macports.postgresql82-server
To stop it:
sudo launchctl stop org.macports.postgresql82-server
Additionally for XoWIKI it is recommended to use ltree. Sadly this is not installed by default in macports, so here we go. You DON'T need this, if you have a fresh installation and no dumpfile which had ltree support .... And hopefully someone will change the portfile to include "ltree".
export PG_VERSION=8.2.14
cd /usr/local/src
curl -L -O ftp://ftp8.de.postgresql.org/pub/misc/pgsql/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.bz2
tar xvfj postgresql-${PG_VERSION}.tar.bz2
cd /usr/local/src/postgresql-${PG_VERSION}
./configure --sysconfdir=/opt/local/etc/postgresql82 --bindir=/opt/local/lib/postgresql82/bin --libdir=/opt/local/lib/postgresql82 --includedir=/opt/local/include/postgresql82 --datadir=/opt/local/share/postgresql82 --mandir=/opt/local/share/man --without-docdir --with-includes=/opt/local/include --with-libraries=/opt/local/lib --with-openssl --with-bonjour --with-readline --with-zlib --enable-thread-safety --enable-integer-datetimes
make
# Yes, do NOT install :-)
# Install ltree
cd /usr/local/src/postgresql-${PG_VERSION}/contrib/ltree
sudo make install
psql82 -U postgres -f ltree.sql template1
And if you say now, you could have not used macports in the beginning, take note that you can at least upgrade using macports, hoping that the ltree code won't need recompiling every time. Also note that ltree is "OPTIONAL"
sudo port install tcl +threads
This will install Tcl with threads enabled, which is needed for AOLserver.
sudo port install aolserverNow 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.11
XOTCL=1.6.5
# 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 ..."
curl -L -O http://www.tdom.org/files/tDOM-0.8.2.tgz
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/postgresql82/bin/pg_config POSTGRES=/opt/local PGINC=/opt/local/include/postgresql82/ PGLIB=/opt/local/lib/postgresql82/ ACS=1
cd ..
tDOM
tar xvfz tDOM-0.8.2.tgz
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 ../..
# Now edit the bogus pkgIndex by adding a space between the number (0.8.2) and the load...
sudo emacs -nw /opt/local/aolserver/lib/tdom0.8.2/pkgIndex.tcl
package ifneeded tdom 0.8.2 "load [list [file join $dir libtdom0.8.2.dylib]]; source [list [file join $dir tdom.tcl]]"
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.7-src.tar.gz
tar xfz tcl8.5.7-src.tar.gz
cd tcl8.5.7/unix
./configure --enable-threads --prefix=/opt/local --disable-corefoundation
sudo make install
cd ../..
tar xvfz xotcl-1.6.5.tar.gz
cd xotcl-1.6.5
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.11.tar.bz2 cd tcllib-1.11 ./configure --prefix=/opt/local/aolserver/ sudo make installType in terminal before starting nsd
ulimit -n 256I 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/postgresql82/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.plistsudo 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