In this post I will go through the full fresh installation of Atlassian on Centos7. I have fresh Centos installation which I will dedicate it to Bitbucket server. I will also use PostgreSQL as database. Atlassian has a guide for this but it is very generic to cover all possible combinations and doesn’t go into the details of installation and configuration of database. This post will have all you need to know on how to install Atlassian Bitbucket on Centos 7 in one place.
All the details and screenshots are correct for below:
OS: Centos 7 ( Linux 3.10.0-327.4.5.el7.x86_64)
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 mkdir /opt/downloads cd /opt/downloads/
sudo wget https://downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-4.3.2-x64.bin sudo chmod +x atlassian-bitbucket-4.3.2-x64.bin
sudo ./atlassian-bitbucket-4.3.2-x64.bin Unpacking JRE ... Starting Installer ... Feb 15, 2016 2:53:02 PM java.util.prefs.FileSystemPreferences$1 run INFO: Created user preferences directory. Feb 15, 2016 2:53:02 PM java.util.prefs.FileSystemPreferences$2 run INFO: Created system preferences directory in java.home. This will install Bitbucket 4.3.2 on your computer. OK [o, Enter], Cancel [c] o Please choose one of the following: Install a new instance [1, Enter], Upgrade an existing instance , Install a new mirror , Upgrade an existing mirror  1 Where should Bitbucket be installed? [/opt/atlassian/bitbucket/4.3.2] Default location for Bitbucket home directory The location for Bitbucket data. This will be the default location for repositories, plugins, and other data. Ensure that this location is not used by another Bitbucket installation. [/var/atlassian/application-data/bitbucket] Configure which ports Bitbucket will use. Bitbucket requires two TCP ports that are not being used by any other applications. The HTTP port is where users will access Bitbucket through their browsers. The control port is used to start and stop Bitbucket. HTTP Port Number  8060 Control Port Number  For a production server we recommend that you run Bitbucket as a Windows/Linux service because Bitbucket will restart automatically when the computer restarts. Install Bitbucket as a service? Yes [y, Enter], No [n] y Please review your Bitbucket installation settings Installation Directory: /opt/atlassian/bitbucket/4.3.2 Home Directory: /var/atlassian/application-data/bitbucket HTTP Port: 8060 Control Port: 8006 Install as a service: Yes Install [i, Enter], Exit [e] i Extracting files ... atlassian-bitbucket/WEB-INF/osgi-framework-bundles/org.apache.servicemix. Installation of Bitbucket is complete Would you like to launch Bitbucket? Yes [y, Enter], No [n] y Please wait a few moments while Bitbucket starts up. Launching Bitbucket ... Installation of Bitbucket 4.3.2 is complete Your installation of Bitbucket 4.3.2 is now ready and can be accessed via your browser. Bitbucket 4.3.2 can be accessed at http://localhost:8060 Launch Bitbucket 4.3.2 in browser? Yes [y, Enter], No [n] n saeed@merrikh:/opt/downloads$
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
sudo firewall-cmd --zone=public --add-port=8060/tcp --permanent
Then remember to reload the firewall for changes to take effect.
sudo firewall-cmd --reload
install database engine and connector
Atlassian highly recommends not to use MySQL/MariaDB for the external database in real servers for Bitbucket. It seems to have performance and bug issues. PostgreSQL instead is the recommended database engine. So here i will install them.
sudo yum localinstall http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm sudo yum install postgresql95-server
After installing the packages, a database needs to be initialised and configured.
The PostgreSQL data directory has all the data files for the database. The variable PGDATA is used to reference this directory.
export PGDATA /var/lib/pgsql/9.5/data
The first command (only needed once) is to initialise the database in PGDATA.
sudo /usr/pgsql-9.5/bin/postgresql95-setup initdb
To control the database service in RHEL 7.1+ and CentOS 7.1+, Systemd is introduced.
Use this to start the service and make sure it starts at the startup:
systemctl start postgresql-9.5.service systemctl enable postgresql-9.5.service
create and setup database
su - now you're loged in as admin. #su - postgres -bash-4.2$ psql psql (9.2.14, server 9.5.1) WARNING: psql version 9.2, server version 9.5. Some psql features might not work. Type "help" for help. Now you are in the psql environment. run below commands CREATE SCHEMA bitbucket; CREATE USER bitbucketuser PASSWORD 'bitbucketdbpassword'; GRANT ALL ON SCHEMA bitbucket TO bitbucketuser; GRANT ALL ON ALL TABLES IN SCHEMA bitbucket TO bitbucketuser; CREATE DATABASE bitbucket WITH ENCODING='UTF8' OWNER=bitbucketuser CONNECTION LIMIT=-1;
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/9.5/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 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 bitbucket server.
Set up Bitbucket
Now open web browser and point to the address that you installed the server.
Select the language and PostgreSQL as external database.
If you see this error in this page after hitting the Test button, make sure your authentication configuration is correct. check,
pg_hba.conf file and run
netstat -ntl and make sure your server is listening on port 5432.
That should be it. Enjoy managing your codes in Bitbucket.