Blog

Installing Atlassian Confluence on CentOS Linux (RHEL) Server or VPS

This guide covers how to install Confluence, the team collaboration software from Atlassian, on a RHEL or CentOS server. The guide has been tested on CentOS 7.

How to Install Confluence

Prerequisites

We will be using a CentOS 7 Linux VPS for this tutorial. Before proceeding you should check the minimum system requirements for the version of Confluence you are installing.

The server on which you will install Confluence will need a basic LAMP stack installed (Linux, Apache, MySQL & PHP).

Use the following one-line command for an expedient set up of your LAMP server on your CentOS server:

sudo sh -c "yum install httpd httpd-devel mysql mysql-server mysql-devel php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml -y; service mysqld start && mysql_secure_installation && service mysqld restart && service httpd start && chkconfig httpd on && chkconfig mysqld on"

Confluence Installation

UPDATE THE SYSTEM

As always, make sure your server is fully up-to-date with the command below:

# yum update

Also, install a text editor of your choice. We will use nano as our text editor:

# yum install nano
INSTALL AND SETUP JAVA

Confluence requires JAVA in order to run. We are going to install Oracle’s JAVA JDK 8. Use the command below to download JDK 8:

# wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.rpm" -O /opt/jdk-8-linux-x64.rpm

Install JAVA:

# yum install /opt/jdk-8-linux-x64.rpm

Configure the JAVA package using the alternatives command:

# JDK_DIRS=($(ls -d /usr/java/jdk*))

# JDK_VER=${JDK_DIRS[@]:(-1)}

# alternatives --install /usr/bin/java java /usr/java/"${JDK_VER##*/}"/jre/bin/java 20000

# alternatives --install /usr/bin/jar jar /usr/java/"${JDK_VER##*/}"/bin/jar 20000

# alternatives --install /usr/bin/javac javac /usr/java/"${JDK_VER##*/}"/bin/javac 20000

# alternatives --install /usr/bin/javaws javaws /usr/java/"${JDK_VER##*/}"/jre/bin/javaws 20000

# alternatives --set java /usr/java/"${JDK_VER##*/}"/jre/bin/java

# alternatives --set javaws /usr/java/"${JDK_VER##*/}"/jre/bin/javaws

# alternatives --set javac /usr/java/"${JDK_VER##*/}"/bin/javac

You can check if JAVA has been properly setup on your server using:

# java -version
INSTALL MYSQL

You need to install MySQL from the community repository.

Download and install the repo:

# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

# sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

Update the package index:

# yum update

Now install and start MySQL:

# yum install mysql-server mysql-client

# systemctl start mysqld

Enable MySQL to start on boot:

# systemctl enable mysqld

With the MySQL installation out of our way, we can now create a database for the Confluence installation. But first, run the mysql_secure_installation script to harden your MySQL server:

# mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Now, log into MySQL as root and create the database:

# mysql -u root -p

mysql> CREATE DATABASE confluence CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON confluence.* TO 'confluenceuser'@'localhost' IDENTIFIED BY 'your_password';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
INSTALL CONFLUENCE

You need to download the appropriate Confluence ‘Linux 64-bit/ 32-bit installer’ from their download page.
We are using a 64-bit CentOS 7 VPS, so we will use the 64-bit installer.

You can use the arch command to check whether you are running a 64 or 32 bit OS on your server. For example our CentOS 7 OS is 64-bit:

[root@linuxvps /]# arch
x86_64

Ok, now let’s get down to business. We are downloading the 64-bit installer:

# wget https://downloads.atlassian.com/software/confluence/downloads/atlassian-confluence-5.9.1-x64.bin

Make the bin file executable:

# chmod a+x atlassian-confluence-5.9.1-x64.bin

Run the installer with ‘root‘ user privileges and the installation will create a dedicated Linux user account named ‘confluence‘ which will be used to run Confluence:

# ./atlassian-confluence-5.9.1-x64.bin

You will get the following output:

Unpacking JRE ...
Starting Installer ...
Dec 03, 2015 10:43:54 AM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.

This will install Confluence 5.9.1 on your computer.
OK [o, Enter], Cancel [c]

Press enter.

Choose the appropriate installation or upgrade option.
Please choose one of the following:
Express Install (uses default settings) [1],
Custom Install (recommended for advanced users) [2, Enter],
Upgrade an existing Confluence installation [3]

You can proceed with a custom install if you want, but we will enter 1 in our CLI for an Express install with the default settings:

