Support #436
Installing Diaspora* on FreeBSD
Description
- Table of contents
- Prerequisites
- Install PostgreSQL
- Install Diaspora*
- Install Nginx
- Resources
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
.
- NOTE: Make sure to enable [X] ETCSYMLINK when running make config. This is to prevent an error later when running
- 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
- Set a password for the postgres user:
- 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'
- And modify the
Start Diaspora¶
- Edit the production environment config:
vi config/environments/production.rb
- And modify the following parameter:
config.assets.compile = true
- And modify the following parameter:
- 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.
- And add/modify the following
- 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; }
- And add the following:
- Restart nginx:
service nginx restart