ãããVPSã®OSãCentOS 8ã«ãRedmineã4.1ã«æ´æ°
ã¾ã¨ã¾ã£ãä¼ã¿ãåããã®ã§ããããVPSã®ãµã¼ãã¼ã®OSãCentOS 7ãã8ã«ä¸ãã¦ãåããã¦Redmineã3.4ãã4.1ã«ä¸ããä½æ¥ãå®æ½ãã¦ãã¾ããæ´æ°ä½æ¥ä¸ã¯Redmineã«ã³ã³ãã³ããæããããªãã®ã§ãã¯ã¦ãªã«çµéãã¡ã¢ãããã¨ã«ãã¾ãã
CentOS 8ã¸ã®æ´æ°
ãããVPSãæä¾ããOSã¤ã³ã¹ãã¼ã«æ©è½ã§ãCentOS 8ã«ä¸ãã¾ãããããVPSãµã¼ãã®ãã¼ã¸ã§ã³ã¯v3ãªã®ã§ãæ¨æºOSã®ã¤ã³ã¹ãã¼ã«ã§ã¯CentOS 8ã¯é¸ã¹ã¾ãããã«ã¹ã¿ã OSã®ã¤ã³ã¹ãã¼ã«ã§CentOS 8ãå ¥ãã¾ãã
ãã¼ãã£ã·ã§ã³ã®è¨å®
ä»®æ³ã²ã¹ãã§ãã£ã¹ã¯ï¼ã¤ã¡ã¼ã¸ãã¡ã¤ã«ï¼ãå¢ãããã¨ããªãã®ã§ãLVMã¯ä½¿ç¨ããã/boot ã¯ext4ã/ã¯xfsãããã¨swapã®3ã¤ã®ãã¼ãã£ã·ã§ã³ãä½æãã¾ããã
ãã¦ã³ããã¤ã³ã | 容éï¼MBï¼ | ãã¡ã¤ã«ã·ã¹ãã |
---|---|---|
/boot | 1024 | ext4 |
swap | 4096 | swap |
/ | æ®ã | xfs4 |
ã¤ã³ã¹ãã¼ã«æã®ãã©ãã«
CentOS 8ã®ã¤ã³ã¹ãã¼ã©ã¼ãèµ·åããMinimal Install ã§ã¤ã³ã¹ãã¼ã«ãéå§ããã¨ãããéä¸ã§ã¨ã©ã¼åæ¢ãã¦ãã¾ãã¾ããã ãã1åã¤ã³ã¹ãã¼ã«ãããç´ããã¨ããã¨ã©ã¼ã«ã¯ãªããªãã£ãã®ã§åå ã¯ããåããã¾ããã ãªããåãã¨ã©ã¼ã¡ãã»ã¼ã¸ãåºãã¨ã®ããã°ãè¦ã¤ãã¾ããã
https://www.softel.co.jp/blogs/tech/archives/6114www.softel.co.jp
ãã®ããã°ã«ããã¨ãMinimalã¤ã³ã¹ãã¼ã«ã§ã¯chronyããã±ã¼ã¸ããªãã®ã§chronyé¢ä¿è¨å®ã使ç¨ã¨ãã¦ã¨ã©ã¼ã«ãªãã¨ã®åæã§ãã
ã¤ã³ã¹ãã¼ã«å¾ã®è¨å®
ãããVPSã§ã¤ã³ã¹ãã¼ã«ããã¨ããã®æç¹ã®ææ°ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããã¾ãããããVPSã§ç¬èªã®Kickstartãæä¾ããã¦ããããã§ããMinumalã§ã¤ã³ã¹ãã¼ã«ããã®ã§ãããchronyãgccãªã©ãã¤ã³ã¹ãã¼ã«ããã¦ããã®ã§ããããVPSã®è¨å®ããã®ä¾åé¢ä¿ã§è¿½å ã¤ã³ã¹ãã¼ã«ããã模æ§ã§ãã
æ°ä»ããç¹ã¨ãã¦ã¯ãchronyã«ããæå»åæè¨å®æ¸ã¿ããããã¯ã¼ã¯ã¯ããã¤ã¹åãeth0ãIPv6æå¹ãåºå®IPã¢ãã¬ã¹ï¼v4ãv6ï¼ä»ä¸æ¸ã¿ããã¼ã ãµã¼ãè¨å®æ¸ã¿ãã«ã¼ãã«ã®ã·ãªã¢ã«ã³ã³ã½ã¼ã«ãæå¹ãSELinuxã¯æå¹ããªã©ã§ããã
ã»ãã¥ãªãã£ä¸ãSSHã®ãã¼ãçªå·ãå¤æ´ãSSHã§ã®rootãã°ã¤ã³ç¦æ¢ã管çã°ã«ã¼ã以å¤ã®ã¢ã«ã¦ã³ãããã®suç¦æ¢ããªã©ãè¨å®ãã¾ããã
Redmine 4.1ã®ç¨¼åã«ããã¦
MariaDBã®ã¤ã³ã¹ãã¼ã«ã¨è¨å®
# dnf module install mariadb/server
MariaDBã¯ã10.3ãã¤ã³ã¹ãã¼ã«ããã¾ãããè¨å®ãã¡ã¤ã«ã«ã¯æåã³ã¼ãï¼æè¿ã¯utf8mb4ãæå®ï¼ãããã©ã¼ãã³ã¹è¨å®ãè¨è¿°ãã¾ãã
/etc/my.cnf.d/mariadb-server.cnf
ãã©ã¡ã¼ã¿å | ããã©ã«ãå¤ | è¨å®å¤ |
---|---|---|
character_set_server | latin1 | utf8mb4 |
innodb_buffer_pool_size | 128MB | 256MB |
innodb_log_file_size | 48MB | 64MB |
innodb_flush_method | fsync | O_DIRECT |
VPSã¯ã¡ã¢ãª2GBã§ããRedmineï¼Ruby on Railsã¢ããªã±ã¼ã·ã§ã³ï¼ã¯ã¡ã¢ãªå°ããªã®ã§1GBã»ã©å²ãã¦ããã¾ããæ®ã1GBãOSãæ¨æºãµã¼ãã¹ã¨MariaDBã¨ã§å ±ç¨ããã®ã§ãMariaDBã¯ãããã512MBã¡ã¢ãªã使ããã°ããã§ãããã ããã§ãinnodb_buffer_pool_sizeã¯ãã®ååã®256MBãå²ãå½ã¦ã¾ããinnodb_log_file_sizeã¯æè¿ã®ãã¼ã¸ã§ã³ã§ããã©ã«ãå¤ãå¢ãã¾ããããããã¯éå»ã®è¨å®å¤ã®64MBãæµç¨ãã¾ãã innodb_flush_methodã¯O_DIRECTãæå®ãããã¨ã§ãã¼ã¿ãã¡ã¤ã«ãéãã¨ãã«OSã®ãã£ã¹ã¯ãã£ãã·ã¥ã使ãããªãã®ã§OSå ¨ä½ã®ã¡ã¢ãªä½¿ç¨ãæ¸ãã¾ãããã®åRedmineã«ã¡ã¢ãªãå²å½ã¦ããã¾ãã
/etc/my.cnf.d/mysql-client.cnf
[mysql] default_character_set = utf8mb4 show-warnings
ãµã¼ãã¹ã®ç»é²ã¨èµ·å
# systemctl enable --now mariadb
ã»ãã¥ã¢ãªåæè¨å®ï¼mysql_secure_installationï¼
MariaDBã®ããã©ã«ãè¨å®ã§ä½ãããrootã¢ã«ã¦ã³ãã«ãã¹ã¯ã¼ããè¨å®ããªã¢ã¼ãããã®rootãã°ã¤ã³ç¦æ¢ãå¿åã¢ã«ã¦ã³ãã®åé¤ãtestãã¼ã¿ãã¼ã¹ã®åé¤ãè¡ãã¾ããæä½æ¥ã§ã¯ã¡ãã£ã¨å¤§å¤ã§ãããã¹ã¯ãªãã mysql_secure_installationãç¨æããã¦ããã®ã§ãããå®è¡ãã¦è¨å®ãã¾ãã
# mysql_sequre_installation # mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB 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? [Y/n] ... Success! 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? [Y/n] ... Success! By default, MariaDB 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? [Y/n] - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Redmineããæ¥ç¶ããã¢ã«ã¦ã³ãã®ä½æ
MariaDBä¸ã«Redmineã®ãã¼ã¿ãã¼ã¹ã¨æ¥ç¶ããã¢ã«ã¦ã³ããä½æãã¾ãã
MariaDB [(none)]> CREATE DATABASE redmine; Query OK, 1 row affected (0.002 sec)
MariaDB [(none)]> GRANT ALL ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'tiger' WITH GRANT OPTION; Query OK, 0 rows affected (0.001 sec)
- IDENTIFIED BY ã®å¾ãã«ã¢ã«ã¦ã³ãã®ãã¹ã¯ã¼ããè¨è¿°ãã¾ãï¼ããã§ã¯ä¾ç¤ºã®ãã 'tiger'ãæå®ï¼ã
MariaDBéçºããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«
# dnf install mariadb-devel
Rubyã®ã¤ã³ã¹ãã¼ã«
CentOS 8ã§ã¯ãããã±ã¼ã¸ã«ã¢ã¸ã¥ã¼ã«ã¨ããæ¦å¿µãå°å ¥ããã¦ããï¼MariaDBãã¢ã¸ã¥ã¼ã«ï¼ãRubyãã¢ã¸ã¥ã¼ã«ã§ã¤ã³ã¹ãã¼ã«ãã¾ãã ã¢ã¸ã¥ã¼ã«ã§ã¯è¤æ°ãã¼ã¸ã§ã³ãå¶å¾¡ãã¦ã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ãã
# dnf module list ruby CentOS-8 - AppStream 4.2 kB/s | 4.3 kB 00:01 CentOS-8 - Base 4.9 kB/s | 3.9 kB 00:00 CentOS-8 - Extras 2.6 kB/s | 1.5 kB 00:00 CentOS-8 - AppStream Name Stream Profiles Summary ruby 2.5 [d] common [d] An interpreter of object-oriented scripting language ruby 2.6 common An interpreter of object-oriented scripting language ãã³ã: [d]efault, [e]nabled, [x]disabled, [i]nstalled
ç¾å¨ã®CentOS 8ã§ã¯ãRubyã¯2.5ã¨2.6ãã¢ã¸ã¥ã¼ã«ã¨ãã¦æä¾ããã¦ãã¾ããããã©ã«ãã¯2.5ã§ãããããã§ã¯2.6ãã¤ã³ã¹ãã¼ã«ãã¾ãã ãªããRedmine 4.0.1ã§Ruby 2.6ã«å¯¾å¿ãã¦ãã¾ãï¼https://www.redmine.org/issues/30118ï¼ã
# dnf module enable ruby:2.6
# dnf module install ruby/common
ruby-develã¯ã¤ã³ã¹ãã¼ã«ãããªãã®ã§ãåå¥ã«ã¤ã³ã¹ãã¼ã«ãã¾ããã¾ããrubyã®bundlerãããã±ã¼ã¸ãç¨æããã¦ããã®ã§åå¥ã«ã¤ã³ã¹ãã¼ã«ãã¾ãã ããã±ã¼ã¸ã®æ å ±ãè¦ãã¨ã次ã®ããã« ruby-2.6ã«å¯¾å¿ããããã±ã¼ã¸ã¨ãªã£ã¦ãã¾ãã
# dnf info ruby-devel rubygem-bundler åå : ruby-devel ãã¼ã¸ã§ã³ : 2.6.3 ãªãªã¼ã¹ : 106.module_el8.1.0+249+93480f15 Arch : x86_64 ãµã¤ãº : 243 k ã½ã¼ã¹ : ruby-2.6.3-106.module_el8.1.0+249+93480f15.src.rpm ãªãã¸ããªã¼ : AppStream æ¦è¦ : A Ruby development environment URL : http://ruby-lang.org/ ã©ã¤ã»ã³ã¹ : (Ruby or BSD) and Public Domain and MIT and CC0 and zlib and UCD 説æ : Header files and libraries for building an extension library for : the Ruby or an application embedding Ruby. åå : rubygem-bundler ãã¼ã¸ã§ã³ : 1.17.2 ãªãªã¼ã¹ : 106.module_el8.1.0+249+93480f15 Arch : noarch ãµã¤ãº : 354 k ã½ã¼ã¹ : ruby-2.6.3-106.module_el8.1.0+249+93480f15.src.rpm ãªãã¸ããªã¼ : AppStream æ¦è¦ : Library and utilities to manage a Ruby application's gem : dependencies URL : http://ruby-lang.org/ ã©ã¤ã»ã³ã¹ : MIT 説æ : Bundler manages an application's dependencies through its entire : life, across many machines, systematically and repeatably.
# dnf install ruby-devel rubygem-bundler
Redmineã®ã¤ã³ã¹ãã¼ã«
Redmineã¢ããªã±ã¼ã·ã§ã³ã®å®è¡ã¦ã¼ã¶ã¼ã¯root権éã§ã¯ãªãå°ç¨ã®ã¦ã¼ã¶ã¼ã¨ãã¾ãã
redmineã¢ã«ã¦ã³ãã®ä½æ
# useradd redmine # passwd redmine ã¦ã¼ã¶ã¼ redmine ã®ãã¹ã¯ã¼ããå¤æ´ã æ°ãããã¹ã¯ã¼ã:************ æ°ãããã¹ã¯ã¼ããåå ¥åãã¦ãã ãã:************ passwd: ãã¹ã¦ã®èªè¨¼ãã¼ã¯ã³ãæ£ããæ´æ°ã§ãã¾ããã
redmineããªãã¸ããªããã¯ãã¼ã³
Redmineã®ãã¼ã¸ã§ã³ã¢ããã«è¿½å¾ãããããããããRedmineã®ã¤ã³ã¹ãã¼ã«ã¯ tarballãå±éããã®ã§ã¯ãªãããªãã¸ããªã®ã¯ãã¼ã³ãå±éãã¾ããRedmineã®å ¬å¼ãªãã¸ããªã¯Subversionã§ãããæè¿ã¯gitã®æ¹ã管çã»æä½ã容æã¨ãªã£ã¦ããã®ã§ãRedmineã®gitãã©ã¼ãªãã¸ããªããã¯ãã¼ã³ãã¾ãããã©ã³ãã¯ããªãªã¼ã¹ãã©ã³ããæå®ãã¾ãã
# cd /var/lib # git clone -b 4.1-stable https://github.com/redmine/redmine.git redmine-4.1-stable # chown -R redmine:redmine redmine-4.1-stable/
ãã¼ã¿ãã¼ã¹è¨å®
redmineã®config/database.yml ãä½æãã¾ãã
production: adapter: mysql2 database: redmine host: localhost username: redmine password: xxxxxxxx encoding: utf8mb4
ãã¼ããã·ã§ã³ãå³ãããã¦ããã¾ãã
$ chmod 0600 /var/lib/redmine-4.1-stable/config/database.yml
ã¡ã¼ã«éç¥ãã®ä»ã®è¨å®
ä»åã¯ã¡ã¼ã«é ä¿¡ç°å¢ãImageMagickï¼äºæï¼ç°å¢ãç¨æãã¦ããªãã®ã§ãconfiguration.ymlã®è¨å®ã¯çç¥ãã¾ãã å¾æ¥å¿ è¦ãçãããè¨å®ãè¡ãã¾ãã
移è¡åã®ãã¼ã¿ãã¼ã¹ã復å
ããã¯ã¢ãããã¦ããMariaDBã®Redmineãã¼ã¿ãã¼ã¹ãæ°ãããã¼ã¿ãã¼ã¹ã¸ã¤ã³ãã¼ããã¾ãã
$ mysql -uredmine -p redmine < redmine_mysql_www.torutk.com-20200424.dump
Redmineã使ç¨ããrubyã¢ã¸ã¥ã¼ã«ç¾¤ã®ã¤ã³ã¹ãã¼ã«
Redmineã使ç¨ããrubyã®ã¢ã¸ã¥ã¼ã«ç¾¤ãã¤ã³ã¹ãã¼ã«ãã¾ããrubyã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«ã«ã¯ãrubyã®bundlerã使ç¨ãã¾ãã Redmineã®ã¤ã³ã¹ãã¼ã«ãã£ã¬ã¯ããªä¸ã®vender/bundlerãæå®ããããã¸ã¤ã³ã¹ãã¼ã«ãã¾ãã
ã¦ã¼ã¶ã¼redmineã§ä»¥ä¸ãå®è¡ãã¾ãã
$ cd /var/lib/redmine-4.1-stable $ bundle install --path vendor/bundler --without development test rmagick : Gems in the groups development, test and rmagick were not installed. Bundled gems are installed into `./vendor/bundler`
ã»ãã·ã§ã³ãã¼ã¿æå·åã®éµçæ
$ bundle exec rails generate_secret_token
ãã¼ã¿ãã¼ã¹ã¹ãã¼ãã®æ´æ°
ç¾æç¹ã§MariaDBã®readmineãã¼ã¿ãã¼ã¹ã«æ ¼ç´ããã¦ãããã¼ã¿ã¯ãæ§Redmine 3.4ã®ãã¼ã¿ã復å ãããã®ã§ãã ããã§ãRedmine 4.1ã®ã¹ãã¼ãã«æ´æ°ããå¿ è¦ãããã¾ãã
$ bundle exec rails db:migrate RAILS_ENV=production == 20170723112801 RenameCommentsToContent: migrating ========================== -- rename_column(:comments, :comments, :content) -> 0.0073s == 20170723112801 RenameCommentsToContent: migrated (0.0076s) ================= == 20180501132547 AddAuthorIdToTimeEntries: migrating ========================= -- add_column(:time_entries, :author_id, :integer, {:default=>nil, :after=>:project_id}) -> 0.0335s == 20180501132547 AddAuthorIdToTimeEntries: migrated (0.0485s) ================ == 20180913072918 AddVerifyPeerToAuthSources: migrating ======================= -- change_table(:auth_sources) -> 0.0025s == 20180913072918 AddVerifyPeerToAuthSources: migrated (0.0026s) ============== == 20180923082945 ChangeSqliteBooleansTo0And1: migrating ====================== == 20180923082945 ChangeSqliteBooleansTo0And1: migrated (0.0000s) ============= == 20180923091603 ChangeSqliteBooleansDefault: migrating ====================== == 20180923091603 ChangeSqliteBooleansDefault: migrated (0.0000s) ============= == 20190315094151 ChangeCustomValuesValueLimit: migrating ===================== -- change_column(:custom_values, :value, :text, {:limit=>16777216}) -> 0.0289s == 20190315094151 ChangeCustomValuesValueLimit: migrated (0.0291s) ============ == 20190315102101 AddTrackersDescription: migrating =========================== -- add_column(:trackers, :description, :string, {:after=>:name}) -> 0.0201s == 20190315102101 AddTrackersDescription: migrated (0.0203s) ================== == 20190510070108 AddUniqueIdToImportItems: migrating ========================= -- change_table(:import_items) -> 0.0098s == 20190510070108 AddUniqueIdToImportItems: migrated (0.0100s) ================ == 20190620135549 ChangeRolesNameLimit: migrating ============================= -- change_column(:roles, :name, :string, {:limit=>255, :default=>""}) -> 0.0182s == 20190620135549 ChangeRolesNameLimit: migrated (0.0184s) ====================
ä¸åº¦åä½ç¢ºèªãï¼WEBrickï¼
ããã§ããã£ããåä½ç¢ºèªããã¾ããRedmineï¼Ruby on Railsï¼å梱ã®Webã¢ããªã±ã¼ã·ã§ã³ãµã¼ãã¼ WEBrick ã§Redmineã®åä½ç¢ºèªããã¾ãã
ä¸æçã«ãã¼ã3000ãéããWEBrickãµã¼ãã¼ãåããRedmineãåãã¦ãããã確èªãã¾ãã
# firewall-cmd --add-port=3000/tcp success
$ bundle exec rails server -e production => Booting WEBrick => Rails 5.2.4.2 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options [2020-04-24 23:25:39] INFO WEBrick 1.4.2 [2020-04-24 23:25:39] INFO ruby 2.6.3 (2019-04-16) [x86_64-linux] [2020-04-24 23:25:39] INFO WEBrick::HTTPServer#start: pid=31266 port=3000
ããã§ãã©ã¦ã¶ãããã¼ã3000ã¸ã¢ã¯ã»ã¹ãã¾ããRedmineç»é¢ã表示ããããOKã§ãã ãã®æç¹ã§ã¯ã¾ã Redmineã®ãã©ã°ã¤ã³ãå ¥ãã¦ããªãã®ã§ããã©ã°ã¤ã³ã®åä½ã«ã¤ãã¦ã¯ç¢ºèªã§ãã¾ããã
ãã®å¾ã¯ãUnicornãNginxãå ¥ãã¦ä¸éãåä½ãå®äºããå¾ã«Redmineã®ãã©ã°ã¤ã³ãå ¥ãããã¨ã¨ãã¾ãã
æ¬æ¥ã®ä½æ¥ã¯ããã¾ã§ã¨ããä¸æçã«éãããã¼ã3000ãéãã¾ãã
# firewall-cmd --reload