How to install Confluence on Centos7 with PostgreSQL

Edit 2018-03-06: I created a script that will do all the steps described on this page and the second part on this page in one place in much easier way. You can download it from github.


Up until now I always have used Mysql server for Confluence instances. PostgreSQL is Atlassian preferred database for Confluence and their other products. So I will go through installation steps for this configuration. I already have a fresh minimal Centos 7 installation.

Atlassian has a guide for this but it is generic covering all possible combinations and for this specific installation one need to jump between various pages. This post will have all you need to know on how to install Atlassian Confluence on Centos 7 in one place.

After you completed steps in this post, you can continue to make your connections secure and encryptedby following the steps on this page. http://comtronic.com.au/how-to-enable-ssl-on-confluence-centos-7/

 

All the details and screenshots are correct for below:

OS: Centos 7 ( Linux 3.10.0-327.36.3.el7.x86_64)
Confluence Software:  atlassian-confluence-6.0.1-x64
Database: PostgreSQL-9.2.15

Preparation

Before start, you need to decide where to download your resources. I usually have my resources in one place. Create a folder for it if you haven’t got one.

sudo yum update
sudo yum install vim wget
sudo mkdir /opt/atlassian
cd /opt/atlassian/

Download

sudo wget https://downloads.atlassian.com/software/confluence/downloads/atlassian-confluence-6.0.1-x64.bin
sudo chmod +x atlassian-confluence-6.0.1-x64.bin

Install

sudo ./atlassian-confluence-6.0.1-x64.bin

Unpacking JRE ...
Starting Installer ...
Nov 05, 2016 10:54:28 PM java.util.prefs.FileSystemPreferences$2 run
INFO: Created system preferences directory in java.home.

This will install Confluence 6.0.1 on your computer.
OK [o, Enter], Cancel [c]
o
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],
Upgrade an existing Confluence installation [3, Enter]
2
.
.
.

Extracting files ...


Please wait a few moments while Confluence starts up.
Launching Confluence ...
Installation of Confluence 6.0.1 is complete
Your installation of Confluence 6.0.1 is now ready and can be accessed via
your browser.

Confluence 6.0.1 can be accessed at http://localhost:8090

Confluence 6.0.1 may take several minutes to load on first start up.
Finishing installation ...
[saeed@moshtari opt]$


Open firewall ports

Centos 7 now comes with firewalld pre-installed and activated by default. You need to open the needed ports to be able to access to the server through web browser.

First check the active zones:

firewall-cmd --get-active-zones
public
  interfaces: eth0
then you can add the ports needed to the zones you want (public here)
sudo firewall-cmd --zone=public --add-port=8090/tcp --permanent

Confluence is going to be the only web service on this machine. So to save typing in the port number each time, I use firewalld to redirect port 80 to 8090. So I just type in my server name and internally port 8090 is called. So instead of the above port you need to go through below lines:

sudo firewall-cmd --zone=public --add-masquerade --permanent sudo firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=8090 --permanent
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent

Remember to reload the firewall for changes to take effect.

sudo firewall-cmd --reload

Now if you have the correct DNS server set-up, to get to the Confluence home page you just need to point to the server host name (http://localhost) rather than http://localhost:8090.

Install database engine and connector

Atlassian’s recommended database engine for Confluence is PostgreSQL. It is also easiest option to install because it doesn’t need extra steps to download Java connector separately.

sudo yum install postgresql-server

Post-installation commands

After installing the packages, a database needs to be initialised and configured.

Initialise

The first command (only needed once) is to initialise the database in PGDATA.

sudo postgresql-setup initdb

Initializing database ... OK

Control service

To control the database service in RHEL 7.1+ and CentOS 7.1+, Systemd is introduced.

Use this to start the service and also make sure it starts at the system start-up

sudo systemctl start postgresql
sudo systemctl enable postgresql

create and set-up database

sudo -u postgres -i
-bash-4.2$ psql
psql (9.2.15)
Type "help" for help.

CREATE USER confdbuser PASSWORD 'confdbpassword';
CREATE SCHEMA confluence;
GRANT ALL ON SCHEMA confluence TO confdbuser;
GRANT ALL ON ALL TABLES IN SCHEMA confluence TO confdbuser;
CREATE DATABASE confluencedb WITH ENCODING='UTF8' OWNER=confdbuser CONNECTION LIMIT=-1;
\q

 

configure authentication methods

default authentication method for local connections in PostgreSQL is set to ‘ident’ that means it will get the operating system user name of the client by contacting the ident server on the client and check if it matches the requested database user name. You can read more on this on official PostgreSQL site.

As we are not planing to have a ident server this needs to be updated. I use md5 method. Other methods can be used too depending on the situation. All these settings resting in pg_hba.conf file in data folder of the postgresql installation.

so need to do below:

sudo vim /var/lib/pgsql/data/pg_hba.conf

just one line needs to be updated. It is towards the end of the file (line 82 in my case) the one starts with host.

this line:

host    all             all             127.0.0.1/32            ident

needs to be updated to:

host    all             all             127.0.0.1/32            md5

then restart the service.

Now all is set to start setting up your server.

Set up Confluence

Now open web browser and point to the address that you installed the server.

Select the language and PostgreSQL as external database.

conf-1-setup-confluence conf-2-get-addons conf-3-license-key conf-4-choose-db-config conf-5-config-db-con conf-6-config-db conf-7-load-content conf-8-config-user conf-9-connect-to-jira conf-10-user-sync conf-11-setup-finished

9 Comments

  1. Updating postgres to 0.0.0.0 means it listens on all interfaces, this might not be a good idea with a VPS or any server with an interface that listens on the internet.

    1. Hi Luke, thanks for reading the post and your comment. You are right it is better to limit it to listen just locally. I think at the time i had trouble getting it working and just wide opened it to get it working.
      Updated the post with your comment.
      host all all 127.0.0.1/32 md5

  2. Thank you so much for this write up. I had trouble connecting to the database. I restarted the postgresql service and it connected. “sudo service postgresql restart”

  3. Thank you for writing up the procedure – I am trialing Confluence at home, see if we find it useful around-the-house knowledge management

Leave a Reply