Installing BitBucket on FreeBSD 11.1

Step by step instructions on installing BitBucket on FreeBSD 11.1.

Install OpenJDK

pkg install openjdk8

Mount filesystems on boot

Add the two following lines to /etc/fstab:

fdesc   /dev/fd         fdescfs         rw      0       0
proc    /proc           procfs          rw      0       0
Mount the two filesystems so you don’t have to reboot.
mount -t fdescfs fdesc /dev/fd
mount -t procfs proc /proc

Install Perl

pkg install perl5

Install Git

pkg install git

Install bash

pkg install bash
cd /bin
ln -s /usr/local/bin/bash

Install PostgreSQL

pkg install postgresql96-server
echo 'postgresql_enable="YES"' >> /etc/rc.conf
/usr/local/etc/rc.d/postgresql initdb
/usr/local/etc/rc.d/postgresql start

Configure PostgreSQL

su - postgres
createuser -sdrP dba
psql
CREATEROLE bitbucketuser WITHLOGIN PASSWORD'foobar'VALID UNTIL 'infinity';
CREATEDATABASEbitbucket WITHENCODING='UTF8'OWNER=bitbucketuser CONNECTIONLIMIT=-1;

Create a user for BitBucket

adduser #default values for all but Shell; set bash as the shell.

Install BitBucket

Download bitbucket from Atlassian’s website. Thoose the “TAR.GZ Archive” version.
tar xzf atlassian-bitbucket-5.8.1.tar.gz -C /usr/local
cd /usr/local
mv atlassian-bitbucket-5.8.1/ bitbucket
chown -R bitbucket:bitbucket bitbucket
cd /usr/local/etc
mkdir bitbucket
chown -R bitbucket:bitbucket bitbucket
su - bitbucket
Edit bitbucket’s .profile file:
  • Add and export JAVA_HOME.
  • Append JAVA_HOME/bin to PATH (uncomment PATH if commented out)
  • Add BITBUCKET_HOME=/usr/local/etc/bitbucket; export BITBUCKET_HOME 

Start BitBucket

cd /usr/local/bitbucket/bin
./start-bitbucket.sh