2010-12-03

在ubuntu安設定openoffice 的service 給 php用

參考:http://code.google.com/p/openmeetings/wiki/OpenOfficeConverter

Install Open Office Service on Debian/(K)Ubuntu (versions > 2.3)

  1. Install OpenOffice-Headless as root (through su, sudo, etc.):
    sudo apt-get install openoffice.org-headless
  2. Create and edit a file named openoffice.sh (for example) with you favorite editor over /etc/init.d:
    vi /etc/init.d/openoffice.sh
    #!/bin/bash
    # openoffice.org  headless server script
    #
    # chkconfig: 2345 80 30
    # description: headless openoffice server script
    # processname: openoffice
    # 
    # Author: Vic Vijayakumar
    # Modified by Federico Ch. Tomasczik
    #
    OOo_HOME=/usr/bin
    SOFFICE_PATH=$OOo_HOME/soffice
    PIDFILE=/var/run/openoffice-server.pid
    
    set -e
    
    case "$1" in
     start)
    
     if [ -f $PIDFILE ]; then
    
      echo "OpenOffice headless server has already started."
      sleep 5
      exit
     fi
      echo "Starting OpenOffice headless server"
      $SOFFICE_PATH -headless -nologo -nofirststartwizard -accept="socket,host=127.0.0.1,port=8100;urp" & > /dev/null 2>&1
      touch $PIDFILE
     ;;
     stop)
     if [ -f $PIDFILE ]; then
      echo "Stopping OpenOffice headless server."
      killall -9 soffice && killall -9 soffice.bin
      rm -f $PIDFILE
      exit
     fi
      echo "Openoffice headless server is not running."
      exit
     ;;
     *)
     echo "Usage: $0 {start|stop}"
     exit 1
    esac
    exit 0
  3. Change the permssions to this file:
    chmod 0755 /etc/init.d/openoffice.sh
  4. Install openoffice.sh init script links:
    update-rc.d openoffice.sh defaults
  5. Start the service:
    /etc/init.d/./openoffice.sh start
  6. You can see if openofice is running with this command:
    netstat -nap | grep office
You should get something like this:
tcp        0      0 127.0.0.1:8100          0.0.0.0:* 
LISTEN     2467/soffice.bin 

沒有留言: