Start Confluence Automatically on Linux
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:
Create a
confluence
user for instance, using the following command:sudo useradd --create-home -c "Confluence role account" confluence
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
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
- 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 '#')
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).
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
Make this file executable:
sudo chmod +x /etc/init.d/confluence
- 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
orrcconf
on Debian-based systems. 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/
The port for this will be whatever is defined in your Confluenceserver.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):
After logging in as the
confluence
user to install Confluence, createstart
andstop
scripts in/usr/local/confluence
:
Examplestart
script:#!/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
Examplestop
script:#!/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
- Make both of these scripts executable. For example, by issuing the command:
sudo chmod a+x /usr/local/confluence/start /usr/local/confluence/stop
. Karmic and later: Create two text files in
/etc/init/
calledconfluence-up.conf
andconfluence-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
Jaunty, Intrepid: Create two text files in
/etc/event.d/
calledconfluence-up
andconfluence-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