Support #956
Updated by Daniel Curtis almost 4 years ago
{{>toc}} This is a guide on installing Redmine with PostgreSQL and nginx on FreeBSD 12. h2. Prepare the Environment * Make sure everything is up to date using the following command: <pre> pkg update -f && pkg upgrade </pre> * Install dependencies: <pre> pkg install portmaster </pre> * Update ports tree: <pre> portsnap fetch extract </pre> * Create a redmine user: <pre> pw add user -n redmine -m -s /sbin/nologin -c "Redmine" </pre> --- h2. Install PostgreSQL 12 * Install PostgreSQL: <pre> pkg install postgresql12-{server,client} </pre> * Enable PostgreSQL at boot, initialize the database and start the service: <pre> sysrc postgresql_enable=YES service postgresql initdb service postgresql start </pre> * Switch to the pgsql user and enter into the psql prompt: <pre> su postgres psql -d template1 </pre> #* Create the *redmineuser* user and *redminedb* database: <pre> CREATE ROLE redmineuser LOGIN ENCRYPTED PASSWORD 'SuperSecretPassword' NOINHERIT VALID UNTIL 'infinity'; CREATE DATABASE redminedb WITH ENCODING='UTF8' OWNER=redmineuser; </pre> * Exit from the postgres user <pre> \q exit </pre> --- h2. Install Nginx * Install nginx with passenger binaries: support: <pre> pkg install nginx rubygem-passenger-nginx </pre> * Compile nginx with passenger support: <pre> portmaster www/nginx </pre> #* *NOTE* : Make sure to enable *[X]PASSENGER* while configuring _nginx_ * Add the redmine user to the www group: <pre> pw usermod redmine -G www </pre> * Start and enable nginx at boot: <pre> sysrc nginx_enable=YES service nginx start </pre> * Create a configuration directory to make managing individual server blocks easier <pre> mkdir /usr/local/etc/nginx/conf.d </pre> * Edit the main nginx config file: <pre> vi /usr/local/etc/nginx/nginx.conf </pre> #* And strip down the config file and add the include statement at the end to make it easier to handle various server blocks: <pre> worker_processes 1; error_log /var/log/nginx-error.log; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; passenger_root /usr/local/lib/ruby/gems/2.7/gems/passenger; passenger_ruby /usr/local/bin/ruby27; # Load config files from the /etc/nginx/conf.d directory include /usr/local/etc/nginx/conf.d/*.conf; } </pre> * Add a *redmine.example.com* server block: <pre> vi /usr/local/etc/nginx/conf.d/redmine.example.com.conf </pre> #* Add the following: <pre> server { listen 80; server_name redmine.example.com; root /usr/local/www/redmine/public; access_log /var/log/redmine.example.com-access.log; error_log /var/log/redmine.example.com-error.log; passenger_ruby /usr/local/bin/ruby27; passenger_sticky_sessions on; passenger_enabled on; passenger_user redmine; passenger_group redmine; } </pre> * Restart nginx: <pre> service nginx restart </pre> --- h2. Install Redmine * Install redmine: <pre> pkg install redmine4 </pre> * Create the database.yml: <pre> cp /usr/local/www/redmine/config/database.yml.example /usr/local/www/redmine/config/database.yml </pre> * Edit the redmine database config: <pre> vi /usr/local/www/redmine/config/database.yml </pre> #* And modify the production database settings: <pre> production: adapter: postgresql database: redminedb host: localhost username: redmineuser password: "SuperSecretPassword" encoding: utf8 </pre> * Install gem dependencies: <pre> cd /usr/local/www/redmine su -m redmine -c "bundle config without 'development bundle install --without development test mysql'" mysql --path vendor/bundle su -m redmine -c "bundle config path 'vendor/bundle'" su -m redmine -c "bundle install" </pre> #* NOTE: I had to run a @bundle upgrade@ in order to get the @bundle install@ to pass without issue. * Generate a secret token: <pre> su -m redmine -c "bundle bundle exec rake generate_secret_token" generate_secret_token </pre> * Edit the Gemfile: <pre> vi Gemfile </pre> #* And add the following below the other gem dependencies: gem "pg", "1.2.3" * Create the database structure: <pre> su -m redmine -c "env env RAILS_ENV=production bundle exec rake db:migrate" db:migrate </pre> * Change the redmine site ownership: <pre> chown -R redmine:www /usr/local/www/redmine </pre> * Open a web browser and go to http://redmine.example.com. The admin username is *admin* and password is *admin*. --- h2. Resources * http://www.redmine.org/wiki/redmine/RedmineInstall * http://www.redmine.org/wiki/redmine/RedmineUpgrade * https://www.redmine.org/projects/redmine/wiki/redmineinstall#PostgreSQL