特殊:Badtitle/NS100:ProjectOpen:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Wikibot留言 | 贡献
无编辑摘要
Wikibot留言 | 贡献
无编辑摘要
 
第223行: 第223行:
Now reboot the server, and logon the PO-Machine (should be something like '''http://localhost:8000''' and enjoy.
Now reboot the server, and logon the PO-Machine (should be something like '''http://localhost:8000''' and enjoy.
----
----
=== Bugs in ]op[ 3.4 with to_date functions ===
Besides the fix mentioned with files '''/web/projop/packages/calendar/www/view-week-display-postgresql.xql''' and '''/web/projop/packages/calendar/www/view-week-display.tcl''', I too faced a few bugs related to to_date conversion function. It seems to_date(timestamp with time zone, text) and to_date(integer, text) were missing so I wrote my own and created them in the database and it started working.
Find below the functions I wrote:
<pre><nowiki>
CREATE OR REPLACE FUNCTION to_date(integer, text)
  RETURNS date AS
$BODY$
DECLARE
    p_date_in alias for $1;    -- date_id
    v_date_out  date;
    a integer;
    b integer;
    c integer;
    d integer;
    e integer;
    m integer;
    day integer;
    month integer;
    year integer;
begin
      -- http://code.activestate.com/recipes/117215/
      a :=  $1 + 32044;
      b := (4*a + 3)/146097;
      c := a - (146097*b)/4;
      d := (4*c +3)/1461;
      e := c - (1461*d)/4;
      m := (5*e+2)/153;
      day := e + 1 - (153*m+2)/5;
      month := m +3 -12*(m/10);
      year := 100*b+d-4800+m/10;
      v_date_out := to_date(year||'-'||month||'-'||day, 'yyyy-mm-dd');
      return v_date_out;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION to_date(integer, text) OWNER TO projop;
CREATE OR REPLACE FUNCTION to_date(timestamp to time zone, text)
  RETURNS date AS
$BODY$
DECLARE
    p_date_in alias for $1;    -- date_id
    p_format_in alias for $2;
    v_date_out  date;
begin
      select to_date(to_char(p_date_in, p_format_in), p_format_in) into v_date_out;
      return v_date_out;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION to_date(timestamp to time zone, text) OWNER TO projop;
CREATE OR REPLACE FUNCTION upper(timestamp with time zone)
  RETURNS timestamp with time zone AS
$BODY$
DECLARE
    p_val alias for $1;   
begin
    return p_val;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION upper(timestamp with time zone) OWNER TO projop;
</nowiki></pre>
----


[[category:UbuntuHelp]]
[[category:UbuntuHelp]]

2010年5月19日 (三) 23:58的最新版本

{{#ifexist: :ProjectOpen/zh | | {{#ifexist: ProjectOpen/zh | | {{#ifeq: {{#titleparts:ProjectOpen|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:ProjectOpen|1|-1|}} | zh | | }}

This wiki document explains how to setup Project Open on Ubuntu Hardy. The intended audience is experienced Linux users and system administrators.

Introduction

If you are new to Project Open, please find more information on their homepage at http://www.project-open.org/

Thanks to

This doctionation were not possible without the great work of Iván Belmonte (http://ivanhq.net/project-open-on-debian-etch/) and Venkat Mangudi (http://www.venkatmangudi.com/index.php?option=com_content&task=view&id=18&Itemid=37). Mainly this is only a summup of both documentations with additions for Ubuntu Hardy (8.04).

Pre-Requirements

I started with a plain Ubuntu 8.04 LTS Server with no special packages except OpenSSH-Server installed during installation from the CD. My machine is a P3, 1GHz with 512 MB Ram, 20 GB HD and Project Open runns good (I do not have many users on the machine, only one or two concurrent).

Step-By-Step Installation

Please note, I just copy the Unix-Commands with have to be entered at shell (eather SSH-Remote-Shell or on the machine itself starting Terminal-Session). Lines starting with a hash (#) are remark-lines. Since anything after a hash is ignored by the shell, it doesn't mather if you enter this also.

Ubuntu-Preparation

Lets start:

   # Became root
   sudo bash

   # Be sure to use current program-repository
   apt-get update

   # install some required programmes
   apt-get install libreadline5-dev zlib1g-dev tcl8.4 tcl8.4-dev tk8.4-dev bison flex cdbs libpam0g-dev libperl-dev python2.4-dev python-dev x-dev 

   # more required programmes
   apt-get install aolserver4 aolserver4-dev aolserver4-doc aolserver4-nscache aolserver4-nsopenssl aolserver4-nspostgres aolserver4-nssha1 aolserver4-nsxml 

   # change to local-source-dir
   cd /usr/local/src

   # you can try to install tdom, but according to my searches, it isn't part of hardy any more
   apt-get install tdom

   # use tdom from gutsy, workes fine
   
   # if you like, use tdom from my server
   wget http://fungus.at/po/tdom_0.7.8-5_i386.deb

   # otherway, search it within the ubuntu-pakage-lib at http://packages.ubuntu.com/de/gutsy/tdom and store it in /usr/local/src

   # install tdom
   dpkg -i tdom_0.7.8-5_i386.deb

   # install postgresql
   apt-get install postgresql postgresql-contrib

So, now we have to change some postgresql-settings: Edit /etc/postgresql/8.3/main/postgresql.conf. Look for VERSION/PLATFORM COMPATIBILITY section, and enable these variables as follows:

   add_missing_from = on
   regex_flavor = extended
   default_with_oids = on

Edit /etc/postgresql/8.3/main/pg_hba.conf. Look for the local IPv4 local connections section, and change md5 auth with ident as follows:

   # IPv4 local connections:
   #host    all         all         127.0.0.1/32          md5
   host    all         all         127.0.0.1/32          ident sameuser

Restart Postgresql:

   /etc/init.d/postgresql-8.3 restart

]Project-open[

   # Download and install ]PO[ package
   wget -c http://ivanhq.net/po/deb/project-open_3.2-1_i386.deb
   # alternative use http://fungus.at/po/project-open_3.2-1_i386.deb
   dpkg -i project-open_3.2-1_i386.deb

   # Create a user and a group for running ]po[
   groupadd projop
   useradd -g projop -d /web/projop -s /bin/bash projop

   # Create a log dir and change permissions on the website for the new user
   mkdir /web/projop/log
   chown -R projop:projop /web/projop

   # Create a new database for ]PO[ (default postgres charset is latin9, set it to utf8)
   su - postgres
    createuser -a -d projop
    createdb --owner=projop projop -E UTF8
    createlang plpgsql projop
   exit

   # Load demo data into the new database
   su - projop
    cd /web/projop/packages/intranet-core/preconf
    gzip -d project-open-3.2.sql.gz
    psql projop -f project-open-3.2.sql
    # please do not exit here, stay as user projop!!

Now we have to check, that the data has been correctly imported:

  psql projop
  projop=# select count(*) from users;
  exit

The output should be something like that; the Number 196 is a must!

    count
   -------
      196
   (1 row)

Edit config file /web/projop/etc/config.tcl and change main path settings

#set homedir                   /usr/local/aolserver
#set bindir                    [file dirname [ns_info nsd]]

set homedir                   /usr/lib/aolserver4
set bindir                    /usr/lib/aolserver4/bin

Launch the server to see if it works okay

/usr/sbin/aolserver4-nsd -f -t /web/projop/etc/config.tcl -u projop -g projop
# Ctrl+C to stop

Exit user projop

exit
Init system

Edit default Aolserver4 init script /etc/init.d/aolserver4 and change next parameters

#USER=www-data
#GROUP=www-data
#ADDRESS=127.0.0.1
#CONF=/etc/aolserver4/aolserver4.tcl

USER=projop
GROUP=projop
ADDRESS=0.0.0.0
CONF=/web/projop/etc/config.tcl

Change next line (about line 42, remove -s main)

#-u $USER -g $GROUP -b $ADDRESS:$PORT -s main -t $CONF >/dev/null 2>&1
-u $USER -g $GROUP -b $ADDRESS:$PORT -t $CONF >/dev/null 2>&1

Test everything works

reboot

BE PATIENT, ]po[ can take up to 1 min to start after rebooting.

Config

Look into config file (/web/projop/etc/config.tcl) for tuning your server sitename, listening port, etc Please note, now the server uses ]PO[ 3.2, but 3.3 is also released.

Fix AOL-Server startup

My aol-server startup had a bug: could not stop the server. So I did this workaround within /etc/init.d/aolserver4: the start-stop-daemon-line was replaced by the killall line.

  stop()
  {
    log_daemon_msg "Stopping web server" "$NAME"
    #start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo >/dev/null
    killall aolserver4-nsd
    if [ $? != 0 ]; then

Upgrade 3.2 to 3.3

Download the Upgrade-Package from sourceforge: http://sourceforge.net/project/showfiles.php?group_id=86419&package_id=89751 I downloaded project-open-3.3.beta1-update.tgz. Store this download at /tmp

   # Unpack the source
   cd /tmp
   tar -xvzf project-open-3.3.beta1-update.tgz

Please read also the guide at README.project-open.3.3.1.2.0.txt, this guide should be found at /tmp. I used the steps 3a and 4 within this documentation.

   # be sure that the rights are OK
   chown -R projop:projop packages.3.3.1.2.0
   chmod -R ug+r packages.3.3.1.2.0

   # become root
   sudo bash

   # become projop-user
   su - projop
 
   # backup old packages
   mv packages packages.old 

   # install new packages
   mv /tmp/packages.3.3.1.2.0 packages 

   # restart aol-server
   /etc/init.d/aolserver4 restart

Bugs on ]po[ 3.3

I had to change this bugs to get ]po[ running under my configuration: /web/projop/packages/calendar/www/view-week-display-postgresql.xql and /web/projop/packages/calendar/www/view-week-display.tcl Search for to_date(start_date and replace it by to_date(:start_date. The ":" is importand before start_date!! This term has to be replaced in both files!!! /web/projop/packages/acs-tcl/tcl/utilities-procs.tcl Thanks to Gustaf Neumann (http://www.mail-archive.com/[email protected]/msg10006.html): Search for ad_proc -public ReturnHeaders and change the method to this:

ad_proc -public ReturnHeaders {{content_type text/html}} {
   We use this when we want to send out just the headers
   and then do incremental writes with ns_write.  This way the user
   doesn't have to wait for streamed output (useful when doing
   bulk uploads, installs, etc.).

   It returns status 200 and all headers including
   any added to outputheaders.
} {
   set all_the_headers "HTTP/1.0 200 OK
MIME-Version: 1.0
Content-Type: $content_type\r\n"
    util_WriteWithExtraOutputHeaders $all_the_headers
    if {[string match text/* $content_type]} {
      if {![string match *charset=* $content_type]} {
append content_type "; charset=[ns_config ns/parameters OutputCharset iso-8859-1]"
      }
      ns_startcontent -type $content_type
    } else {
      ns_startcontent
    }
}

Now reboot the server, and logon the PO-Machine (should be something like http://localhost:8000 and enjoy.


Bugs in ]op[ 3.4 with to_date functions

Besides the fix mentioned with files /web/projop/packages/calendar/www/view-week-display-postgresql.xql and /web/projop/packages/calendar/www/view-week-display.tcl, I too faced a few bugs related to to_date conversion function. It seems to_date(timestamp with time zone, text) and to_date(integer, text) were missing so I wrote my own and created them in the database and it started working. Find below the functions I wrote:

CREATE OR REPLACE FUNCTION to_date(integer, text)
  RETURNS date AS
$BODY$
DECLARE
    p_date_in alias for $1;     -- date_id
    v_date_out  date;
    a integer;
    b integer;
    c integer;
    d integer;
    e integer;
    m integer;
    day integer;
    month integer;
    year integer;
begin
      -- http://code.activestate.com/recipes/117215/
      a :=  $1 + 32044;
      b := (4*a + 3)/146097;
      c := a - (146097*b)/4;
      d := (4*c +3)/1461;
      e := c - (1461*d)/4;
      m := (5*e+2)/153;
      day := e + 1 - (153*m+2)/5;
      month := m +3 -12*(m/10);
      year := 100*b+d-4800+m/10;
      v_date_out := to_date(year||'-'||month||'-'||day, 'yyyy-mm-dd');
      return v_date_out;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION to_date(integer, text) OWNER TO projop;

CREATE OR REPLACE FUNCTION to_date(timestamp to time zone, text)
  RETURNS date AS
$BODY$
DECLARE
    p_date_in alias for $1;     -- date_id
    p_format_in alias for $2;
    v_date_out  date;
begin
      select to_date(to_char(p_date_in, p_format_in), p_format_in) into v_date_out;
      return v_date_out;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION to_date(timestamp to time zone, text) OWNER TO projop;

CREATE OR REPLACE FUNCTION upper(timestamp with time zone)
  RETURNS timestamp with time zone AS
$BODY$
DECLARE
    p_val alias for $1;     
begin
    return p_val;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION upper(timestamp with time zone) OWNER TO projop;