Project

General

Profile

Support #436

Updated by Daniel Curtis about 9 years ago

This is a simple guide for setting up Diaspora* on a FreeBSD FAMP server. h2. Add the diaspora user 

 h1. Prerequisites 

 * Update Add the system and ports tree diaspora user along with the group using the helper script: 
 <pre> 
 pkg update && pkg upgrade mkdir /usr/local/www/diaspora 
 portsnap fetch extract 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 

 * Install ca_root_nss This guide will use portupgrade to manage packages from the ports tree: 
 <pre> 
 cd /usr/ports/security/ca_root_nss pkg install portupgrade 
 make config 
 make reinstall clean 
 </pre> 
 #* *NOTE*: Make sure to enable @*[X]* ETCSYMLINK@ when running make config. This is to prevent an error later when running @bundle install@. 

 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. 
 <pre> > WITH_PKGNG=yes 
 echo 'WITH_PKGNG=yes' >> /etc/make.conf > WITHOUT="X11" 
 echo 'WITHOUT="X11"' >> /etc/make.conf > OPTIONS_UNSET=X11 
 echo 'OPTIONS_UNSET=X11' >> /etc/make.conf 
 echo '#! >  
 > #! DO NOT USE SPACES OR COMMENTS IN THE FOLLOWING LINE EVER!' >> /etc/make.conf EVER! 
 echo 'DEFAULT_VERSIONS= > DEFAULT_VERSIONS=      perl5=5.16 ruby=2.1 python=2.7 postgresql=9.3 mysql=5.5' >> /etc/make.conf mysql=5.5 
 echo 'PERL5_DEFAULT=5.16' >> /etc/make.conf >  
 > PERL5_DEFAULT=5.16 
 echo 'RUBY_VER=2.1' >> /etc/make.conf > RUBY_VER=2.1 
 echo 'WANT_PGSQL_VER=93' >> /etc/make.conf > WANT_PGSQL_VER=93 
 echo 'WANT_MYSQL_VER=55m > WANT_MYSQL_VER=55      #! 55m for MariaDB, 55p for Percona' >> /etc/make.conf 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 portmaster ca_root_nss sudo gmake git subversion python27 curl automake    ImageMagick-nox11 ghostscript9-nox11 ruby21 rubygem-bundler rubygem-nokogiri node libtool bison readline 
 </pre> 

 h1. Setup Diaspora Environment h3. Building Required Packages 

 * Add 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 diaspora user along with packages you must have, in the group using order required to pull in all of the helper script: required dependencies. 
 <pre> # databases/mariadb55-server 
 mkdir /usr/local/www/diaspora # graphics/ImageMagick-nox11 
 adduser # databases/redis 
 </pre> # lang/ruby21 OR lang/ruby20 matching what you set in make.conf! 
 #* And use the following: # sysutils/rubygem-bundler 
 <pre> 
 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> # www/node 

 h2. H2. Install RVM 

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

 * Install RVM and Ruby 2.1 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.1 2.0 
 </pre> 

 * Install bundler inside of RVM: 
 <pre> 
 gem install rubygems-bundler bundler 
 </pre> 

 * 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> 
 echo 'export RAILS_ENV="production"' >> ~/.bashrc 
 echo 'export DB="mysql2"' >> ~/.bashrc 
 </pre> 

 * Exit back into root: 
 <pre> 
 exit 
 </pre> 

 h1. h2. MariaDB 5.5 Server 

 PostgreSQL will always offer the best performance on FreeBSD, especially on multi-core systems. PostgreSQL 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 

 * Install MariaDB: instead: 
 <pre> 
 pkg install mariadb55-client mariadb55-server 
 </pre> 

 h2. Configure MariaDB 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. 

 * Copy a base MariaDB configuration to use Install ghostscript9-nox11: 
 <pre> 
 cp /usr/local/share/mysql/my-small.cnf /var/db/mysql/my.cnf cd /usr/ports/print/ghostscript9-nox11 
 portupgrade -Np 
 </pre> 

 * Tuning: Copy one of the default config files and change the max packet size: The ONLY options you should leave set in ghostscript9-nox11 are: 
 <pre> > FONTCONFIG 
 vi /var/db/mysql/my.cnf > ICONV 
 </pre> > GS_jpeg, GS_jpeggray 
 #* and modify max_allowed_packet > 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 32M include them. You must include GS_plan or the build will fail. 

 h3. Options: _graphics/ImageMagick-nox11_ 

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

 It is recommended that you set only these options: 
 * Enable and start MariaDB 16BIT_PIXEL 
 <pre> * BZIP2 
 echo 'mysql_enable="YES"' >> /etc/rc.conf * FONTCONFIG 
 service mysql-server start * FREETYPE 
 </pre> 

 * Prepare Database for use by running the secure installation: JPEG 
 <pre> * LQR 
 mysql_secure_installation * LZMA 
 </pre> * MODULES 
 *NOTE*: Choose a strong root password and answer yes to all questions. 

 h3. Create MariaDB Databases and Users 

 * Login to MariaDB and create appropriate databases and users. PERL 
 <pre> * PNG 
 mysql -u root -p * THREADS 
 </pre> 
 #* * TIFF 

 This will minimize the number of dependencies which are pulled in. Do not select both JASPER and run JPEG as this will cause the following SQL queries build to create the *diasporadb* database fail. THREADS introduces no additional dependencies and *diasporauser* user: will offer faster performance on most systems. 

 Other options which you may wish to set, but are entirely optional: 
 <pre> * DOCS 
 CREATE DATABASE diasporadb CHARACTER SET utf8; 

 CREATE USER 'diasporauser'@'127.0.0.1' IDENTIFIED BY 'SuperSecretPassword'; 

 GRANT ALL PRIVILEGES ON diasporadb.* TO 'diasporauser'@'127.0.0.1'; 

 flush privileges; * FFTW 
 exit * GRAPHVIZ 
 </pre> * HDRI 
 * OPENEXR 

 h1. Install 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.  

 h2. Redis 

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

 * Enable and start Redis You should not install bundle dependencies using ports. This will put you out of sync with Diaspora* recommended/required versions. 
 <pre> 
 echo 'redis_enable="YES"' >> /etc/rc.conf su - diaspora 
 service redis start gem install rubygem-bundler 
 </pre> 

 h1. Install h2. Node.js 

 * Install Node.js and npm: 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 npm 
 </pre> 

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

 Congrats! You have all your dependencies installed. 

 h2. Get the Diaspora* as the 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> 

 h2. Configure Diaspora* 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. Install With Bundler Bundle 

 * Start by setting bundler It's time to use install the system nokogiri gem. This is to prevent an error during install: Ruby libraries required by Diaspora: 
 <pre> 
 bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/include/libxml2" 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! 

 * Install Instead, you should install your Gems under your Diaspora* user's installation to prevent any problems and ensure you have the Ruby libraries required by Diaspora: 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. Diaspora* Database Setup setup 

 * Double check that the database.yml your config/database.yml looks right: right and run: 
 <pre> 
 vi config/database.yml 
 </pre> 

 * Run the following to setup the database: 
 <pre> 
 bundle exec rake db:create db:schema:load 
 </pre> 

 h2. Start Diaspora 

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

Back