0
2

自己PCにRedmineを構築

Last updated at Posted at 2024-02-20

背景

個人的なスケジュールとか、勉強とかのタスク管理をしたかった🦝

今回構築した環境・バージョン

macos Sonoma 14.2
チップ Apple M1
ruby 3.1.4
Remine 5.1.1
Mysql 5.7

手順

brewインストール

自分の環境ではbrewがインストールされていないようだったので、インストール

コマンド : brew install rbenv

実行結果:bash: brew: command not found

どうやらbrewが入ってないらしい

ということで以下を実行しインストール

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

再度brew -vで確認するも、、、、
それでもbrew -vでnot found になるので

echo export PATH='/opt/homebrew/bin:$PATH' >> ~/.bash_profile 

パスを通す

※良く見たらインストール後、
Warning: /opt/homebrew/bin is not in your PATH. が表示されている

source ~/.bash_profile 

読み直し

コマンド:brew -v

実行結果:Homebrew 4.2.9 

できた!

rvenb、rubyなど

Ruby バージョン管理の rbenv をインストール。これでプロジェクトごとに Ruby バージョン指定する。

brew install rbenv

インストール可能なバージョンをリストアップ。

rbenv install --list
3.0.6
3.1.4
3.2.3
3.3.0
※以下省略※

以下を参考に、インストール可能はバージョンと、Redmine側が対応しているバージョンで最新をものをインストール
https://redmine.jp/tech_note/supported-rubies/
私の場合は、3.1だったので以下を実行しインストール

rbenv install 3.1.4

続いて、rbenv の Ruby へのパスを通す

vimでbash_profileを開く

vim ~/.bash_profile

以下を記載

export PATH="~/.rbenv/shims:$PATH" 
eval "$(rbenv init -)"

更新

source ~/.bash_profile

データベース構築

Redmine 用のデータベースをMySQLで構築する。

MySQLをインストール

brew install mysql@5.7
If you need to have mysql@5.7 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> /Users/tanakatanuki/.bash_profile

とあるので、パスを通す

echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> /Users/tanakatanuki/.bash_profile

更新(お忘れなく!これやらないと反映されません)

source /Users/tanakatanuki/.bash_profile

mysqlsの起動

brew services start mysql@5.7
パスワード設定
mysql_secure_installation

パスワード設定コマンド実行後、色々聞かれるけれど、個人的に使うので、yesでもnoでもあまり気にしなくていいかなと思います。私は、最後の質問のみ「yes」にしました。長いので折りたたんで乗せています。参考までに。

実行結果
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: 
Please set the password for root here.

New password: 

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) :   

 ... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
CREATE DATABASE redmine CHARACTER SET utf8mb4;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'username'@'localhost';
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| redmine            |
| sys                |
+--------------------+

redmineが作成されているのでOK

Redmineインストール

以下サイトからGUIで、5.1.1をダウンロード
https://www.redmine.org/projects/redmine/wiki/Download

その後、また、CUIでフォルダ内で解凍

tar -zxvf redmine-5.1.1.tar.gz 

フォルダ移動

cd redmine-5.1.1

データベースとRedmineの接続設定

config/database.example.yml をコピーして config/database.yml を作成する。

cp config/database.yml.example config/database.yml

そして config/database.yml を編集しusernameとpasswordを編集

vi config/database.yml

プロジェクトで使用するRubyバージョンを指定する

rbenv local 3.1.4

プロジェクトごとに使用するGemを管理するため bundler をインストール

rbenv exec gem install bundler

Redmine の開発でも行わない限り development や test は不要なので除外する。また、インストール先のパスを vendor/bundle に指定する。この設定により、プロジェクト直下に .bundle/config が作成される。

bundle config without 'development test' --local
bundle config set path 'vendor/bundle' --local

Redmineに必要なGemをインストールする。redmine-4.1直下の Gemfile の設定に従いインストールされる。

bundle install

セッション秘密鍵の生成

bundle exec rake generate_secret_token

データベーステーブルの作成

RAILS_ENV=production bundle exec rake db:migrate

デフォルトデータの登録

RAILS_ENV=production bundle exec rake redmine:load_default_data

※言語の一覧が表示されるので、「ja」を選択

動作確認

以下でサーバを起動

bundle exec rails server -e production

ブラウザでhttp://localhost:3000 を入力しRedmineのトップページが立ち上がっていることを確認し完了🦝

image.png

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2