Project

General

Profile

Support #436

Installing Diaspora* on FreeBSD

Added by Daniel Curtis about 6 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Web Server
Target version:
Start date:
08/12/2014
Due date:
% Done:

100%

Estimated time:
6.00 h
Spent time:

Description

This is a simple guide for setting up Diaspora* on FreeBSD 9.

Prerequisites

  • Update the system and ports tree
    pkg update && pkg upgrade
    portsnap fetch extract
    
  • Install ca_root_nss
    cd /usr/ports/security/ca_root_nss
    make config
    make reinstall clean
    
    • NOTE: Make sure to enable [X] ETCSYMLINK when running make config. This is to prevent an error later when running bundle install.
  • Install portmaster:
    cd /usr/ports/ports-mgmt/portmaster
    make install clean
    pkg2ng
    
  • 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.
    echo 'WITHOUT="X11"' >> /etc/make.conf
    echo 'OPTIONS_UNSET=X11' >> /etc/make.conf
    echo 'DEFAULT_VERSIONS=    perl5=5.16 ruby=2.2 python=2.7 postgresql=9.4 mysql=5.5' >> /etc/make.conf
    echo 'PERL5_DEFAULT=5.16' >> /etc/make.conf
    echo 'RUBY_VER=2.2' >> /etc/make.conf
    echo 'WANT_PGSQL_VER=94' >> /etc/make.conf
    
  • The following packages are optional but recommended before you begin building Diaspora* on FreeBSD:
    portmaster shells/bash security/sudo devel/gmake devel/git devel/subversion lang/python27 ftp/curl devel/automake  graphics/ImageMagick-nox11 print/ghostscript9-nox11 lang/ruby22 www/node www/npm devel/libtool devel/bison devel/readline textproc/rubygem-nokogiri databases/redis sysutils/rubygem-bundler
    
  • Enable and start Redis
    echo 'redis_enable="YES"' >> /etc/rc.conf
    service redis start
    
  • Add the diaspora user
    pw add user -n diaspora -m -s /usr/local/bin/bash -c "Diaspora*" 
    

Install PostgreSQL

  • Install PostgreSQL 9.4:
    portmaster databases/postgresql94-server databases/postgresql94-client
    
  • Connect to the default database:
    su - postgres
    psql
    
    • Set a password for the postgres user:
      \password postgres
      
    • The postgres admin console will show postgres=#, create a new diaspora database user and database:
      CREATE USER diasporauser WITH PASSWORD 'diasporapass';
      CREATE DATABASE diasporadb OWNER diasporauser;
      
    • Quit from the database
      \q
      
  • Exit from the postgres user
    exit
    

Install Diaspora*

  • Download Diaspora* as the diaspora user run:
    su - diaspora
    git clone git://github.com/diaspora/diaspora.git
    cd diaspora
    
  • Copy the example configuration files
    cp config/database.yml.example config/database.yml
    cp config/diaspora.yml.example config/diaspora.yml
    
  • Start by setting bundler to use the system nokogiri gem. This is to prevent an error during install:
    bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/include/libxml2" 
    
  • Install the Ruby libraries required by Diaspora:
    bundle install --without test development --path vendor/bundle
    

Setup the Database

  • Double check that the database.yml looks right:
    vi config/database.yml
    
  • Run the following to setup the database:
    RAILS_ENV=production bundle exec rake db:create db:schema:load
    
  • Edit the diaspora config:
    vi config/diaspora.yml
    
    • And modify the certificate_authority parameter to the following:
      certificate_authorities: '/usr/local/etc/ssl/cert.pem'
      

Start Diaspora

  • Edit the production environment config:
    vi config/environments/production.rb
    
    • And modify the following parameter:
      config.assets.compile = true
      
  • Precompile the assets used by Diaspora:
    RAILS_ENV=production bundle exec rake assets:precompile
    
  • Start Diaspora:
    ./script/server
    

Install Nginx

  • Install Nginx with Passenger
    portmaster www/nginx
    

    NOTE: Make sure to enable [X]PASSENGER during the configuration
  • Install Passenger
    portmaster www/rubygem-passenger
    

    NOTE: Make sure to enable NGINX during the configuration
    NOTE: Enabling the [X] SYMLINK option will make upgrading passenger easier later on
  • Start and enable nginx at boot:
    echo 'nginx_enable="YES"' >> /etc/rc.conf
    service nginx start
    

Configure Nginx

  • Create a configuration directory to make managing individual server blocks easier:
    mkdir /usr/local/etc/nginx/conf.d
    
  • Configuring Nginx and Passenger, edit the /usr/local/etc/nginx/nginx.conf file:
    vi /usr/local/etc/nginx/nginx.conf
    
    • And add/modify the following
      user  www www;
      worker_processes  4;
      error_log  /var/log/nginx/error.log notice;
      pid        /var/run/nginx.pid;
      
      events {
        worker_connections  1024;
      }
      
      http {
        passenger_root /usr/local/lib/ruby/gems/2.2/gems/passenger;
        passenger_ruby /usr/local/bin/ruby;
        passenger_max_pool_size 15;
        passenger_pool_idle_time 300;
      
        # Load config files from the /etc/nginx/conf.d directory
        include /usr/local/etc/nginx/conf.d/*.conf;
      
        include       mime.types;
        default_type  application/octet-stream;
        sendfile      on;
        tcp_nopush    on;
        keepalive_timeout  65;
        tcp_nodelay        on;
      }
      

      NOTE: The above configuration will set the ruby used by passenger to the system default ruby.
  • Create a server block for diaspora
    vi /usr/local/etc/nginx/conf.d/diaspora.conf
    
    • And add the following:
      server {
        listen       80;
        server_name  diaspora.example.com;
      
        passenger_enabled on;
        passenger_user    diaspora;
        passenger_group   diaspora;
      
        access_log /var/log/nginx-diaspora.log;
        root /home/diaspora/diaspora/public;
      }
      
  • Restart nginx:
    service nginx restart
    

Resources

History

#1 Updated by Daniel Curtis about 6 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 30

#2 Updated by Daniel Curtis about 6 years ago

  • Description updated (diff)
  • % Done changed from 30 to 70

#3 Updated by Daniel Curtis about 6 years ago

  • Description updated (diff)

#4 Updated by Daniel Curtis almost 6 years ago

  • Description updated (diff)

#5 Updated by Daniel Curtis over 5 years ago

  • Category set to Web Server
  • Project changed from 101 to FreeBSD Administration
  • Subject changed from Installing Diaspora* on FreeBSD 9.2-RELEASE to Installing Diaspora* on FreeBSD
  • Target version set to FreeBSD 9

#6 Updated by Daniel Curtis over 5 years ago

  • % Done changed from 70 to 80
  • Description updated (diff)

#7 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#8 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#9 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#10 Updated by Daniel Curtis over 5 years ago

  • % Done changed from 80 to 90

#11 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#12 Updated by Daniel Curtis over 5 years ago

  • % Done changed from 90 to 50
  • Description updated (diff)

#13 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#14 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#15 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#16 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#17 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#18 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#19 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#20 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)
  • % Done changed from 50 to 70

#21 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)
  • % Done changed from 70 to 90

#22 Updated by Daniel Curtis over 5 years ago

  • Status changed from In Progress to Resolved
  • Description updated (diff)
  • % Done changed from 90 to 100

#23 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#24 Updated by Daniel Curtis over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF