プロジェクト

全般

プロフィール

001a_Ubuntu 20.04系にRedmine4.2(Redmine5.0)をインストール

バージョン 1 (手動人形, 2023/01/17 14:35) → バージョン 2/19 (手動人形, 2023/01/17 15:18)

{{TOC}}

## 本記事の目的(対象とする読者)

- Ubuntuサーバの基礎設定は終わったので、redmineをインストールしたい。
- 取り敢えず動くところまで確認したい。

## 本記事で実施すること

1. redmineを動かすためのパッケージがインストールできるように準備をします。
1. redmineを動かすためのパッケージ(Ruby/データベース/Webサービスなど)をインストールします。
1. データベースやWebサービスの基礎設定を行います。
1. redmineの動作確認を行います。

### 特記事項

- インストールするredmineのバージョンは4.2です。
- 5.x系にしないのは「筆者が使いたいプラグインが4.2系まででしか動作確認できなかった(2023年1月現在)」という単純にして重要な理由です。

## 手順

### ## 前提

- Ubuntuサーバの初期設定が終わった直後の状態を想定します。
- インストールするredmineのバージョンは4.2です。5.x系にしないのは「筆者が使いたいプラグインが4.2系まででしか動作確認できなかった」という単純にして重要な理由です。
-
環境は以下の通りです。
- Apache系
- MySQL
- Ruby 2.7
- また、パッケージ管理としてaptitudeを用いています。aptが好みの方はこちらに読み替えてください。

### 必要なパッケージをインストールします。

```bash
sudo aptitude update

sudo aptitude install build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev libffi-dev mysql-server mysql-client apache2 apache2-dev libapr1-dev libaprutil1-dev imagemagick libmagick++-dev fonts-takao-pgothic subversion git ruby libruby ruby-dev libmysqlclient-dev

```

### apacheの追加モジュールをインストールします。

```bash
sudo aptitude install libapache2-mod-passenger
```

### rubyのパッケージ管理(gem)を用いて必要なライブラリをインストールします。

```bash
sudo gem install bundler racc mysql2
# 「3 gems installed」が表示されればインストール成功です。
```

### mysqlの初期設定を行います。

#### mysql設定変更

```bash
sudo mkdir /etc/old
# 各種設定ファイルのバックアップをここに格納します。

sudo cp -pi /etc/mysql/mysql.conf.d/mysqld.cnf /etc/old/mysqld.cnf.$(date +%Y%m%d)
# .$(date +%Y%m%d)をつけることで、バックアップファイルは当日日付(YYYYMMDD形式)で記録されます

diff -u /etc/mysql/mysql.conf.d/mysqld.cnf /etc/old/mysqld.cnf.$(date +%Y%m%d)
# バックアップが取れていることを「差分が存在しないこと」で確認します

echo -e "default_authentication_plugin=mysql_native_password" | sudo tee -a /etc/mysql/mysql.conf.d/mysqld.cnf
# mysqld.cnfに追記をします

```

#### 設定後の差分確認

```bash
diff -u /etc/old/mysqld.cnf.$(date +%Y%m%d) /etc/mysql/mysql.conf.d/mysqld.cnf
```

```diff
+default_authentication_plugin=mysql_native_password
```

#### 設定反映

```bash
sudo systemctl restart mysql.service
```

#### mysql rootパスワード変更

```bash
mysql -u root -p
# 未設定のためパスワードは不要です
```

```sql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
#''のpasswordは任意のものを入力ください

flush privileges;

exit

```

#### mysql_secure_installation

```bash
sudo mysql_secure_installation
```

#### 質問事項

```
Enter password for user root:
# 上記で設定したパスワードを入力します

VALIDATE PASSWORD COMPONENT 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 component?

Press y|Y for Yes, any other key for No:
# Yを入力してEnter

There are three levels of password validation policy:

LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
# ポリシーに合わせて0/1/2を入力

Estimated strength of the password: 50
Change the password for root ? ((Press y|Y for Yes, any other key for No) :
# 既に設定しているのでn

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) :
# anonymousユーザーを削除するためY

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) :
# rootユーザのリモートログインを禁止するためY

Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
# テストDBを削除するためY

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
# 設定を反映するためy
```

### mysqlでDBとユーザーを設定します。

```bash
sudo mysql -u root -p
# 上記で設定した「mysqlのrootパスワード」を入力し、mysqlにログインします
```

```mysql
CREATE DATABASE redmine character set utf8mb4;
# DB "redmine" を作成します

CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'password';
# ユーザ "redmine"を作成し、パスワードを設定します
# この'password'は任意のパスワードに変更してください

GRANT ALL ON redmine.* TO 'redmine'@'localhost';
# DB "redmine"の権限をユーザ "redmine"に委譲します

flush privileges;
# 設定を反映させます

exit
```
トップへ
クリップボードから画像を追加 (サイズの上限: 50 MB)