Installing Phabricator

Installing Phabricator

 

Phabricator is a complete set of tools for developing software. Included apps help you manage tasks and sprints, review code, host git, svn, or mercurial repositories, build with continuous integration, review designs, discuss in internal chat channels, and much more. It's fast, scalable, and fully open source. Install it locally with no limitations, or have us host it for you.

In this guide i will take you step by step on how to install it on Debian Jesssie

Update and Upgrade your Debian installation

This is something you must always do to make sure you have the latest packages available.
apt-get update
apt-get dist-upgrade
Create the directory where you will install phabricator
mkdir -p /var/www/ph
 

Prerequisite

apt-get install sudo   nginx php5 php5-cgi php5-fpm

Next, get php-fpm to listen on the correct host/port. In /etc/php5/fpm/pool.d/www.conf change the listen value to match the fastcgi_pass location in your Nginx configuration. For example, I changed mine from:

listen = /var/run/php5-fpm.sock

To:

listen = 127.0.0.1:9000

There is a script for ubuntu and centos for auto installation but may give errors on ubuntu so i modified the script

#!/bin/bash

confirm() {
  echo "Press RETURN to continue, or ^C to cancel.";
  read -e ignored
}

GIT='git'

LTS="Ubuntu 10.04"
ISSUE=`cat /etc/issue`
if [[ $ISSUE != Debian* ]]
then
  echo "This script is intended for use on Ubuntu, but this system appears";
  echo "to be something else. Your results may vary.";
  echo
  confirm
elif [[ `expr match "$ISSUE" "$LTS"` -eq ${#LTS} ]]
then
  GIT='git-core'
fi

echo "PHABRICATOR UBUNTU INSTALL SCRIPT";
echo "This script will install Phabricator and all of its core dependencies.";
echo "Run it from the directory you want to install into.";
echo

ROOT=`pwd`
echo "Phabricator will be installed to: ${ROOT}.";
confirm

echo "Testing sudo..."
sudo true
if [ $? -ne 0 ]
then
  echo "ERROR: You must be able to sudo to run this script.";
  exit 1;
fi;

echo "Installing dependencies: git, apache, mysql, php...";
echo

set +x

sudo apt-get -qq update
sudo apt-get install \
  $GIT mysql-server apache2 dpkg-dev \
  php5 php5-mysql php5-gd php5-dev php5-curl php-apc php5-cli php5-json

# Enable mod_rewrite
sudo a2enmod rewrite

HAVEPCNTL=`php -r "echo extension_loaded('pcntl');"`
if [ $HAVEPCNTL != "1" ]
then
  echo "Installing pcntl...";
  echo
  apt-get source php5
  PHP5=`ls -1F | grep '^php5-.*/$'`
  (cd $PHP5/ext/pcntl && phpize && ./configure && make && sudo make install)
else
  echo "pcntl already installed";
fi

if [ ! -e libphutil ]
then
  git clone https://github.com/phacility/libphutil.git
else
  (cd libphutil && git pull --rebase)
fi

if [ ! -e arcanist ]
then
  git clone https://github.com/phacility/arcanist.git
else
  (cd arcanist && git pull --rebase)
fi

if [ ! -e phabricator ]
then
  git clone https://github.com/phacility/phabricator.git
else
  (cd phabricator && git pull --rebase)
fi

echo
echo
echo "Install probably worked mostly correctly. Continue with the 'Configuration Guide':";
echo
echo "    https://secure.phabricator.com/book/phabricator/article/configuration_guide/";
echo
echo "You can delete any php5-* stuff that's left over in this directory if you want.";

copy this file in /var/www/ph and unzip it

unzip /var/www/ph/phabricator-debian.zip

Now just run the script

/var/www/ph/phabricator-debian

 

This script install everything for you including mysql php and clones the phabriator repository for you

After the installation is done you will now have /var/www/ph/phabricator folder which contains the phabricator code and site.

install nginx

apt-get install nginx

We now need to modify nginx to serve phabricator via ssl. keep in mid that i am using letsencryot certificates that is why i have the /.well_known path.

server {
 listen 80;
 server_name example.com;
 return 301 https://example.com;
}




server
{
 # Change to your real subdomain, e.g. phabricator.mysite.com
 server_name example.com;
 listen 443 ssl default_server;

 # Update to the directory where you've installed Phabricator.
 root /var/www/ph/phabricator/webroot;
 try_files $uri $uri/ /index.php;
ssl on;
 ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
 ssl_session_timeout 30s;


 location /
 {
 index index.php;

 if ( !-f $request_filename )
 {
 rewrite ^/(.*)$ /index.php?__path__=/$1 last;
 break;
 }
 }

 location /index.php
 {
 fastcgi_pass localhost:9000;
 fastcgi_index index.php;

 #required if PHP was built with --enable-force-cgi-redirect
 fastcgi_param REDIRECT_STATUS 200;

 #variables to make the $_SERVER populate in PHP
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_param QUERY_STRING $query_string;
 fastcgi_param REQUEST_METHOD $request_method;
 fastcgi_param CONTENT_TYPE $content_type;
 fastcgi_param CONTENT_LENGTH $content_length;

 fastcgi_param SCRIPT_NAME $fastcgi_script_name;

 fastcgi_param GATEWAY_INTERFACE CGI/1.1;
 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

 fastcgi_param REMOTE_ADDR $remote_addr;

 }


location /.well-known {
 default_type text/plain;
 root /var/www/letsencrypt/webroot;
}




}

 

One the site is up and running it will complain about setup issues

In oder to solve some of these issues you must modify /etc/mysql/my.cf with the following

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
sql_mode = STRICT_ALL_TABLES
ft_stopword_file=/var/www/ph/phabricator/resources/sql/stopwords.txt
ft_min_word_len = 3
ft_boolean_syntax =' |-><()~*:""&^'
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 16M
max_allowed_packet = 34M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#slow_query_log_file = /var/log/mysql/mysql-slow.log
#slow_query_log = 1
#long_query_time = 2
#log_queries_not_using_indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d

To get ldap working you must first install

 apt-get install php5-ldap

There is also a problem with /var/www/ph/libphutil/src/auth/PhutilLDAPAuthAdapter.php where i had to comment out a line in the code otherwise authentication wouldnt work

 

      $message,                                                                                                                                 
         $errno,                                                                                                                                          
         $error);                                                                                                                                     
     } else {                                                                                                                                           
       $full_message = pht(                                                                                                                            
         'LDAP Exception: %s',                                                                                                                            
         $message);                                                                                                                                       
     }                                                                                                                                                   
                                                                                                                                                        
     #throw new Exception($full_message);                                                                                   
   }                                                                                                                                                   
                                                                                                                                                          
   private function bindLDAP($conn, $user, PhutilOpaqueEnvelope $pass) {                                                                                  │···············
     $profiler = PhutilServiceProfiler::getInstance();                                                                                                    │···············
     $call_id = $profiler->beginServiceCall(                                                                                                              │···············
       array(            

 

Set pahabricator base url to

bin/config set phabricator.base-uri 'http://example.com/'

 

And thats it you should be good to go.

If you wish to test that the ldap configurations you added are correct , use the following to test binding against ldap

bin/auth ldap --trace