Home

Redmine Setup Memo

■Redmineインストール
・Redmine 5.0 をUbuntu 22.04 LTSにインストールする手順
 https://blog.redmine.jp/articles/5_0/install/ubuntu/

kokaki@skynew:~$ sudo apt -y install ruby-dev postgresql-server-dev-all libxslt1-dev libxml2-dev libpq-dev libcurl4-openssl-dev zlib1g-dev apache2-dev gcc g++ make patch imagemagick
kokaki@skynew:~$ sudo locale-gen ja_JP.UTF-8
    Generating locales (this might take a while)...
    ja_JP.UTF-8... done
    Generation complete.
kokaki@skynew:~$ locale -a
    C
    C.utf8
    POSIX
    ja_JP.utf8
kokaki@skynew:~$ sudo apt update
kokaki@skynew:~$ sudo apt install -y build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev libffi-dev
kokaki@skynew:~$ sudo apt install -y postgresql libpq-dev
kokaki@skynew:~$ sudo apt install -y apache2 apache2-dev
kokaki@skynew:~$ sudo apt install -y imagemagick fonts-takao-pgothic
kokaki@skynew:~$ sudo apt install -y subversion git
・Rubyインストール
 - ソースコードダウンロード
kokaki@skynew:~$ curl -O https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.1.tar.gz
 - Rubyビルド
kokaki@skynew:~$ tar xvf ruby-3.4.1.tar.gz
kokaki@skynew:~$ cd ruby-3.4.1
kokaki@skynew:~/ruby-3.4.1$ ./configure --disable-install-doc
kokaki@skynew:~/ruby-3.4.1$ make
kokaki@skynew:~/ruby-3.4.1$ sudo make install
kokaki@skynew:~/ruby-3.4.1$ cd ..
 - rubyバージョン確認
kokaki@skynew:~$ ruby -v
    ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
・PostgreSQL設定
 - Redmine用ユーザ(redmine)作成
kokaki@skynew:~$ sudo -i -u postgres createuser -P redmine
    Enter password for new role: (Raspberrypi5)
    Enter it again: (Raspberrypi5)
kokaki@skynew:~$ sudo -i -u postgres createdb -E UTF-8 -l ja_JP.UTF-8 -O redmine -T template0 redmine
kokaki@skynew:~$ curl -O https://www.redmine.org/releases/redmine-5.1.5.tar.gz
kokaki@skynew:~$ tar xvf redmine-5.1.5.tar.gz
kokaki@skynew:~$ sudo mv redmine-5.1.5/ /var/lib/
kokaki@skynew:~$ sudo mv /var/lib/redmine-5.1.5/ /var/lib/redmine/
kokaki@skynew:~$ sudo chown -R www-data:root /var/lib/redmine
kokaki@skynew:~$ sudo cp /var/lib/redmine/config/database.yml.example /var/lib/redmine/config/database.yml
kokaki@skynew:~$ sudo vi /var/lib/redmine/config/database.yml
    production:
      adapter: postgresql
      database: redmine
      host: localhost
      username: redmine
      password: "********"
      encoding: utf8
kokaki@skynew:~$ sudo cp /var/lib/redmine/config/configuration.yml.example /var/lib/redmine/config/configuration.yml
kokaki@skynew:~$ sudo vi /var/lib/redmine/config/configuration.yml
    production:
      email_delivery:
        delivery_method: :smtp
        smtp_settings:
          address: "localhost"
          port: 25
          domain: "example.com"

      rmagick_font_path: /usr/share/fonts/truetype/takao-gothic/TakaoPGothic.ttf
kokaki@skynew:~$ cd /var/lib/redmine
kokaki@skynew:/var/lib/redmine$ sudo bundle config set --local without 'development test'
kokaki@skynew:/var/lib/redmine$ sudo bundle install
    Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users on this
    machine.
    Your Ruby version is 3.4.1, but your Gemfile specified >= 2.7.0, < 3.3.0
kokaki@skynew:/var/lib/redmine$ sudo vi Gemfile
    -ruby '>= 2.7.0', '< 3.3.0'
    +ruby '>= 2.7.0', '< 3.5.0'
