Start Confluence Automatically on Linux

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

On Linux/Solaris, the best practice is to install, configure and run each service (including Confluence) as a dedicated user with only the permissions they require.

To install, configure and run Confluence automatically on Linux/Solaris:

  1. Create a confluence user for instance, using the following command:

    sudo useradd --create-home -c "Confluence role account" confluence
  2. Create a directory to install Confluence into.  In this example we're using /usr/local/confluence.

    sudo mkdir /usr/local/confluence
    sudo chown confluence: /usr/local/confluence
    


  3. Log in as the confluence user to install Confluence:

    sudo su - confluence
    cd /usr/local/confluence/
    tar zxvf /tmp/confluence-5.6.4.tar.gz
    ln -s confluence-5.6.4/ current
    
  4. Edit <<CONFLUENCE_INSTALL_DIRECTORY>>/confluence/WEB-INF/classes/confluence-init.properties file, and set confluence.home=/usr/local/confluence/<Confluence_Data_Home> (ensure you have removed the comment '#')
  5. Then back as root, create the file /etc/init.d/confluence (code shown below), which will be responsible for starting up Confluence after a reboot (or when manually invoked).
    (warning) If you are running Ubuntu Jaunty (or later) do not perform this step. Please use the instructions further down this page.

    #!/bin/sh -e
    # Confluence startup script
    #chkconfig: 2345 80 05
    #description: Confluence
    
    # Define some variables
    # Name of app ( JIRA, Confluence, etc )
    APP=confluence
    # Name of the user to run as
    USER=confluence
    # Location of Confluence install directory
    CATALINA_HOME=/usr/local/confluence/current
    # Location of Java JDK
    export JAVA_HOME=/usr/lib/jvm/java-7-oracle
    
    case "$1" in
      # Start command
      start)
        echo "Starting $APP"
        /bin/su -m $USER -c "$CATALINA_HOME/bin/start-confluence.sh &> /dev/null"
        ;;
      # Stop command
      stop)
        echo "Stopping $APP"
        /bin/su -m $USER -c "$CATALINA_HOME/bin/stop-confluence.sh &> /dev/null"
        echo "$APP stopped successfully"
        ;;
       # Restart command
       restart)
            $0 stop
            sleep 5
            $0 start
            ;;
      *)
        echo "Usage: /etc/init.d/$APP {start|restart|stop}"
        exit 1
        ;;
    esac
    
    exit 0
    
  6. Make this file executable:

    sudo chmod +x /etc/init.d/confluence
  7. Set this file to run at the appropriate runlevel. For example, use sudo chkconfig --add confluence on Redhat-based systems, sudo update-rc.d confluence defaults or rcconf on Debian-based systems.
  8. You should now be able to start Confluence with the init script. A successful startup output typically looks like this:

    $ sudo /etc/init.d/confluence start
    Starting Confluence:
    If you encounter issues starting up Confluence, please see the Installation guide at http://confluence.atlassian.com/display/DOC/Confluence+Installation+Guide
    Using CATALINA_BASE:   /usr/local/confluence/current
    Using CATALINA_HOME:   /usr/local/confluence/current
    Using CATALINA_TMPDIR: /usr/local/confluence/current/temp
    Using JRE_HOME:       /usr/lib/jvm/java-1.7.0-oracle
    done.
    


    You should then see this running at http://<server>:8090/
    (info) The port for this will be whatever is defined in your Confluence server.xml file.

Adding Confluence as a service for Ubuntu Jaunty (or later)

To continue configuring Confluence to start automatically as a service on Ubuntu Jaunty (or later):

  1. After logging in as the confluence user to install Confluence, create start and stop scripts in /usr/local/confluence:

    Example startscript:

    #!/bin/bash
    export JAVA_HOME=/usr/lib/jvm/java-7-oracle-1.7.0.71/
    export JDK_HOME=/usr/lib/jvm/java-7-oracle-1.7.0.71/
    cd /usr/local/confluence/current/bin
    ./startup.sh
    


    Example stopscript:

    #!/bin/bash
    export JAVA_HOME=/usr/lib/jvm/java-7-oracle-1.7.0.71/
    export JDK_HOME=/usr/lib/jvm/java-7-oracle-1.6.0.71/
    cd /usr/local/confluence/current/bin
    ./shutdown.sh
    
  2. Make both of these scripts executable. For example, by issuing the command: sudo chmod a+x /usr/local/confluence/start /usr/local/confluence/stop.
  3. Karmic and later: Create two text files in /etc/init/ called confluence-up.conf and confluence-down.conf:

    confluence-up:

    start on runlevel [2345]
    
    script
    
    	date >> /tmp/confluence-startup.out
    	exec sudo -u confluence /usr/local/confluence/start >> /tmp/confluence-startup.out 2>&1
    
    end script
    


    confluence-down:

    start on runlevel [16]
    
    expect fork
    respawn
    
    exec sudo -u confluence /usr/local/confluence/stop >> /tmp/confluence-shutdown.out 2>&1
    



    ... and make them readable to all users:
    sudo chmod a+r /etc/init/confluence-up.conf /etc/init/confluence-down.conf

  1. Jaunty, Intrepid: Create two text files in /etc/event.d/ called confluence-up and confluence-down:

    confluence-up:

    start on runlevel 2
    start on runlevel 3
    start on runlevel 4
    start on runlevel 5
    
    exec sudo -u confluence /usr/local/confluence/start >> /tmp/confluence-startup.out 2>&1
    


    confluence-down:

    start on runlevel 1
    start on runlevel 6
    
    exec sudo -u confluence /usr/local/confluence/stop >> /tmp/confluence-shutdown.out 2>&1
    


    ... and make them readable to all users:
    sudo chmod a+r /etc/event.d/confluence-up /etc/event.d/confluence-down

RELATED TOPICS

Starting Confluence Automatically on System Startup

Last modified on Dec 14, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.