Project

General

Profile

Support #436

Updated by Daniel Curtis over 9 years ago

h2. Add the diaspora user 

 * Add the diaspora user along with the group using the helper script: 
 <pre> 
 mkdir /usr/local/www/diaspora 
 adduser 
 Username: diaspora 
 Full name: Diaspora* 
 Uid (Leave empty for default):  
 Login group [diaspora]:  
 Login group is diaspora. Invite diaspora into other groups? []:  
 Login class [default]:  
 Shell (sh csh tcsh bash rbash git-shell nologin) [sh]: bash 
 Home directory [/home/diaspora]: /usr/local/www/diaspora 
 Home directory permissions (Leave empty for default):  
 Use password-based authentication? [yes]: no 
 Lock out the account after creation? [no]:  
 yes 
 no 
 </pre> 

 h3. Package Management 

 * This guide will use portupgrade to manage packages from Use of the `portmaster` ports tree: 
 <pre> 
 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 install portupgrade 
 </pre> followed by pkg2ng and set up /etc/make.conf before installing ports-mgmt/portmaster. 

 h3. 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 

 h2. Prerequisite Packages for Building 

 * The following packages will be required before you begin building Diaspora* on FreeBSD: _ports-mgmt/portmaster_ and _security/ca_root_nss_ 
 <pre> 
 pkg install portmaster ca_root_nss 
 </pre> 

 * The following packages are optional but recommended before you begin building Diaspora* on FreeBSD: _shells/bash_ and _security/sudo_ 
 <pre> 
 pkg install bash sudo 
 </pre> 

 Note that you may choose to use security/openssl instead of the system OpenSSL. However, this must be built first and most packages will NOT use it. 

 h3. Options: _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. devel/git will always pull in Python. 
 <pre> 
 pkg install git subversion 
 </pre> 

 h3. 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. 
 <pre> 
 pkg install python27 curl automake 
 </pre> 

 h3. 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/mariadb55-server databases/postgresql93-server 
 # graphics/ImageMagick-nox11 
 # databases/redis 
 # lang/ruby21 OR lang/ruby20 matching what you set in make.conf! 
 # sysutils/rubygem-bundler 
 # www/node 

 H2. Install RVM 

 * Switch to the diaspora user: 
 <pre> 
 su - diaspora 
 </pre> 

 * Install RVM and Ruby 2.0 
 <pre> 
 curl -sSL https://get.rvm.io | bash -s stable 
 source /usr/local/www/diaspora/.rvm/scripts/rvm 
 echo '[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm"' >> ~/.bashrc 
 rvm autolibs read-fail 
 rvm install 2.0 
 </pre> 

 * Exit back into root: 
 exit 

 h2. MariaDB 5.5 Server 

 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. However my production environment limits the use of PostgreSQL, so I will use MariaDB instead: 
 <pre> 
 pkg install mariadb55-client mariadb55-server 
 </pre> 

 h3. Options: _print/ghostscript9-nox11_ h2. ImageMagick 

 Unfortunately, this package It is unavoidable, and very important to note that there are two ImageMagick 'base' ports, both of which will take pull in many many dependencies. Only ever use _graphics/ImageMagick-nox11_. It is strongly recommended that you longer use portmaster to set build ImageMagick locally, as the options on than it takes to build. Do NOT install ghostscript9-nox11 using pkg as this default packages will pull in over 50MB of pointless dependencies! The FreeBSD package builder uses default options, numerous dependencies which means CUPS and every single driver. 

 * Install ghostscript9-nox11: 
 <pre> 
 cd /usr/ports/print/ghostscript9-nox11 
 portupgrade -Np 
 </pre> 

 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 do not need for Diaspora*. 

 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. 

 h3. Options: _graphics/ImageMagick-nox11_ 

 * Install ImageMagick-nox11: 
 <pre> 
 cd /usr/ports/graphics/ImageMagick-nox11 
 portupgrade -Np 
 </pre> 

 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.  

 

 h3. 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. 

 h2. Redis 

 * Install 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. 
 <pre> 
 pkg install redis 
 </pre> 

 h2. 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 libyaml, libffi, and libexecinfo if they are missing. 

 h3. 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: 
 <pre> 
 --enable-dtrace 
 </pre> 
 to 
 <pre> 
 --disable-dtrace 
 </pre> 

 * Or just install Ruby 2.1 using pkg: 
 <pre> 
 pkg install ruby21 
 </pre> 

 h2. 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_. 
 <pre> 
 su - diaspora 
 gem pkg install rubygem-bundler 
 </pre> 

 h2. 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_. 
 <pre> 
 pkg install node 
 </pre> 

 If you require Node Package Manager, you should install _www/npm_ - however, this is optional as Diaspora* does not require NPM. 

 h2. 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: 
 * bash 
 <pre> 
 vi ~/.bashrc 
 </pre> 
 > export RAILS_ENV='production' 
 > export DB='mysql2' 

 Congrats! You have all your dependencies installed. 

 h2. Get the Diaspora* source 

 * It's time to download Diaspora! As your diaspora user run: 
 <pre> 
 su - diaspora 
 cd ~ 
 git clone    git://github.com/diaspora/diaspora.git 
 cd diaspora 
 </pre> 

 Don't miss the cd diaspora, all coming commands expect to be run from that directory! 

 h3. Configuration 

 * Copy the example configuration files 
 <pre> 
 cp config/database.yml.example config/database.yml 
 cp config/diaspora.yml.example config/diaspora.yml 
 </pre> 

 h2. Bundle 

 * It's time to install the Ruby libraries required by Diaspora: 
 <pre> 
 bundle install 
 </pre> 

 This takes quite a while. You should get a green success message when it's finished, if that's not the case you should seek for help on the mailing list or the IRC channel. You can speed it up a bit adding -jn to the command, where n is the number of CPU cores you have available. 

 Running the manual gem install command shown in the error message can sometimes show a clearer error message if the bundle command fails. 

 h3. 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. 
 <pre> 
 su - diaspora 
 cd ~/diaspora/ 
 diaspora@myhost ~/diaspora/ $ bundle install --without test development --path vendor/bundle 
 </pre> 

 The @--path vendor/bundle@ will install your Gems to @~/diaspora/vendor/bundle@ 

 h2. Database setup 

 * Double check your config/database.yml looks right and run: 
 <pre> 
 bundle exec rake db:create db:schema:load 
 </pre> 

 h2. Start Diaspora 

 * It's time to start Diaspora: 
 <pre> 
 ./script/server 
 </pre>

Back