See where Confluence will be installed and the settings that will be used.
Installation Directory: /opt/atlassian/confluence
Home Directory: /var/atlassian/application-data/confluence
HTTP Port: 8090
RMI Port: 8000
Install as service: Yes
Install [i, Enter], Exit [e]

Press Enter again to start the Confluence installation which will give you the below output:

Extracting files ...

Please wait a few moments while Confluence starts up.
Launching Confluence ...
Installation of Confluence 5.9.1 is complete
Your installation of Confluence 5.9.1 is now ready and can be accessed via
your browser.
Confluence 5.9.1 can be accessed at http://localhost:8090
Finishing installation ...

As you can see, Confluence is listening on port 8090. You can change this and the URI path in the server.xml file. And indeed, we need to change the URL from which we will access Confluence. Therefore, enter the conf directory:

# cd /opt/atlassian/confluence/conf

However, you need to shutdown Confluence first and then edit the server.xml file.

# sh /opt/atlassian/confluence/bin/shutdown.sh

# nano server.xml

Now, find the ‘localhost’ value and replace it with your server IP address.

Save and exit the file. Next step is to configure a MySQL datasource connection for Confluence. In order to do that, you need to install the MySQL JDBC driver. Below is the procedure to do that. Execute the below commands:

# cd /opt
# wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.35.tar.gz
# tar -zxvf mysql-connector-java-5.1.35.tar.gz
# cd /opt/mysql-connector-java-5.1.35
# mv mysql-connector-java-5.1.35-bin.jar /opt/atlassian/confluence/confluence/WEB-INF/lib/

With these commands you are downloading the JDBC driver in the /opt directory, extracting it and then move the unpacked jar file in the appropriate Confluence directory (/opt/atlassian/confluence/confluence/WEB-INF/lib/).

Next, edit the server.xml file again:

# nano /opt/atlassian/confluence/conf/server.xml

Find the following lines:

<Context path="" docBase="../confluence" debug="0" reloadable="true">
   <!-- Logger is deprecated in Tomcat 5.5. Logging configuration for Confluence is specified in confluence/WEB-INF/classes/log4j.properties -->

Insert the underneath lines within the Context element (between the ‘<Context path=”” docBase=”” ‘ and ‘<!– Logger is deprecated in Tomcat 5.5.” ‘ line):

<Resource name="jdbc/confluence" auth="Container" type="javax.sql.DataSource"
          username="confluenceuser"
          password="your_password"
          driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost:3306/confluence?useUnicode=true&amp;characterEncoding=utf8"
          maxActive="15"
          maxIdle="7"
          defaultTransactionIsolation="READ_COMMITTED"
          validationQuery="Select 1" />

Of course replace your_password with the password you configured during the creation of the confluence database. Save and close the file. Now edit the web.xml file located in the WEB-INFdirectory:

# nano /opt/atlassian/confluence/confluence/WEB-INF/web.xml

Insert the following components just before </web-app> near the end of the file:

<resource-ref>
    <description>Connection Pool</description>
    <res-ref-name>jdbc/confluence</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>

Save and close the web.xml file.

After all these changes you’ve made to the configuration files, you can now start Confluence. Issue this command:

# sh /opt/atlassian/confluence/bin/start-confluence.sh

For troubleshooting use the Confluence log file (/opt/atlassian/confluence/logs/catalina.out).

You can now finish the Confluence installation at: http://your_server_IP:8090 . You will be welcomed by the installation page as shown in the picture below:

confluence

Click on Production Installation (you can choose a Trial Installation of course, since the Product install requires you to have an active Confluence license), choose if you want to have an addon and enter your license key in the following screen.

Then, set up the database. Choose MySQL and Direct JDBC Connection. Enter the corresponding settings:

Driver Class Name: com.mysql.jdbc.Driver

Database URL: jdbc:mysql://localhost:3306/confluence?useUnicode=true&characterEncoding=utf8

Username: confluenceuser

Password: your_password

Then click on Next and finish the Confluence configuration.

Congratulations, if you followed our steps carefully you now have a fully working Confluence installation on your CentOS 7 VPS. For more information about Confluence, visit their official documentation.

Using A Custom Domain Name with Confluence

To use a custom domain with Confluence, simply configure an A Record at your domain provider, or wherever DNS for your domain is hosted. The A record should look like this:

documentation A 101.102.103.104

Replace the IP above with the address of your Confluence server. This will point http://documentation.domain.com to your Confluence server.

This entry was posted in Guides & How To's, Linux VPS, VPS Hosting. Bookmark the permalink. Trackbacks are closed, but you can post a comment.



Questions? We're here to help.