kokaki@skynew:/var/lib/redmine$ sudo bundle install
    :
    :
    :
    https://github.com/jch/html-pipeline#dependencies
    -------------------------------------------------
    Post-install message from rubyzip:
    RubyZip 3.0 is coming!
    **********************

    The public API of some Rubyzip classes has been modernized to use named
    parameters for optional arguments. Please check your usage of the
    following classes:
    * `Zip::File`
    * `Zip::Entry`
    * `Zip::InputStream`
    * `Zip::OutputStream`

    Please ensure that your Gemfiles and .gemspecs are suitably restrictive
    to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0).
    See https://github.com/rubyzip/rubyzip for details. The Changelog also
    lists other enhancements and bugfixes that have been implemented since
    version 2.3.0.
kokaki@skynew:/var/lib/redmine$ sudo -u www-data bin/rake generate_secret_token
    /usr/local/lib/ruby/gems/3.4.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/logging.rb:1: 
    warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
    You can add logger to your Gemfile or gemspec to silence this warning.
    /usr/local/lib/ruby/gems/3.4.0/gems/activesupport-6.1.7.10/lib/active_support/message_verifier.rb:3: 
    warning: base64 was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
    You can add base64 to your Gemfile or gemspec to silence this warning.
    rake aborted!
    LoadError: cannot load such file -- base64 (LoadError)
    /var/lib/redmine/config/application.rb:5:in '<top (required)>'
    /var/lib/redmine/Rakefile:5:in '<top (required)>'
    (See full trace by running task with --trace)
・LoadErrorが出るので、以下のモジュールを追加
kokaki@skynew:/var/lib/redmine$ sudo vi Gemfile
    gem 'base64'
    gem 'bigdecimal'
    gem 'mutex_m', '~> 0.2.0'
    gem xxxx 1.3.4
kokaki@skynew:/var/lib/redmine$ sudo bundle install
    Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users on this
    machine.
    Fetching gem metadata from https://rubygems.org/.........
    Resolving dependencies...
    Fetching bigdecimal 3.1.9
    Fetching mutex_m 0.2.0
    Installing mutex_m 0.2.0
    Installing bigdecimal 3.1.9 with native extensions
    Bundle complete! 44 Gemfile dependencies, 77 gems now installed.
    Gems in the groups 'development' and 'test' were not installed.
    Use `bundle info [gemname]` to see where a bundled gem is installed.
kokaki@skynew:/var/lib/redmine$ sudo -u www-data bin/rake generate_secret_token
kokaki@skynew:/var/lib/redmine$ sudo -u www-data RAILS_ENV=production bin/rake db:migrate
kokaki@skynew:/var/lib/redmine$ sudo gem install passenger -N
    Fetching passenger-6.0.24.gem
    Fetching rack-3.1.8.gem
    Fetching rackup-2.2.1.gem
    Successfully installed rack-3.1.8
    rackup's executable "rackup" conflicts with rack
    Overwrite the executable? [yN]  y
    Successfully installed rackup-2.2.1
    Building native extensions. This could take a while...
    Successfully installed passenger-6.0.24
    3 gems installed
kokaki@skynew:/var/lib/redmine$ sudo passenger-install-apache2-module --auto --languages ruby
    :
    :
    :
    Detected 0 error(s), 1 warning(s).
    Press ENTER to continue.

    --------------------------------------------

    Deploying a web application

    To learn how to deploy a web app on Passenger, please follow the deployment
    guide:

    https://www.phusionpassenger.com/library/deploy/apache/deploy/

    Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
    https://www.phusionpassenger.com

    Passenger is a registered trademark of Phusion Holding B.V.
    kokaki@skynew:/var/lib/redmine$ passenger-install-apache2-module --snippet
    LoadModule passenger_module /usr/local/lib/ruby/gems/3.4.0/gems/passenger-6.0.24/buildout/apache2/mod_passenger.so
    <IfModule mod_passenger.c>
      PassengerRoot /usr/local/lib/ruby/gems/3.4.0/gems/passenger-6.0.24
      PassengerDefaultRuby /usr/local/bin/ruby
    </IfModule>
