2024-04-11
Redmine을 설치 하기 위해서 3일 이상 삽질을 했다.
10개 이상의 설치 관련 글들을 보면서 시도를 했는데, 권한과 passenger 설정 문제로 대부분 실패 했었다.
그리고 아래 링크를 따라해서 성공 했다.
링크: https://www.linuxcloudvps.com/blog/how-to-install-redmine-on-ubuntu-22-04/

아래는 위 링크를 실제로 따라해보면서 나온 결과물이다.

일단 처음엔 root로 접속해서 일일이 sudo를 안쳐도 되는 상태로 만든뒤에, 우분투 버전을 확인한다.
root@b1ix:/home/b1ix# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy
22.04버전이면 일단 안심이다.

다음은 apt를 업데이트 한뒤, Redmine에 필요한 의존성 프로그램들을 설치한다
root@b1ix:/home/b1ix# apt update root@b1ix:/home/b1ix# apt install build-essential ruby-dev libxslt1-dev libmariadb-dev gnupg2 bison libbison-dev libgdbm-dev libncurses-dev libncurses5-dev libxml2-dev zlib1g-dev imagemagick libmagickwand-dev libreadline-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3

설치가 끝났으면, redmine이라는 이름의 user를 생성한 뒤 해당 그룹에 www-data도 추가해준다
root@b1ix:/home/b1ix# useradd -r -m -d /opt/redmine -s /bin/bash redmine root@b1ix:/home/b1ix# usermod -aG redmine www-data

웹서버로 쓰일 nginx를 설치하고 설정파일을 설정한다.
root@b1ix:/home/b1ix# apt install nginx root@b1ix:/home/b1ix# apt install -y dirmngr gnupg apt-transport-https ca-certificates curl root@b1ix:/home/b1ix# curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt | gpg --dearmor | tee /etc/apt/trusted.gpg.d/phusion.gpg >/dev/null root@b1ix:/home/b1ix# sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger jammy main > /etc/apt/sources.list.d/passenger.list' root@b1ix:/# apt update root@b1ix:/# apt install libnginx-mod-http-passenger -y root@b1ix:/# systemctl restart nginx root@b1ix:/# vim /etc/nginx/conf.d/redmine.yourdomain.com.conf
설정 파일에서 listen에 원하는 port를, server_name에 Redmine을 돌릴 서버 주소를 적어 놓는다.
server {
	listen 80;
	server_name redmine.yourdomain.com;

	root /opt/redmine/public;

	access_log /var/log/nginx/your_domain.com.access.log;
	error_log /var/log/nginx/your_domain.com.error.log;
	passenger_enabled on;
	passenger_min_instances 1;
	client_max_body_size 10m;
}
root@b1ix:/# systemctl restart nginx

데이터베이스로 쓰일 mariadb를 설치하고 유저 설정을 한다.
root@b1ix:/# apt install mariadb-server root@b1ix:/# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 38 Server version: 10.6.16-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE redminedb; Query OK, 1 row affected (0.000 sec) MariaDB [(none)]> GRANT ALL on redminedb.* to redmineuser@localhost identified by 'mariadb_password'; Query OK, 0 rows affected (0.001 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> \q Bye

자 이제 본격적으로 Redmine을 설치해보자!
설치 도중에 user를 변경해 가며 권한을 줘야 하기 때문에 하나하나 잘 따라서 하지 않으면 나중에 오류가 뜨니 이부분은 특히 잘 보면서 하길 바란다.
root@b1ix:/# cd /opt/redmine/ root@b1ix:/opt/redmine# wget https://www.redmine.org/releases/redmine-5.0.5.tar.gz root@b1ix:/opt/redmine# tar -xzvf redmine-5.0.5.tar.gz -C /opt/redmine/ --strip-components=1 root@b1ix:/opt/redmine# chown -R redmine. /opt/redmine/ root@b1ix:/opt/redmine# su - redmine redmine@b1ix:~$ redmine@b1ix:~$ cp -a /opt/redmine/config/configuration.yml{.example,} redmine@b1ix:~$ cp -a /opt/redmine/config/database.yml{.example,} redmine@b1ix:~$ cp -a /opt/redmine/public/dispatch.fcgi{.example,} redmine@b1ix:~$ vim /opt/redmine/config/database.yml
Redmine을 download한 뒤 설정 파일을 복사하고, 설정파일중 database에 대한 부분을 아래와 같이 바꾼다.
production:
adapter: mysql2
database: redminedb
host: localhost
username: redmineuser
password: "mariadb_password"
# Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
encoding: utf8mb4
root계정으로 돌아간 뒤에 bundler를 설치하고, 미리 설치해둔 mariadb에 마이그레이션을 진행한뒤, gem을 업데이트 하면 끝난다.
redmine@b1ix:~$ exit logout root@b1ix:/opt/redmine# root@b1ix:/opt/redmine# cd /opt/redmine && gem install bundler root@b1ix:/opt/redmine# su - redmine redmine@b1ix:~$ redmine@b1ix:~$ bundle config set --local path 'vendor/bundle' redmine@b1ix:~$ bundle install redmine@b1ix:~$ bundle update redmine@b1ix:~$ bundle exec rake generate_secret_token redmine@b1ix:~$ RAILS_ENV=production bundle exec rake db:migrate redmine@b1ix:~$ RAILS_ENV=production REDMINE_LANG=en bundle exec rake redmine:load_default_data redmine@b1ix:~$ exit logout root@b1ix:/opt/redmine# root@b1ix:/opt/redmine# gem update
설치 도중 user를 변경해서 해야 하는 부분들은 잘 따라 하지 않으면, 차후 권한 문제가 발생 할 수 있으니 명심 하길 바란다.

이제 nginx에서 설정한 주소에 들어가면 Redmine웹페이지가 뜰 것이다.
관리자 아이디 // 비빌번호는 admin // admin 이니, 로그인 해서 비밀번호부터 변경 하고 잘 쓰길 바란다.