Support #436
Updated by Daniel Curtis over 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.1 python=2.7 postgresql=9.4 mysql=5.5' >> /etc/make.conf echo 'PERL5_DEFAULT=5.16' >> /etc/make.conf echo 'RUBY_VER=2.1' >> /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/ruby21 www/node www/npm devel/libtool devel/bison devel/readline textproc/rubygem-nokogiri databases/redis </pre> * Enable and start Redis <pre> echo 'redis_enable="YES"' >> /etc/rc.conf service redis start </pre> --- h1. Setup Diaspora Environment * Add the diaspora user <pre> mkdir /usr/local/www/diaspora pw add user -n diaspora -m -s /usr/local/bin/bash -c "Diaspora*" </pre> h2. Install RVM * Switch to the diaspora user: <pre> su - diaspora </pre> * Install RVM and Ruby 2.1 <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 </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="postgres"' >> ~/.bashrc </pre> * Exit back into root: <pre> exit </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. Diaspora* Database Setup * Double check that the database.yml looks right: <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 * 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 www/rubygem-passenger </pre> *NOTE*: Make sure to enable [X]PASSENGER when during the nginx configuration *NOTE*: Make sure to enable (*) NGINX when during the rubygem-passenger configuration 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.1/gems/passenger-4.0.59; passenger_ruby /usr/local/bin/ruby; passenger_max_pool_size 15; passenger_pool_idle_time 300; #passenger_spawn_method direct; # Uncomment on Ruby 1.8 for ENC to work include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; keepalive_timeout 65; tcp_nodelay on; # Load config files from the /etc/nginx/conf.d directory include /usr/local/etc/nginx/conf.d/*.conf; } </pre> *NOTE*: The above configuration will set the ruby used by passenger to the system default ruby. * Find the exact ruby version that diaspora will use: <pre> su - diaspora passenger-config --ruby-command </pre> #* Example output: <pre> passenger-config was invoked through the following Ruby interpreter: Command: /usr/local/www/diaspora/.rvm/gems/ruby-2.1.5@diaspora/wrappers/ruby Version: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-freebsd9.3] To use in Apache: PassengerRuby /usr/local/www/diaspora/.rvm/gems/ruby-2.1.5@diaspora/wrappers/ruby To use in Nginx : passenger_ruby /usr/local/www/diaspora/.rvm/gems/ruby-2.1.5@diaspora/wrappers/ruby To use with Standalone: /usr/local/www/diaspora/.rvm/gems/ruby-2.1.5@diaspora/wrappers/ruby /usr/local/www/diaspora/.rvm/gems/ruby-2.1.5@diaspora/gems/passenger-4.0.59/bin/passenger start </pre> * Exit back into the root shell: <pre> exit </pre> h3. Diaspora nginx server block * 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_ruby /usr/local/www/diaspora/.rvm/gems/ruby-2.1.5@diaspora/wrappers/ruby; passenger_user diaspora; passenger_group diaspora; access_log /var/log/nginx-diaspora.log; root /usr/local/www/diaspora/diaspora/public; } </pre> * Restart nginx: <pre> service nginx restart </pre> h2. Resources * https://wiki.diasporafoundation.org/Installation/FreeBSD