大分から発信!とあるエンジニアの独り言

自社サイト構築にあたり調査した内容などをメモする。主にPHP、MYSQL、Linux、IDEなど

CentOS7 64bitにプロジェクト管理ソフトウェアRedmineをインストールしてみる

CentOS7 64bitにプロジェクト管理ソフトウェアRedmineをインストール

今回ちょっと長いです。

環境

Windows8.1にvmware playerをインストールしてCentOS7を稼働させています。
CentOS7をインストール直後にRedmineを入れる手順をメモ。

Redmineインストール参考サイト

参考にしているサイトは前回紹介したRedmineの日本語情報サイトです。
Redmine.JP — Redmine日本語情報サイト
・自分で環境を構築する: ダウンロード | インストール
インストールを選択。
CentOS向け Redmine 2.5 インストール手順 (Redmine.JP Blog)

この情報を元にCentOS7にRedmineをインストールしたいと思います。

Redmineインストール

SELinuxを無効にする

[root@centos ~]# getenforce ← SELinux状態確認
Enforcing ← SELinux有効

[root@centos ~]# setenforce 0 ← SELinux無効化

[root@centos ~]# getenforce ← SELinux状態確認
Permissive ← SELinux無効

[root@centos ~]# vi /etc/sysconfig/selinux ← SELinux設定ファイル編集
SELINUX=enforcing

SELINUX=disabled ← システム起動時にSELinuxを無効化
[root@centos ~]# reboot ←再起動
[root@centos ~]# getenforce ← SELinux状態確認
Disabled ← SELinux無効になっていることを確認

iptablesでHTTPを許可

80番ポート開放

[root@localhost sysconfig]# vi iptables

# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configur
ation

filter

:INPUT ACCEPT
:FORWARD ACCEPT
:OUTPUT ACCEPT

  • A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  • A INPUT -p icmp -j ACCEPT
  • A INPUT -i lo -j ACCEPT
  • A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
  • A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT ←追加
  • A INPUT -j REJECT --reject-with icmp-host-prohibited
  • A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

iptables再起動

[root@localhost sysconfig]# service iptables restart
Redirecting to /bin/systemctl restart iptables.service

EPELリポジトリの登録

これが手順通りだと下記のエラーになりました。

[root@localhost sysconfig]# rpm -Uvh epel-releasehttp://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
エラー: epel-releasehttp://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm のオープンに失敗: そのようなファイルやディレクトリはありません

そのためyumを使ってインストールします。

[root@localhost sysconfig]# yum install epel-release

インストールされたか確認します

[root@localhost sysconfig]# yum repolist
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.fairway.ne.jp
* epel: mirror.premi.st ←これが追加されていればOK
* extras: mirror.fairway.ne.jp
* updates: ftp.nara.wide.ad.jp
リポジトリー ID リポジトリー名 状態
base/7/x86_64 CentOS-7 - Base 8,465
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 6,056
extras/7/x86_64 CentOS-7 - Extras 44
updates/7/x86_64 CentOS-7 - Updates 1,011
repolist: 15,576

開発ツール(Cコンパイラ等)のインストール

またエラー…

[root@localhost sysconfig]# yum groupinstall "Development Tools"
読み込んだプラグイン:fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirror.fairway.ne.jp
* epel: ftp.tsukuba.wide.ad.jp
* extras: mirror.fairway.ne.jp
* updates: ftp.nara.wide.ad.jp
Warning: Group development does not have any packages to install.
Maybe run: yum groups mark install (see man yum)
インストールまたは更新に利用できるいくつかの要求されたグループにパッケージがありません

まじ英語嫌い。Linuxも嫌い。とりあえずDevelopment Toolsは既にインストールされていたみたいです。

RubyとPassengerのビルドに必要なヘッダファイルなどのインストール

yum -y install openssl-devel readline-devel zlib-devel curl-devel libyaml-devel

MySQLとヘッダファイルのインストール

yum -y install mysql-server mysql-devel

Apacheとヘッダファイルのインストール

yum -y install httpd httpd-devel

ImageMagickとヘッダファイル・日本語フォントのインストール

yum -y install ImageMagick ImageMagick-devel ipa-pgothic-fonts