kokaki@skynew:/var/lib/redmine$ sudo vi /etc/apache2/conf-available/redmine.conf
    # Redmineの画像ファイル・CSSファイル等へのアクセスを許可する設定。
    # Apache 2.4のデフォルトではサーバ上の全ファイルへのアクセスが禁止されている。
    <Directory "/var/lib/redmine/public">
        Require all granted
    </Directory>

    # Passengerの基本設定。
    # passenger-install-apache2-module --snippet で表示された設定を記述。
    # 環境によって設定値が異なるため以下の5行はそのまま転記せず、必ず
    # passenger-install-apache2-module --snippet で表示されたものを使用すること。
    #
    LoadModule passenger_module /usr/local/lib/ruby/gems/3.4.0/gems/passenger-6.0.24/buildout/apache2/mod_passenger.so
    <IfModule mod_passenger.c>
        PassengerRoot /usr/local/lib/ruby/gems/3.4.0/gems/passenger-6.0.24
        PassengerDefaultRuby /usr/local/bin/ruby
    </IfModule>

    # 必要に応じてPassengerのチューニングのための設定を追加(任意)。
    # 詳しくは Configuration reference - Passenger + Apache (https://www.phusionpassenger.com/docs/references/config_reference/apache/) 参照。
    PassengerMaxPoolSize 20
    PassengerMaxInstancesPerApp 4
    PassengerPoolIdleTime 864000
    PassengerStatThrottleRate 10
    # Redmineのインストールディレクトリへのアクセスを許可
    <Directory /var/lib/redmine/public>
        Allow from all
        Options -MultiViews
        Require all granted
    </Directory>
    Alias /redmine /var/lib/redmine/public
    <Location /redmine>
        PassengerBaseURI /redmine
        PassengerAppRoot /var/lib/redmine
    </Location>
kokaki@skynew:/var/lib/redmine$ sudo a2enconf redmine
    Enabling conf redmine.
    To activate the new configuration, you need to run:
      systemctl reload apache2
kokaki@skynew:/var/lib/redmine$ apache2ctl configtest
    AH00526: Syntax error on line 13 of /etc/apache2/sites-enabled/default-ssl.conf:
    SSLCertificateKeyFile: file '/etc/ssl/private/ssl-cert-snakeoil.key' does not exist or is empty
kokaki@skynew:/var/lib/redmine$ sudo systemctl reload apache2
http://localhost/redmine
Redmine
・Redmineをインストールした直後であればログインID、パスワードともに"admin"でログインできます。
・初めてadminでログインするとパスワードの変更を求められます。adminユーザーのパスワードがデフォルトのままだと誰でも管理ユーザーとしてRedmineにログインできてしまうので変更します。

admin/Raspberrypi5
ユーザ追加
kokaki@kokaki.jp/Ka****16

■redmineテーマ
kokaki@skynew:~/work$ cd /var/lib/redmine/
kokaki@skynew:/var/lib/redmine$ sudo git clone -b redmine5.1 https://github.com/farend/redmine_theme_farend_bleuclair.git public/themes/bleuclair
    [sudo] password for kokaki:
    Cloning into 'public/themes/bleuclair'...
    remote: Enumerating objects: 1896, done.
    remote: Counting objects: 100% (501/501), done.
    remote: Compressing objects: 100% (158/158), done.
    remote: Total 1896 (delta 423), reused 343 (delta 343), pack-reused 1395 (from 2)
    Receiving objects: 100% (1896/1896), 7.78 MiB | 8.54 MiB/s, done.
    Resolving deltas: 100% (1159/1159), done.
    Note: switching to 'a4ddbe79adffd999da9525fa11e3ef810b1f81b1'.

    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by switching back to a branch.

    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -c with the switch command. Example:

    git switch -c <new-branch-name>

    Or undo this operation with:

    git switch -

    Turn off this advice by setting config variable advice.detachedHead to false
