Project

General

Profile

Support #436

Updated by Daniel Curtis almost 9 years ago

{{>toc}} 

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

 h1. Prerequisites 

 * Update the system and ports tree 
 <pre> 
 pkg update && pkg upgrade 
 portsnap fetch extract 
 </pre> 

 * Install ca_root_nss 
 <pre> 
 cd /usr/ports/security/ca_root_nss 
 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@. 

 * Install portmaster: 
 <pre> 
 cd /usr/ports/ports-mgmt/portmaster 
 make install clean 
 pkg2ng 
 </pre> 

 * 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> 
 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 
 </pre> 

 * The following packages are optional but recommended before you begin building Diaspora* on FreeBSD: 
 <pre> 
 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 
 </pre> 

 * Enable and start Redis 
 <pre> 
 echo 'redis_enable="YES"' >> /etc/rc.conf 
 service redis start 
 </pre> 

 * Add the diaspora user  
 <pre> 
 pw add user -n diaspora -m -s /usr/local/bin/bash -c "Diaspora*" 
 </pre>  

 --- 

 h1. Install PostgreSQL 

 * Install PostgreSQL 9.4: 
 <pre> 
 portmaster databases/postgresql94-server databases/postgresql94-client 
 </pre> 

 * Connect to the default database: 
 <pre> 
 su - postgres 
 psql 
 </pre> 
 #* Set a password for the postgres user: 
 <pre> 
 \password postgres 
 </pre> 
 #* The postgres admin console will show @postgres=#@, create a new diaspora database user and database: 
 <pre> 
 CREATE USER diasporauser WITH PASSWORD 'diasporapass'; 
 CREATE DATABASE diasporadb OWNER diasporauser; 
 </pre> 
 #* Quit from the database 
 <pre> 
 \q 
 </pre> 

 * Exit from the postgres user 
 <pre> 
 exit 
 </pre> 

 --- 

 h1. Install Diaspora* 

 * Download Diaspora* as the diaspora user run: 
 <pre> 
 su - diaspora 
 git clone git://github.com/diaspora/diaspora.git 
 cd diaspora 
 </pre> 

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

 * Start by setting bundler to use the system nokogiri gem. This is to prevent an error during install: 
 <pre> 
 bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/include/libxml2" 
 </pre>  

 * Install the Ruby libraries required by Diaspora: 
 <pre> 
 bundle install --without test development --path vendor/bundle 
 </pre> 

 h2. Setup the Database 

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

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

 * Edit the diaspora config: 
 <pre> 
 vi config/diaspora.yml 
 </pre> 
 #* And modify the @certificate_authority@ parameter to the following: 
 <pre> 
 certificate_authorities: '/usr/local/etc/ssl/cert.pem' 
 </pre> 

 h2. Start Diaspora 

 * Edit the production environment config: 
 <pre> 
 vi config/environments/production.rb 
 </pre> 
 #* And modify the following parameter: 
 <pre> 
 config.assets.compile = true 
 </pre> 

 * Precompile the assets used by Diaspora: 
 <pre> 
 RAILS_ENV=production bundle exec rake assets:precompile 
 </pre> 

 * Start Diaspora: 
 <pre> 
 ./script/server 
 </pre> 

 --- 

 h1. Install Nginx 

 * Install Nginx with Passenger 
 <pre> 
 portmaster www/nginx 
 </pre> 
 *NOTE*: Make sure to enable *[X]PASSENGER* during the configuration 

 


 * Install Passenger 
 <pre> 
 portmaster www/rubygem-passenger 
 </pre> 
 *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: 
 <pre> 
 echo 'nginx_enable="YES"' >> /etc/rc.conf 
 service nginx start 
 </pre> 

 h2. Configure Nginx 

 * Create a configuration directory to make managing individual server blocks easier: 
 <pre> 
 mkdir /usr/local/etc/nginx/conf.d 
 </pre> 

 * Configuring Nginx and Passenger, edit the @/usr/local/etc/nginx/nginx.conf@ file: 
 <pre> 
 vi /usr/local/etc/nginx/nginx.conf 
 </pre> 
 #* And add/modify the following 
 <pre> 
 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; 
 } 
 </pre> 
 *NOTE*: The above configuration will set the ruby used by passenger to the system default ruby. 

 * Create a server block for diaspora 
 <pre> 
 vi /usr/local/etc/nginx/conf.d/diaspora.conf 
 </pre> 
 #* And add the following: 
 <pre> 
 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; 
 } 
 </pre> 

 * Restart nginx: 
 <pre> 
 service nginx restart 
 </pre> 

 h1. Resources 

 * https://wiki.diasporafoundation.org/Installation/FreeBSD

Back