Rubyのインストール

下記のURLから最新のRubyをダウンロードして下さい。
ダウンロード
f:id:daiki2034:20141014181319p:plain
最新の安定版:Ruby 2.*.*←ここで右クリックして「リンクのアドレスコピー」
2014/10/14現在は2.1.3が最新バージョンなのでこれをインストールします。
http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.3.tar.gz

curl -O http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.3.tar.gz

ダウンロードしたら解凍

[root@localhost sysconfig]# tar zxvf ruby-2.1.3.tar.gz
[root@localhost sysconfig]# cd ruby-2.1.3-p451
[root@localhost sysconfig]# ./configure --disable-install-doc
[root@localhost sysconfig]# make

................................やらかしたwww

Redmine 2.5は2014年2月にリリースされたRuby 2.1には対応していません。必ずRuby 2.0をインストールしてください。

ちょwwまじかwwwと思ってオフィシャルサイト行ったら
現在はバージョン2.5.2でRuby2.1に対応してました!!

ということで続き

[root@localhost ruby-2.1.3]# make install

ちゃんとインストールされたか確認します

[root@localhost ruby-2.1.3]# ruby -v
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]

bundlerのインストール

bundlerとはRedmineが使用するGemを一括インストールするためのツールです。

[root@localhost sysconfig]# gem install bundler --no-rdoc --no-ri
Fetching: bundler-1.7.3.gem (100%)
Successfully installed bundler-1.7.3
1 gem installed

MySQLの設定

デフォルトのキャラセットをUTF-8に変更する

vi /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

character-set-server=utf8 ←これ追加

# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

[mysql]
default-character-set=8 ←これ追加

#
# include all files from the config directory
#

mysqlを起動します

[root@localhost /]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.

エラーですね。。。
CentOS7からMysqlの代わりにMariaDBがインストールされます。
せっかくなのでこれ使ってみます。

sudo yum install mariadb-server mariadb-devel

途中、インストールするか聞かれるのでyを入力

Is this ok [y/d/N]: y

キャラクターセットをutf8に
/etc/my.cnf.d/server.cnfに追記
[mysqld]
character-set-server = utf8
/etc/my.cnf.d/mysql-clients.cnfに追記
[mysql]
default-character-set = utf8
show-warnings

Mariadb起動

[root@localhost init.d]# systemctl start mariadb

ではMariadbに入ります。
何故かコマンドはmysql

[root@localhost init.d]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

入れたことを確認したらOKなので[exit]で出てください。

Mariadb自動起動させる

[root@localhost init.d]# systemctl enable mariadb.service
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

Redmine最新をダウンロード(現2.5.2)

[root@localhost init.d]# cd /var/lib
[root@localhost lib]# curl -O http://www.redmine.org/releases/redmine-2.5.2.tar.gz

解凍して

tar xvf redmine-2.5.2.tar.gz

ファイル移動

mv redmine-2.5.2 /var/lib/redmine

移動したフォルダに移動

[root@localhost lib]# cd /var/lib/redmine/

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

configフォルダ作成

[root@localhost redmine]# mkdir config

configフォルダに移動

[root@localhost redmine]# cd config

configフォルダにdatabase.ymlファイルを作成・確認

[root@localhost config]# touch database.yml
[root@localhost config]# ls
database.yml

database.ymlを編集する

[root@localhost config]# vi database.yml

ユーザはroot。パスワードは設定していないので空白。
通常はありえませんよ!!!ただ入れて遊んでるので今回はOKですが、、、

production:
adapter: mysql2
database: redmine
host: localhost
username: root
password:
encoding: utf8

設定ファイル config/configuration.yml の作成

[root@localhost config]# touch configuration.yml

[root@localhost config]# vi configuration.yml

example.comは変えてください。

production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "localhost"
port: 25
domain: 'example.com'

rmagick_font_path: /usr/share/fonts/ipa-pgothic/ipagp.ttf

疲れたので一旦終了!!

2018年6月
高収入アルバイト求人サイト「のみアル」をオープンしました!
初心者でも安心のナイトワークはのみアルで見つけよう|のみアル

記事はこちら↓
daiki2034.hatenablog.com