Installation/FreeBSD
Caveat
This guide is intended for experienced FreeBSD administrators. It is not intended as an introduction to FreeBSD. It uses a combination of ports and packages and takes a while to get everything compiled and running properly.
Note that while this guide applies to multiple versions, behaviors and performance on 10.0-RELEASE may be different as a result of changing the system compiler from GNU gcc to LLVM clang.
Versions
These instructions apply to FreeBSD 9.2-RELEASE and 10.0-RELEASE. It is generally not recommended to run Diaspora* on versions prior to these as they have either reached or will reach end of life in the foreseeable future.
Package Management
Use of the `portmaster` ports management tool is recommended. Use of pkgng is required for consistency. pkg_* is obsoleted and should not be used for new installs.
You should run pkg
followed by pkg2ng
and set up /etc/make.conf
before installing ports-mgmt/portmaster
.
Prerequisites
It is assumed that you have a fresh install of FreeBSD, using portsnap for ports tree management. You will also need a non-root user that will own the Diaspora* installation and processes.
make.conf
It is vitally important that you do not use tabs in make.conf. This will break your system! The settings here are in addition to any others you already have, and are required to prevent conflicts.
WITH_PKGNG=yes
WITHOUT="X11"
OPTIONS_UNSET=X11
# DO NOT USE SPACES OR COMMENTS IN THE FOLLOWING LINE EVER!
DEFAULT_VERSIONS= perl5=5.16 ruby=2.1 python=2.7 postgresql=9.3 mysql=5.5
PERL5_DEFAULT=5.16
RUBY_VER=2.1
WANT_PGSQL_VER=93
WANT_MYSQL_VER=55 # 55m for MariaDB, 55p for Percona
Prerequisite Packages for Building
The following packages will be required before you begin building Diaspora* on FreeBSD:
- ports-mgmt/portmaster
- security/ca_root_nss
- devel/git
You should select CURL
support for devel/git
. This will pull in the ftp/curl
dependency. The ETCSYMLINK
option in ca_root_nss is optional and not required.
The following packages are optional but recommended before you begin building Diaspora* on FreeBSD:
- shells/bash
- security/sudo
Building Required Packages
The complete list of required packages (which will automatically pull in related dependencies) is as follows. Again note that this is not a comprehensive list of installed packages, but rather the packages you must have, in the order required to pull in all of the required dependencies.
databases/postgresql93-server
- graphics/ImageMagick-nox11
- databases/sqlite3
- databases/redis
lang/ruby21
ORlang/ruby20
matching what you set in make.conf!sysutils/rubygem-bundler
www/node
PostgreSQL
PostgreSQL will always offer the best performance on FreeBSD, especially on multi-core systems. 9.3 offers significant performance benefits over prior versions as well.
You will need to install:
- databases/postgresql93-server
Optionally, you may also want to install:
- databases/postgresql93-contrib
As tempting as it may be, do NOT install PL/Ruby. It has not been maintained for years and contains significant security vulnerabilities which will result in the compromise of your pod.
Options: databases/postgresql93-server
The only mandatory options are INTDATE, NLS, SSL, TZDATA
, and XML
which are set by default.
OPTIMIZED_CFLAGS
is optional but not recommended on 10.0-RELEASE systems at this time.
ImageMagick
It is very important to note that there are two ImageMagick 'base' ports, both of which will pull in many many dependencies. Only ever use graphics/ImageMagick-nox11
. It is strongly recommended that you use portmaster to build ImageMagick locally, as the default packages will pull in numerous dependencies which you do not need for Diaspora*.
Options: graphics/ImageMagick-nox11
It is recommended that you set only these options:
16BIT_PIXEL
- BZIP2
- FONTCONFIG
- FREETYPE
- JPEG
- LQR
- LZMA
- MODULES
- PERL
- PNG
- THREADS
TIFF
This will minimize the number of dependencies which are pulled in. Do not select both JASPER
and JPEG
as this will cause the build to fail. THREADS
introduces no additional dependencies and will offer faster performance on most systems.
Other options which you may wish to set, but are entirely optional:
DOCS
- FFTW
- GRAPHVIZ
- HDRI
OPENEXR
Note that ImageMagick has a very ugly, nasty, long dependency chain so it is in your best interests to try and minimize it. You should always include PERL
, since this will only pull in PCRE - a required package - if it is missing.
Options: print/ghostscript9-nox11
Unfortunately, this package is unavoidable, and will take you longer to set the options on than it takes to build. Do NOT install ghostscript9-nox11 using pkg as this will pull in over 50MB of pointless dependencies! The FreeBSD package builder uses default options, which means CUPS and every single driver.
The ONLY options you should leave set in ghostscript9-nox11 are:
FONTCONFIG
- ICONV
- GS_jpeg, GS_jpeggray
- GS_bit, GS_bitrgb, GS_bitcmyk
- GS_plan
GS_pngmono, GS_pnggray, GS_png16, GS_png256, GS_png16m, GS_pngalpha, GS_png48
Absolutely all other options should be unset, unless you have a specific reason to include them. You must include GS_plan or the build will fail.
SQLite3
You should always use databases/sqlite3
rather than relying on any built-ins. SQLite3 is true to its name and pulls in essentially no dependencies.
You should generally use the default options. On busy pods or systems with lots of memory, you may wish to select TS2
- Memory by default - over the default of TS1
. However you should only do this if you really know what you're doing!
Redis
When building databases/redis
, you should select the LUA
option only if you plan to use Lua for other things.
Do not select LUAJIT
. This will break things.
Ruby
This is where things get slightly interesting.For this installation, we will presume Ruby 2.1 - however, you can use Ruby 2.0 simply by changing "2.1" to "2.0" in /etc/make.conf
.
Note that you can install multiple Ruby versions without causing conflicts! This is by design! If you do not set up make.conf
correctly, you will have gem version conflicts which will break your installation!
The Ruby port will pull in several dependencies, including Python, which is why you must set a default version for it.
IMPORTANT TEMPORARY WORKAROUND
Your Ruby build will fail out of the box currently (April 2014) on all versions! You must edit lang/ruby21/Makefile
and change:
--enable-dtrace
to
--disable-dtrace
Options: lang/python27
You can use other versions of Python, but 2.7 is the recommended version for most installations. If you will be running other software that depends on Python, use the version most appropriate for that software - usually 2.7 anyways.
Python should use the default options unless other software requires you to set additional options.
Ruby Gems Bundler
You should not use Ruby to install Bundler unless you are installing it locally. Instead, you should use sysutils/rubygem-bundler
to provide a system-wide Bundler install.
You should not install bundle dependencies using ports. This will put you out of sync with Diaspora* recommended/required versions. Only install sysutils/rubygem-bundler
.
Node.js
Node.js does not jump out at most people because of the way it is set up in ports. You are looking for www/node
.
If you require Node Package Manager, you should install www/npm
- however, this is optional as Diaspora* does not require NPM.
Setting up your Diaspora* User
To make life easier for yourself, you should set your Diaspora* environment variables in the shell rc for your shell of choice. Here are some examples:
csh (FreeBSD default)
.cshrc
setenv RAILS_ENV production setenv DB postgres
bash (optional package)
.bashrc
export RAILS_ENV='production' export DB='postgres'
ksh93 (optional package)
.kshrc
RAILS_ENV=production DB=postgres export RAILS_ENV DB
Setting up your Gems correctly
Because FreeBSD ports are always "current", it is guaranteed that you will have version mismatches if you use ports. Similarly, if you install system-wide from gems, you will conflict with ports - often in ways that break Ruby! Therefore, you must _never_ install your Gems system-wide or from ports!
Instead, you should install your Gems under your Diaspora* user's installation to prevent any problems and ensure you have the correct versions.
root@myhost # su - diaspora diaspora@myhost $ cd ~/diasporaInstallDir/ diaspora@myhost ~/diasporaInstallDir/ $ bundle install --without test development --path vendor/bundle
The --path vendor/bundle
will install your Gems to diasporaInstallDir/vendor/bundle.
Congrats! You have all your dependencies installed. Go back to Notes On Installing and Running Diaspora.