UPDATE --July-2018 Original instruction was installing postgresql-server-9.2. Atlassian has dropped support for v9.2 for newer versions. The post updated to install Postgresql-server v9.6 instead. If you have followed original post, and now want to update your database server to the latest, you can follow this post: How to upgrade Postgresql server to v9.6
Update 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 encrypted by 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 set-up:
OS: Centos 7.5 ( Linux 3.10.0-327.36.3.el7.x86_64)
Confluence Server: atlassian-confluence-6.10.1-x64
Database Server: PostgreSQL-9.6.9
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
Install database server
Atlassian’s recommended database engine for Jira is PostgreSQL. It is also easiest option to install because it doesn’t need extra steps to download Java connector separately.
The version that Centos7 repository includes at the moment is v9.2. It not supported by Atlassian products any more. So will need to use community repository the get the latest version of v9.6.
sudo yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm sudo yum install postgresql96-server
After installing the packages, you need to initialise and configure it.
Initialise
sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb Initializing database ... OK
Control service
sudo systemctl enable postgresql-9.6 sudo systemctl start postgresql-9.6
create and set-up database
sudo -u postgres -i -bash-4.2$ psql psql (9.6.9) Type "help" for help. postgres=# CREATE USER confluencedbuser PASSWORD 'confluencedbpassword'; postgres=# CREATE DATABASE confluencedb WITH ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C' TEMPLATE template0; postgres=# GRANT ALL PRIVILEGES ON DATABASE confluencedb to confluencedbuser; \q
-bash-4.2$ exit
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. You can consider other methods 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 -u postgres -i -bash-4.2$ vim /var/lib/pgsql/9.6/data/pg_hba.conf
Update the line beginning with host
. 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
change it to:
host all all 127.0.0.1/32 md5
Open firewall ports
Centos 7 now comes with firewalld
pre-installed and activated in some templates by default. You need to
open the needed ports to get 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
If you want to redirect the traffic to port 80 for the ease of access follow the next commands, otherwise you can skip them.
It is not recommended for production servers that are open to public. For production servers you can follow my other post to serve on https here. How to enable ssl for Jira Software on Centos7
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 Jira home page you just need to point to the server host name (http://localjiraserver) and not http://localjiraserver:8090.
Download and Install Confluence
sudo mkdir /opt/atlassian
cd /opt/atlassian/
sudo wget https://downloads.atlassian.com/software/confluence/downloads/atlassian-confluence-6.10.1-x64.bin sudo chmod +x atlassian-confluence-6.10.1-x64.bin
Install
sudo ./atlassian-confluence-6.10.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.10.1 on your computer.
OK [o, Enter], Cancel [c] o Click Next to continue, or Cancel to exit Setup.
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] 2
Select the folder where you would like Confluence 6.10.1 to be installed, then click Next.
Where should Confluence 6.10.1 be installed? [/opt/atlassian/confluence]
Default location for Confluence data [/var/atlassian/application-data/confluence]
Configure which ports Confluence will use. Confluence requires two TCP ports that are not being used by any other applications on this machine. The HTTP port is where you will access Confluence through your browser. The Control port is used to Startup and Shutdown Confluence.
Use default ports (HTTP: 8090, Control: 8000) - Recommended [1, Enter], Set custom value for HTTP and Control ports [2] 1
Confluence can be run in the background. You may choose to run Confluence as a service, which means it will start automatically whenever the computer restarts. Install Confluence as Service? Yes [y, Enter], No [n] y. Extracting files ...
Please wait a few moments while we configure Confluence.
Installation of Confluence 6.10.1 is complete Start Confluence now? Yes [y, Enter], No [n] y
Please wait a few moments while Confluence starts up. Launching Confluence ... Installation of Confluence 6.10.1 is complete Your installation of Confluence 6.10.1 is now ready and can be accessed via your browser. Confluence 6.10.1 can be accessed at http://localhost:8090 Confluence 6.10.1 may take several minutes to load on first start up. Finishing installation ...
Now all is set to start setting up your server.
Set up Confluence
Open your
web browser and point to the address that you installed the server.
Select the language and PostgreSQL as external database.
thanks this made the process extremely simple
you are welcome 🙂
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.
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
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”
perfect. glad it was helpful 🙂
Thank you Saeed. What a big help this was!
Thank you for writing up the procedure – I am trialing Confluence at home, see if we find it useful around-the-house knowledge management
Hey.
Once you reboot the machine, it does not run the bloody confluence.
Anyone else experienced the same issues?
Thank you very much , this is the best tutorial I ever seen