Install Openoffice headless as a service in Ubuntu

It's taken me forever to figure out to get this going so now that I've found it out here's the solution (thanks to this post:


First of all install the headless openoffice from the repositories:


sudo apt-get install

The 2 latter packages are required or you will get an error message: This url is not supported

Now you need to create a script to start it as a service:

sudo nano /etc/init.d/

Paste the following code into that file:

# headless server script
# chkconfig: 2345 80 30
# description: headless openoffice server script
# processname: openoffice
# Author: Vic Vijayakumar
# Modified by Federico Ch. Tomasczik

set -e

case "$1" in
if [ -f $PIDFILE ]; then
echo "OpenOffice headless server has already started."
sleep 5
echo "Starting OpenOffice headless server"
$SOFFICE_PATH -headless -nologo -nofirststartwizard -accept="socket,host=,port=8100;urp" & > /dev/null 2>&1
touch $PIDFILE
if [ -f $PIDFILE ]; then
echo "Stopping OpenOffice headless server."
killall -9 soffice && killall -9 soffice.bin
rm -f $PIDFILE
echo "Openoffice headless server is not running."
echo "Usage: $0 {start|stop}"
exit 1
exit 0

 Exit the nano text editor saving the file as you do. 

Now make the script executable:

sudo chmod 0755 /etc/init.d/

Make it start automatically on reboot by executing this command:

sudo update-rc.d defaults

Now start the service by running

sudo /etc/init.d/ start

Now all should be good!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

When starting OpenOffice (OO) outside OpenVPMS, you should also disable OpenVPMS' facility for restarting OO (as a workaround for memory leaks in OO 2.x).

To disable restart, edit applicationContext.xml located in the directory:


and change the reuseCount value as follows:

     <bean id="OOBootstrapConnectionPool"
        <constructor-arg ref="OOSocketBootstrapService"/>
        <!-- restart OpenOffice after 'reuseCount' uses. Use 0 to never restart -->
        <property name="reuseCount" value="0"/>

OpenOffice 2.x cannot be started by OpenVPMS on Ubuntu without some configuration changes.

Whichever user is used to run OpenOffice, they need to have a writable home directory so that OpenOffice can read/write $HOME/.openoffice.org2

If OpenOffice can doesn't have permission to access this directory, it silently fails - the soffice process will appear in ps listings, but:

 > netstat -a |grep 8100  

will show that no process is listening on port 8100 (the port OpenVPMS configures OpenOffice to listen on).

By default, the /etc/init.d/tomcat5.5 script runs tomcat as user tomcat55 which doesn't have a writable home directory. Also, when it runs tomcat (using jsvc) it doesn't change $USER or $HOME to refer to tomcat55, but leaves them as the same as root. When OpenOffice is started by OpenVPMS in this scenario, it has no permission to access root's home directory, so it silently fails.

To configure Ubuntu to enable OpenVPMS to start/stop OpenOffice do the following:

1. Make the tomcat55 user home directory writable by tomcat55.

 > chown tomcat55 /usr/share/tomcat55 

2. Change /etc/init.d/tomcat5.5 to set USER and HOME to that of tomcat55

 # Run Tomcat 5 as this user ID

There is a step missing above, before you make the directory writable you need to create it: 

mkdir /usr/share/tomcat55
Note that for OpenOffice 3 and tomcat 6,  there should be no need for the above script. The only thing that should be required is to change ownership of the tomcat6 home directory from root to tomcat6, in order for the  OpenOffice to create its directory and files i.e.: sudo chown tomcat6 /usr/share/tomcat6
Just a single question, I need to run the service as a user other than root, how can I specify the user that should run the service? I mean the script: /etc/init.d/ Thanks

As per the comment above, you shouldn't need the script at all.

If soffice is is in the PATH used to start tomcat, OpenVPMS will launch it automatically. Alternatively, you can edit applicationContext.xml located in:


and set the path of the soffice binary:

  <bean id="OOBootstrapConnectionPool"
        <constructor-arg ref="OOSocketBootstrapService"/>
        <property name="path" value="/path/to/soffice"/>

Make sure you can run soffice as the user running tomcat before starting tomcat.


Ok, sorry for not explain well myself, I'm not using tomcat nor openvpms, I need openoffice only for file conversion that's why I need to start it headless and with the user www-data. Thanks for your quick answer....

Having just fired up a system on an Amazon EC2 instance running Ubuntu 14.04, I thought it would be worth bringing this up to date.

My recipe is:

download Apache_OpenOffice_4.1.3_Linux_x86-64_install-deb_en-GB.tar.gz
gunzip A*
tar -xvf A*
cd en-GB/DEBS
sudo dpkg -i *.deb
## need to add soffice to path so:
    sudo nano /etc/init.d/tomcat7 and add /opt/openoffice4/program
## need to install libxt6 so:  
    sudo apt-get install libxt6


  1. To do the download bit, I found it easiest to use my windows laptop to navigate to the OO site and grab the 64bit debian version and then use WinSCP to push it up to the EC2 instance.
  2. I am using the English (British) version - if you use the US version then 'GB' changes to 'US'.
  3. Having done the base install (the dpkg -i *.deb), if you immediately restart tomcat and try printing an odt document, you will get an error saying that OpenVPMS cannot find soffice. Hence the need to add /opt/openoffice4/program to tomcat7's path.
  4. If you now restart tomcat and try again you will get 'failed to start after 10 retries'. The fix is to install the libxt6 package.
  5. If you are switching from running OpenVPMS on a windows platform to a linux platform as we are, then you may want to install the liberation fonts - see - this will give a match to the windows fonts.

Regards, Tim G

Syndicate content