■redmineプラグイン
・テンプレート<https://github.com/agileware-jp/redmine_issue_templates>
kokaki@skynew:/var/lib/redmine$ cd plugins
kokaki@skynew:/var/lib/redmine/plugins$ sudo git clone https://github.com/agileware-jp/redmine_issue_templates
    Cloning into 'redmine_issue_templates'...
    remote: Enumerating objects: 6665, done.
    remote: Counting objects: 100% (216/216), done.
    remote: Compressing objects: 100% (112/112), done.
    remote: Total 6665 (delta 141), reused 121 (delta 101), pack-reused 6449 (from 3)
    Receiving objects: 100% (6665/6665), 1.51 MiB | 6.45 MiB/s, done.
    Resolving deltas: 100% (4030/4030), done.
    kokaki@skynew:/var/lib/redmine/plugins$ ls -ld redmine_issue_templates
    drwxr-xr-x 13 root root 4096 Jan  2 17:56 redmine_issue_templates
    kokaki@skynew:/var/lib/redmine/plugins$ sudo bundle install
    Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users on this
    machine.
    Bundle complete! 44 Gemfile dependencies, 77 gems now installed.
    Gems in the groups 'development' and 'test' were not installed.
    Use `bundle info [gemname]` to see where a bundled gem is installed.
kokaki@skynew:/var/lib/redmine/plugins$ sudo bundle exec rake redmine:plugins:migrate RAILS_ENV=production

・工数管理<https://github.com/redmine-work-time/redmine_work_time>
kokaki@skynew:/var/lib/redmine/plugins$ sudo git clone https://github.com/tkusukawa/redmine_work_time.git
    Cloning into 'redmine_work_time'...
    remote: Enumerating objects: 2558, done.
    remote: Counting objects: 100% (27/27), done.
    remote: Compressing objects: 100% (21/21), done.
    remote: Total 2558 (delta 10), reused 18 (delta 6), pack-reused 2531 (from 1)
    Receiving objects: 100% (2558/2558), 1.56 MiB | 5.82 MiB/s, done.
    Resolving deltas: 100% (1526/1526), done.
kokaki@skynew:/var/lib/redmine/plugins$ sudo bundle exec rake redmine:plugins:migrate RAILS_ENV=production
kokaki@skynew:/var/lib/redmine/plugins$ sudo systemctl restart apache2

■pgAdminインストール
How to Install pgAdmin on Ubuntu 24.04
https://www.linuxtechi.com/how-to-install-pgadmin-on-ubuntu/
1) Install Curl Utility
kokaki@skynew:~$ sudo apt update && sudo apt install curl -y

2) Add pgAdmin APT Repository
kokaki@skynew:~$ curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
    File '/usr/share/keyrings/packages-pgadmin-org.gpg' exists. Overwrite? (y/N) y
kokaki@skynew:~$ sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
    Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
    Hit:2 http://archive.ubuntu.com/ubuntu noble InRelease
    Get:3 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/noble pgadmin4 InRelease [4217 B]
    Hit:4 http://archive.ubuntu.com/ubuntu noble-updates InRelease
    Get:5 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/noble pgadmin4/main all Packages [3469 B]
    Hit:6 http://archive.ubuntu.com/ubuntu noble-backports InRelease
    Get:7 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/noble pgadmin4/main amd64 Packages [5594 B]
    Fetched 13.3 kB in 1s (11.3 kB/s)
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    2 packages can be upgraded. Run 'apt list --upgradable' to see them.
3) Install pgAdmin on Ubuntu 24.04
kokaki@skynew:~$ sudo apt install pgadmin4 -y
    Processing triggers for hicolor-icon-theme (0.17-2) ...
    Processing triggers for libc-bin (2.39-0ubuntu8.3) ...
    Errors were encountered while processing:
    pgadmin4-desktop
    pgadmin4
    E: Sub-process /usr/bin/dpkg returned an error code (1)
4) Configure User Account for pgAdmin Web Interface
kokaki@skynew:~$ sudo /usr/pgadmin4/bin/setup-web.sh
    Setting up pgAdmin 4 in web mode on a Debian based platform...
    Creating configuration database...
    NOTE: Configuring authentication for SERVER mode.

    Enter the email address and password to use for the initial pgAdmin user account:

    Email address: kokaki@kokaki.jp
    Password: (Raspberrypi5)
    Retype password: (Raspberrypi5)
    pgAdmin 4 - Application Initialisation
    ======================================

    Creating storage and log directories...
    We can now configure the Apache Web server for you.
    This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4.
    Do you wish to continue (y/n)? y
    The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete.
    Continue (y/n)? y
    Apache successfully restarted.
    You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4
