Support #747
Updated by Daniel Curtis over 8 years ago
{{>toc}} This is a guide on installing Redmine with MariaDB and Nginx on FreeBSD 10. h2. Prepare the Environment * Make sure that pkg is set to use Before installation of the latest packages. Create the pkg repo config file: <pre> mkdir -p /usr/local/etc/pkg/repos vi /usr/local/etc/pkg/repos/FreeBSD.conf </pre> #* And add the following: <pre> FreeBSD: { url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", enabled: yes } </pre> * Make components, make sure everything is up to date using the following command: <pre> pkg update -f && pkg upgrade </pre> * Create a redmine user: <pre> pw add user -n redmine -m -s /sbin/nologin -c "Redmine" </pre> * Install a few dependencies: <pre> pkg install portmaster gcc llvm36 cmake scons ImageMagick rubygem-mime-types1 rubygem-sass-rails </pre> h2. Install Nginx * Install nginx with passenger support: <pre> portmaster www/nginx </pre> #* *NOTE*: Make sure to enable *@[X]PASSENGER@* while configuring _nginx_ * Install Passenger <pre> portmaster www/rubygem-passenger </pre> #* *NOTE*: Make sure to enable *@[X]NGINX@* while configuring rubygem-passenger #* *NOTE*: Enabling *[X]SYMLINK* makes upgrading passenger easier later on. * Add the redmine user to the www group: <pre> pw usermod redmine -G www </pre> * Start and enable nginx at boot: <pre> echo 'nginx_enable="YES"' >> /etc/rc.conf 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; # Load Phusion Passenger module globally passenger_root /usr/local/lib/ruby/gems/2.2/gems/passenger; passenger_ruby /usr/local/bin/ruby22; 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; } </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_enabled on; passenger_user redmine; passenger_group redmine; } </pre> * Restart nginx: <pre> service nginx restart </pre> --- h2. Install MariaDB server * Start by installing the mariadb100-server and mariadb100-client packages: <pre> pkg install mariadb100-{server,client} </pre> * Copy a base MariaDB configuration to use: <pre> cp /usr/local/share/mysql/my-small.cnf /var/db/mysql/my.cnf </pre> * Edit the mariadb config to change the max packet size: <pre> vi /var/db/mysql/my.cnf </pre> #* and modify @max_allowed_packet@ to 32M <pre> max_allowed_packet = 32M </pre> * Enable and start MariaDB <pre> echo 'mysql_enable="YES"' >> /etc/rc.conf service mysql-server start </pre> * Prepare the database for use by running the secure installation: <pre> mysql_secure_installation </pre> #* *NOTE*: +Choose a strong root password+ and answer +yes+ to all questions. h3. Create MariaDB Databases and Users * Login to MariaDB and create appropriate databases and users. <pre> mysql -u root -p </pre> #* and run the following SQL queries to create the *redminedb* database and *redmineuser* user: <pre> CREATE DATABASE redminedb CHARACTER SET utf8; CREATE USER 'redmineuser'@'localhost' IDENTIFIED BY 'SuperSecretPassword'; GRANT ALL PRIVILEGES ON redminedb.* TO 'redmineuser'@'localhost'; FLUSH PRIVILEGES; quit </pre> --- h2. Install Redmine * Install redmine: <pre> portmaster www/redmine </pre> #* *NOTE*: Make sure to enable *@[X]PASSENGER@* while configuring redmine * Copy config/database.yml.example to config/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: mysql2 database: redminedb host: localhost username: redmineuser password: "SuperSecretPassword" encoding: utf8 </pre> * Install gem dependencies: <pre> cd /usr/local/www/redmine bundle install --without development test postgres --path vendor/bundle </pre> * Generate a secret token: <pre> bundle exec rake generate_secret_token </pre> * Create the database structure: <pre> env RAILS_ENV=production bundle exec rake db:migrate </pre> * Change the redmine site ownership: <pre> chown -R redmine:www /usr/local/www/redmine </pre> --- h2. Install Nginx * Install nginx with passenger support: <pre> portmaster www/nginx </pre> #* *NOTE*: Make sure to enable *@[X]PASSENGER@* while configuring _nginx_ * Install Passenger <pre> portmaster www/rubygem-passenger </pre> #* *NOTE*: Make sure to enable *@[X]NGINX@* while configuring rubygem-passenger #* *NOTE*: Enabling *[X]SYMLINK* makes upgrading passenger easier later on. * Add the redmine user to the www group: <pre> pw usermod redmine -G www </pre> * Start and enable nginx at boot: <pre> echo 'nginx_enable="YES"' >> /etc/rc.conf 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; # Load Phusion Passenger module globally passenger_root /usr/local/lib/ruby/gems/2.2/gems/passenger; passenger_ruby /usr/local/bin/ruby22; 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; } </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_enabled on; passenger_user redmine; passenger_group redmine; } </pre> * Restart nginx: <pre> service nginx restart </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