{"id":4405,"date":"2022-07-02T22:26:33","date_gmt":"2022-07-02T13:26:33","guid":{"rendered":"https:\/\/pvision.jp\/tech\/?p=4405"},"modified":"2023-04-08T14:51:47","modified_gmt":"2023-04-08T05:51:47","slug":"step-by-step-install-redmine-4-2-5-0-with-ruby-2-7-on-ubuntu","status":"publish","type":"post","link":"https:\/\/pvision.jp\/apps\/2022\/07\/02\/step-by-step-install-redmine-4-2-5-0-with-ruby-2-7-on-ubuntu\/","title":{"rendered":"Step-by-Step: Install Redmine 4.2\/5.0 with Ruby 2.7 on Ubuntu"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>In this article, I will explain how to install Redmine 4.2\/5.0 with Ruby 2.7 on Ubuntu step-by-step. You can easily follow the process in a copy-and-paste manner.<\/p>\n\n\n\n<p>If you are looking for the installation procedure for Redmine 5.0 and Ruby 3.1, please refer to the following article:<\/p>\n\n\n\n<p><a href=\"https:\/\/pvision.jp\/apps\/2022\/07\/step-by-step-install-redmine-5-0-with-ruby-3-1-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">Step-by-Step: Install Redmine 5.0 with Ruby 3.1 on Ubuntu<\/a><\/p>\n\n\n\n<div class=\"wp-block-cocoon-blocks-blank-box-1 blank-box block-box\">\n<p>If you are interested in improving the Redmine user experience for your project members, please check the following:<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/trello.com\/power-ups\/617c2d2289d99f306863e8fa\/redsync-w-redmine\" target=\"_blank\">RedSync &#8211; A Trello Power-Up to Integrate Redmine to Trello<\/a><\/p>\n\n\n\n<p>You can use Trello as a front end of Redmine and enjoy Trello&#8217;s excellent user interface and capabilities, such as a checklist on a card, kanban boards, automated workflow, etc.<\/p>\n\n\n\n<p>In addition to the standard Redmine functions, you can edit the schedule on the Gantt chart and collaborate with outside partners who do not have Redmine accounts on your system.<\/p>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Environment<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>OS: Ubuntu 20.04 LTS \/ 22.04 LTS<\/li>\n\n\n\n<li>Redmine: 4.2, 5.0<\/li>\n\n\n\n<li>Ruby: 2.7<\/li>\n\n\n\n<li>Rails: 5.2, 6.1 (included in Redmine)<\/li>\n\n\n\n<li>MySQL: 8.0<\/li>\n<\/ul>\n\n\n\n<p>The above combination of versions is the latest (except for Ubuntu) at the time of writing. Please check the newest prerequisite software versions for Redmine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installation Steps<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Setup Ubuntu<\/li>\n\n\n\n<li>Setup MySQL<\/li>\n\n\n\n<li>Setup Ruby<\/li>\n\n\n\n<li>Setup Redmine<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Setup Ubuntu<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Install Ubuntu<\/h3>\n\n\n\n<p>Follow the official guide applicable to your environment.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create User<\/h3>\n\n\n\n<p>Create a user for Redmine operations.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo adduser redmine<\/code><\/pre><\/div>\n\n\n\n<p>Enable the user as a sudoer.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo gpasswd -a redmine sudo<\/code><\/pre><\/div>\n\n\n\n<p>Hereafter, log in as <span class=\"bold-blue\">redmine<\/span>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Library<\/h3>\n\n\n\n<p>Update the package list and upgrade the installed modules.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo apt update<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo apt upgrade -y<\/code><\/pre><\/div>\n\n\n\n<p>Install the library required for the subsequent operations.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo apt install -y build-essential<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Setup MySQL<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Install MySQL<\/h3>\n\n\n\n<p>Check available MySQL versions from the Community Edition page and identify the suitable version for Redmine 5.0. (as of writing, 0.8.22-1_all)<\/p>\n\n\n\n<p>Obtain the package URL, download it with wget and add it to the repository.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd ~\nwget https:\/\/dev.mysql.com\/get\/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i mysql-apt-config_0.8.22-1_all.deb<\/code><\/pre><\/div>\n\n\n\n<p>Package Manager (dpkg) asks you which MySQL product you wish to configure. Accept the default and click OK.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/pvision.jp\/tech\/wp-content\/uploads\/2022\/06\/image-2.png\" alt=\"\" class=\"wp-image-4038\"\/><\/figure>\n\n\n\n<p>Update the package list and install MySQL with a library.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo apt update<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo apt install -y mysql-server libmysqlclient-dev<\/code><\/pre><\/div>\n\n\n\n<p>Set the root password.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/pvision.jp\/tech\/wp-content\/uploads\/2022\/06\/image.png\" alt=\"\" class=\"wp-image-4207\"\/><\/figure>\n\n\n\n<p>Select &#8220;Use Strong Password Encryption.&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/pvision.jp\/tech\/wp-content\/uploads\/2022\/06\/image-4.png\" alt=\"\" class=\"wp-image-4208\"\/><\/figure>\n\n\n\n<p>Confirm that MySQL is running.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>systemctl status mysql<\/code><\/pre><\/div>\n\n\n\n<p>You will see the following output. <strong>Active: active<\/strong> means MySQL is running.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>\u25cf mysql.service - MySQL Community Server\n     Loaded: loaded (\/lib\/systemd\/system\/mysql.service; enabled; vendor preset: enabled)\n     Active: active (running) since Fri 2022-06-17 06:53:26 UTC; 16s ago\n       Docs: man:mysqld(8)\n             http:\/\/dev.mysql.com\/doc\/refman\/en\/using-systemd.html\n   Main PID: 26378 (mysqld)\n     Status: &quot;Server is operational&quot;\n      Tasks: 38 (limit: 4575)\n     Memory: 359.0M\n     CGroup: \/system.slice\/mysql.service\n             \u2514\u250026378 \/usr\/sbin\/mysqld<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-cocoon-blocks-blank-box-1 blank-box block-box\">\n<p>New versions of MySQL may not allow you to set up the root password during the installation described above. In that case, you should alter the password with a command.<\/p>\n\n\n\n<p>Start the MySQL command shell as follows:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo mysql -u root<\/code><\/pre><\/div>\n\n\n\n<p>In the MySQL command shell, enter the following command. You need to change &lt;password&gt; to your own choice.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>ALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED WITH mysql_native_password by &#39;&lt;password&gt;&#39;;<\/code><\/pre><\/div>\n<\/div>\n\n\n\n<p>Change the default settings for safety.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo mysql_secure_installation<\/code><\/pre><\/div>\n\n\n\n<p>Example: (No specific requirement for this installation)<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>redmine@redmine-test:~$ sudo mysql_secure_installation\n\nSecuring the MySQL server deployment.\n\nEnter password for user root:\n\nVALIDATE PASSWORD COMPONENT can be used to test passwords\nand improve security. It checks the strength of password\nand allows the users to set only those passwords which are\nsecure enough. Would you like to setup VALIDATE PASSWORD component?\n\nPress y|Y for Yes, any other key for No: N\nUsing existing password for root.\nChange the password for root ? ((Press y|Y for Yes, any other key for No) : N\n\n ... skipping.\nBy default, a MySQL installation has an anonymous user,\nallowing anyone to log into MySQL without having to have\na user account created for them. This is intended only for\ntesting, and to make the installation go a bit smoother.\nYou should remove them before moving into a production\nenvironment.\n\nRemove anonymous users? (Press y|Y for Yes, any other key for No) : Y\nSuccess.\n\n\nNormally, root should only be allowed to connect from\n&#39;localhost&#39;. This ensures that someone cannot guess at\nthe root password from the network.\n\nDisallow root login remotely? (Press y|Y for Yes, any other key for No) : Y\nSuccess.\n\nBy default, MySQL comes with a database named &#39;test&#39; that\nanyone can access. This is also intended only for testing,\nand should be removed before moving into a production\nenvironment.\n\n\nRemove test database and access to it? (Press y|Y for Yes, any other key for No) : Y\n - Dropping test database...\nSuccess.\n\n - Removing privileges on test database...\nSuccess.\n\nReloading the privilege tables will ensure that all changes\nmade so far will take effect immediately.\n\nReload privilege tables now? (Press y|Y for Yes, any other key for No) : Y\nSuccess.<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Create Database and User<\/h3>\n\n\n\n<p>Start MySQL shell.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>mysql -u root -p<\/code><\/pre><\/div>\n\n\n\n<p>Create a database and user. Change the my_password as appropriate.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>CREATE DATABASE redmine CHARACTER SET utf8mb4;\nCREATE USER &#39;redmine&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;my_password&#39;;<\/code><\/pre><\/div>\n\n\n\n<p>Grant privileges on the database to the user.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>GRANT ALL PRIVILEGES ON redmine.* TO &#39;redmine&#39;@&#39;localhost&#39;;\nFLUSH PRIVILEGES;<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Setup Ruby<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Install rbenv<\/h3>\n\n\n\n<p>We use rbenv as a version management tool for Ruby.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo apt install -y rbenv<\/code><\/pre><\/div>\n\n\n\n<p>Initialize it.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>rbenv init<\/code><\/pre><\/div>\n\n\n\n<p>It displays the following message.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># Load rbenv automatically by appending\n# the following to ~\/.bashrc:\neval &quot;$(rbenv init -)&quot;<\/code><\/pre><\/div>\n\n\n\n<p>Add the above content to the .bashrc file. Bash will configure PATH etc., at starting.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd ~\nvim .bashrc<\/code><\/pre><\/div>\n\n\n\n<p>Apply the change to the current session.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>source .bashrc<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Install ruby-build<\/h3>\n\n\n\n<p>We use ruby-build with rbenv to install Ruby.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd ~\nmkdir -p &quot;$(rbenv root)&quot;\/plugins\ngit clone https:\/\/github.com\/rbenv\/ruby-build.git &quot;$(rbenv root)&quot;\/plugins\/ruby-build\ncurl -fsSL https:\/\/github.com\/rbenv\/rbenv-installer\/raw\/main\/bin\/rbenv-doctor | bash<\/code><\/pre><\/div>\n\n\n\n<p>The last command displays the following diagnostic result:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>Checking for `rbenv&#39; in PATH: \/usr\/bin\/rbenv\nChecking for rbenv shims in PATH: OK\nChecking `rbenv install&#39; support: \/home\/redmine\/.rbenv\/plugins\/ruby-build\/bin\/rbenv-install (ruby-build 20211203)\nCounting installed Ruby versions: none\n  ...\nChecking RubyGems settings: OK\nAuditing installed plugins: OK<\/code><\/pre><\/div>\n\n\n\n<p>Now you are ready to start the Ruby installation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Ruby<\/h3>\n\n\n\n<p>Confirm the installable Ruby versions.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>rbenv install --list<\/code><\/pre><\/div>\n\n\n\n<p>Install the latest version of 2.7 (as of writing, 2.7.6) for Redmine 4.2 and 5.0.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>rbenv install 2.7.6\nrbenv global 2.7.6<\/code><\/pre><\/div>\n\n\n\n<p>You can specify the Ruby version for either locally or globally in rbenv. In this case, we specify it globally.<\/p>\n\n\n\n<p>Confirm the installed version.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>ruby -v<\/code><\/pre><\/div>\n\n\n\n<p>Install a library for gem installation.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo apt install -y ruby2.7-dev<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Setup Redmine<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Install Redmine (V5.0)<\/h3>\n\n\n\n<p>Download the latest version of Redmine from the <a rel=\"noreferrer noopener\" href=\"https:\/\/redmine.org\/projects\/redmine\/wiki\/Download\" target=\"_blank\">redmine.org<\/a> site using wget and extract files.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>wget https:\/\/www.redmine.org\/releases\/redmine-5.0.2.tar.gz\ncd \/opt\nsudo tar xvf ~\/redmine-5.0.2.tar.gz<\/code><\/pre><\/div>\n\n\n\n<p>Create a link to a normalized directory name (redmine) without version numbers.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo ln -s redmine-5.0.2 redmine<\/code><\/pre><\/div>\n\n\n\n<p>Change the file owner.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo chown -R redmine:redmine redmine\/<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Install Redmine (V4.1)<\/h3>\n\n\n\n<p>Download the latest version of Redmine from the <a rel=\"noreferrer noopener\" href=\"https:\/\/redmine.org\/projects\/redmine\/wiki\/Download\" target=\"_blank\">redmine.org<\/a> site using wget and extract files.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>wget https:\/\/www.redmine.org\/releases\/redmine-4.2.7.tar.gz\ncd \/opt\nsudo tar xvf ~\/redmine-4.2.7.tar.gz<\/code><\/pre><\/div>\n\n\n\n<p>Create a link to a normalized directory name (redmine) without version numbers.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo ln -s redmine-4.2.7 redmine<\/code><\/pre><\/div>\n\n\n\n<p>Create a directory and change the file owner.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo mkdir -p redmine\/tmp\/pdf<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo chown -R redmine:redmine redmine\/<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Define Database Connection<\/h3>\n\n\n\n<p>Define the database connection in redmine\/config\/database.yml.<\/p>\n\n\n\n<p>Create a database.yml from an example file.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo cp redmine\/config\/database.yml.example redmine\/config\/database.yml<\/code><\/pre><\/div>\n\n\n\n<p>The above file has definitions for the MySQL connection. Override the following items for the production environment.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>username: redmine<\/li>\n\n\n\n<li>password: the password you specified during MySQL setup<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>production:\n  adapter: mysql2\n  database: redmine\n  host: localhost\n  username: redmine\n  password: &quot;&lt;password&gt;&quot;\n  encoding: utf8mb4<\/code><\/pre><\/div>\n\n\n\n<p>database.yml has development and test environment definitions. You can ignore them unless you are developing a part of Redmine or a plug-in.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Gems<\/h3>\n\n\n\n<p>Install gems specified in Gemfile, excluding for development and test environment.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd \/opt\/redmine\nbundle config set --local without &#39;development test&#39;\nbundle install<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Create Session Store Secret<\/h3>\n\n\n\n<p>Create the session store secret used to protect from a session hijack.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>RAILS_ENV=production bundle exec rake generate_secret_token<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Initialize Database<\/h3>\n\n\n\n<p>Create a schema and load the default data.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>RAILS_ENV=production bundle exec rake db:migrate\nRAILS_ENV=production bundle exec rake redmine:load_default_data<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Run Redmine with Puma<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Install Puma<\/h3>\n\n\n\n<p>Start Redmine server using puma.<\/p>\n\n\n\n<p>Create Gemfile.local file.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd \/opt\/redmine\nsudo vim Gemfile.local<\/code><\/pre><\/div>\n\n\n\n<p>Define the following in the Gemfile.local file.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>gem &#39;puma&#39;<\/code><\/pre><\/div>\n\n\n\n<p>Install puma gem.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>bundle install<\/code><\/pre><\/div>\n\n\n\n<p>The following message is displayed. Gemfile has the puma definition for the test environment, and the bundle reports it as duplication. In this case, we are not installing a test environment so that we can ignore the message.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>Your Gemfile lists the gem puma (&gt;= 0) more than once.\nYou should probably keep only one of them.\nRemove any duplicate entries and specify the gem only once.\nWhile it&#39;s not a problem now, it could cause errors if you change the version of one of them later.<\/code><\/pre><\/div>\n\n\n\n<p>Start the Web server.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>bundle exec puma -e production<\/code><\/pre><\/div>\n\n\n\n<p>Access the Redmine server in a Web browser.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>http:\/\/&lt;Redmine Server Address&gt;:9292<\/code><\/pre><\/div>\n\n\n\n<p>Login to Redmine.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>User ID: admin<\/li>\n\n\n\n<li>Password: admin<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Support CORS<\/h2>\n\n\n\n<p>You do not need CORS to use Redmine from a Web browser. CORS is required when a Web application accesses Redmine API.<\/p>\n\n\n\n<p>We use Rack CORS Middleware to support CORS.<\/p>\n\n\n\n<p>Edit Gemfile.local file.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd \/opt\/redmine\nsudo vim Gemfile.local<\/code><\/pre><\/div>\n\n\n\n<p>Add rack-cors gem.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>gem &#39;rack-cors&#39;<\/code><\/pre><\/div>\n\n\n\n<p>Install the gem.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>bundle install<\/code><\/pre><\/div>\n\n\n\n<p>Create config\/initializer\/cors.rb file.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo vim config\/initializers\/cors.rb<\/code><\/pre><\/div>\n\n\n\n<p>Define the following:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>Rails.application.config.middleware.insert_before 0, Rack::Cors do\n  allow do\n    origins &#39;*&#39;\n    resource &#39;*&#39;, headers: :any, methods: [:get, :post, :patch, :put, :options]\n  end\nend<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Support HTTPS<\/h2>\n\n\n\n<p>Reference: <a rel=\"noreferrer noopener\" href=\"https:\/\/puma.io\/puma\/#binding-tcp-sockets\" target=\"_blank\">Puma: A Ruby Web Server Built For Parallelism | Binding TCP Socket<\/a><\/p>\n\n\n\n<p>Support HTTPS using a self-signed certificate. If you have a CA-signed certificate, you can use it as well.<\/p>\n\n\n\n<p>Create a private key and a certificate signing request.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd ~\nopenssl genrsa -out private.key 2048\nopenssl req -new -key private.key -out request.csr<\/code><\/pre><\/div>\n\n\n\n<p>Generate a certificate.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>openssl x509 -in request.csr -out certificate.crt -req -signkey private.key -days 365<\/code><\/pre><\/div>\n\n\n\n<p>Start the Web server.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd \/opt\/redmine\nbundle exec puma -b &#39;ssl:\/\/0.0.0.0:9393?key=\/home\/redmine\/private.key&cert=\/home\/redmine\/certificate.crt&#39; -e production<\/code><\/pre><\/div>\n\n\n\n<p>Access the Redmine server in a Web browser.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>https:\/\/&lt;Redmine Server Address&gt;:9393<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Start as Ubuntu Service<\/h2>\n\n\n\n<p>Register the Redmine server as an Ubuntu service and start it at OS boot up.<\/p>\n\n\n\n<p>Create a shell file to start the Redmine server.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>cd ~\nvim start_redmine.sh<\/code><\/pre><\/div>\n\n\n\n<p>Write the following:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"start_redmine.sh\"><code>#!\/bin\/sh\n\ncd \/opt\/redmine\n\/home\/redmine\/.rbenv\/shims\/bundle exec puma -e production<\/code><\/pre><\/div>\n\n\n\n<p>Modify to executable.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>chmod +x start_redmine.sh<\/code><\/pre><\/div>\n\n\n\n<p>Create a service definition file.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo vim \/lib\/systemd\/system\/redmine.service<\/code><\/pre><\/div>\n\n\n\n<p>Write the following:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"redmine.service\"><code>[Unit]\nDescription=Start Redmine Server\nAfter=network.target\n\n[Service]\nType=simple\nExecStart=\/home\/redmine\/start_redmine.sh\nRestart=always\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre><\/div>\n\n\n\n<p>Register the service.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo systemctl enable redmine<\/code><\/pre><\/div>\n\n\n\n<p>Start the service.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>sudo systemctl start redmine<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Commands for Service<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start: sudo systemctl start redmine<\/li>\n\n\n\n<li>Stop: sudo systemctl stop redmine<\/li>\n\n\n\n<li>Restart: sudo systemctl restart redmine<\/li>\n\n\n\n<li>View Latest Logs: sudo journalctl -unit=redmine -e<\/li>\n\n\n\n<li>Watch Log: sudo journalctl -unit=redmine -f<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In this article, I will explain how to install Redmine 4.2\/5.0 with Ruby 2.7 on Ubuntu step-by-step. You can easily follow the process in a copy-and-paste manner. If you are looking for the installation procedure for Redmine 5.0 and Ruby 3.1, please refer to the following article: Step-by-Step: Install Redmine 5.0 with Ruby 3.1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4636,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"wf_post_folders":[13],"class_list":["post-4405","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-redmine"],"_links":{"self":[{"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/posts\/4405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/comments?post=4405"}],"version-history":[{"count":11,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/posts\/4405\/revisions"}],"predecessor-version":[{"id":5076,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/posts\/4405\/revisions\/5076"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/media\/4636"}],"wp:attachment":[{"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/media?parent=4405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/categories?post=4405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/tags?post=4405"},{"taxonomy":"wf_post_folders","embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/wf_post_folders?post=4405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}