kokaki@skynew:~$ sudo systemctl restart apache2
5) Access pgAdmin Web Interface
http://localhost/pgadmin4
Redmine

新しいサーバーを追加
一般 - 名前:Redmine
接続 - ホスト名/アドレス:localhost
接続 - 管理用データベース:redmine
接続 - ユーザー名:redmine
接続 - パスワード:redmine

PostgreSQL導入備忘録(peer認証エラー)
https://hackteck.hatenablog.com/entry/2020/11/27/100405
kokaki@skynew:~$ sudo passwd postgres
    New password:
    Retype new password:
    passwd: password updated successfully
kokaki@skynew:~$ su - postgres
    Password:
    Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 5.15.133.1-microsoft-standard-WSL2 x86_64)

    * Documentation:  https://help.ubuntu.com
    * Management:     https://landscape.canonical.com
    * Support:        https://ubuntu.com/pro

    System information as of Fri Jan  3 04:48:37 JST 2025

    System load:  0.0                 Processes:             62
    Usage of /:   0.7% of 1006.85GB   Users logged in:       1
    Memory usage: 21%                 IPv4 address for eth0: 172.24.70.19
    Swap usage:   0%

    * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
    just raised the bar for easy, resilient and secure K8s cluster deployment.

    https://ubuntu.com/engage/secure-kubernetes-at-the-edge

    This message is shown once a day. To disable it please create the
    /var/lib/postgresql/.hushlogin file.
postgres@skynew:~$ psql
    psql (16.6 (Ubuntu 16.6-0ubuntu0.24.04.1))
    Type "help" for help.

    postgres=# ALTER USER postgres with encrypted password 'Raspberrypi5';
    ALTER ROLE
    postgres=# \l データベース一覧
    postgres=# \q 終了
    postgres@skynew:~$ exit
    logout

kokaki@skynew:~$ sudo find / -name pg_hba.conf
    /etc/postgresql/16/main/pg_hba.conf
kokaki@skynew:~$ sudo vi /etc/postgresql/16/main/pg_hba.conf
    # maintenance (custom daily cronjobs, replication, and similar tasks).
    #
    # Database administrative login by Unix domain socket
    #local   all             postgres                                peer
    local   all             postgres                                md5
kokaki@skynew:~$ sudo systemctl restart postgresql

■Railsアプリデプロイ
・rubyバージョン変更及び、モジュール追加
kokaki@skynew:~$ vi www/rails/books/Gemfile
    ruby "3.4.1"

    gem 'base64'
    gem 'bigdecimal'
    gem 'mutex_m', '~> 0.2.0'
・Gemfile.lockの(バージョン差異のため一旦)削除
kokaki@skynew:~$ rm www/rails/books/Gemfile.lock

・再インストール
kokaki@skynew:~$ cd www/rails/books
kokaki@skynew:~/www/rails/books$ sudo bundle install

・Apache2から起動するためRedmineの設定に追記
kokaki@skynew:~$ sudo vi /etc/apache2/conf-available/redmine.conf
    Alias /books /home/kokaki/www/rails/books/public
    <Location /books>
      PassengerBaseURI /books
      PassengerAppRoot /home/kokaki/www/rails/books
    </Location>
・Apache2再起動
kokaki@skynew:~$ sudo systemctl restart apache2

■アカウントロック解除方法
kokaki@skynew:~$ sudo sqlite3 /var/lib/pgadmin/pgadmin4.db
    SQLite version 3.45.1 2024-01-30 16:01:20
    Enter ".help" for usage hints.
    sqlite> SELECT LOCKED,LOGIN_ATTEMPTS FROM USER WHERE USERNAME = "kokaki@kokaki.jp";
    1|3
    sqlite> UPDATE USER SET LOCKED = false, LOGIN_ATTEMPTS = 0 WHERE USERNAME = "kokaki@kokaki.jp";
    sqlite> SELECT LOCKED,LOGIN_ATTEMPTS FROM USER WHERE USERNAME = "kokaki@kokaki.jp";
    0|0
    sqlite> .q

Home

2025 kokaki.jp, Office.