{"id":198,"date":"2015-12-11T14:51:25","date_gmt":"2015-12-11T22:51:25","guid":{"rendered":"http:\/\/www.infosynergetics.com\/?p=198"},"modified":"2018-05-10T13:10:43","modified_gmt":"2018-05-10T20:10:43","slug":"installing-redmine-3-on-an-existing-ubuntu-lamp-server","status":"publish","type":"post","link":"https:\/\/www.infosynergetics.com\/?p=198","title":{"rendered":"Installing Redmine 3 on an Existing Ubuntu LAMP server"},"content":{"rendered":"<p>Note: \u00a0This has been updated from its original post in 2015.<\/p>\n<p>I will be upgrading some Ubuntu 12 servers in the near future and will be deploying Redmine 3 (upgrading from 2.2). \u00a0In order to prepare for that, and because I needed a Redmine instance for a project I will be undertaking (an store management app to integrate with Square), I decided to do a full deploy of Redmine to an Ubuntu 14 server I had setup to use in a course I was teaching at UCSD. \u00a0It had Apache, MySQL and PHP installed to support a BPM solution, so I would need to add RoR support to the server, and get Redmine running. \u00a0Although this wouldn&#8217;t be fully parallel to what I will be doing in a couple of weeks, it would serve as a refresher for me, and alert me to things I need to be aware of. \u00a0I was mostly able to follow the Redmine <a href=\"http:\/\/www.redmine.org\/projects\/redmine\/wiki\/redmineinstall\">install<\/a> documents, but there were a few exceptions that I wanted to document, as well as some additional pieces that the Redmine docs don&#8217;t really address.<\/p>\n<p>The first step is to get Passenger <a href=\"https:\/\/www.phusionpassenger.com\/library\/install\/apache\/\">running<\/a>. \u00a0The instructions are simple and straightforward, and this installation worked just fine. \u00a0Once installed, you need to install Redmine. \u00a0The first question is about Ruby in your environment. \u00a0I attempted to use RBEnv as that seems to be growing in popularity. \u00a0After hitting a number of snags, I opted to uninstall RBEnv and switch back to RVM which I&#8217;ve had success with. \u00a0I suspect that had I wanted to try for a bit longer, I could have ironed out the RBEnv issues, but I decided to move on. \u00a0Basically what was happening was that I had first installed it in my home account, then realized that this would be problematic and located instructions for doing a multiuser install, as I want to run my app under a service account, not as my user. \u00a0I should point out that I did all of this work with a &#8220;standard&#8221; user account that was also in the sudoers list. \u00a0I believe that I will be able to effectively manage the upgrades over time with this approach.<\/p>\n<p>I followed the multiuser RVM installation instructions located <a href=\"https:\/\/rvm.io\/rvm\/install\">here<\/a>. \u00a0Again, this is straightforward, just follow the instructions and make sure you are working in the multiuser part. \u00a0After completing the install, create a Redmine user (this is after the whole Redmine install is completed) to act as a service account, and grant it the appropriate permissions. \u00a0The account can be locked and will work just fine, so people cannot attempt to log on to your system if they guess the service account name. \u00a0Once RVM is installed, you can install whatever Ruby you wish (or rubies). \u00a0I installed 2.2.3, then made it the system default (RVM use 2.2.3 &#8211;default). \u00a0I give the redmine user ownership of the files, tmp and log directories recursively as that user needs to write to those directories.<\/p>\n<p>Once that is complete, create a database for Redmine and select a user for this. \u00a0As a matter of safety, I create a specific user to access the database, and limit connections to localhost only, for the Redmine user only. \u00a0If you have PHPMyAdmin running this is a simple enough task. \u00a0In general, and MySQL defaults to this, you shouldn&#8217;t be directly connecting to it from another machine. \u00a0If such a thing is necessary, you should do it on an IP by IP basis, so that you are allowing just a specific IP. \u00a0I have an implementation at a client where there is an integration between MySQL and another tool that requires a direct external connection for read only. \u00a0I created a read only user, and allow it to authenticate only from that one IP address.<\/p>\n<p>Install both SVN and ImageMagick. \u00a0The OpenID libraries are dependent on whether you want OpenID. \u00a0ImageMagick is optional as well, but the default with Redmine is to use RMagick to handle images, and it will not install without ImageMagick. \u00a0You&#8217;ll want images, so just go for it. \u00a0There is one thing that won&#8217;t install with the RMagick gem, if you just install ImageMagick (sudo apt-get install imagemagick). \u00a0You will also need to install a dev library by using sudo apt-get install libmagickwand-dev.<\/p>\n<p>At this point, you will want to install the MySQL libraries and drivers so that the MySQL2 gem will install correctly. \u00a0Run the following.<\/p>\n<blockquote><p>sudo apt-get install ruby-mysql \u00a0libmysqlclient-dev (the old libmysql-ruby was a transitional package).<\/p><\/blockquote>\n<p>At this point <a href=\"http:\/\/www.redmine.org\/projects\/redmine\/wiki\/Download\">download<\/a> Redmine. \u00a0I used SVN and downloaded it to a directory in usr\/local. \u00a0Then I created a symlink to the directory in \/var\/www. \u00a0From here, configure the database.yml file as directed in the installation directions, then install bundler (gem install bundler) then install the required gems using bundle install &#8211;without development test (you can exclude rmagick at this point, as well, if you aren&#8217;t going to use it).<\/p>\n<p>Next, create the application secret by executing, from within the Redmine directory (also applies to any app) rake secret. \u00a0This generates a secret key and then captures it in an environment variable. \u00a0Rails 4 requires\u00a0that you create a config\/secrets.yml file and place the following two lines, in lieu of using the config\/initializers\/secret_token.rb file:<\/p>\n<blockquote><p>production:<\/p>\n<p>secret_key_base: &#8216;secret generated above&#8217;<\/p><\/blockquote>\n<p>A key configuration item, as it turns out is:<\/p>\n<p>PassengerResolveSymlinksInDocumentRoot on<\/p>\n<p>Without this, you will simply receive a list of items in the public folder. \u00a0This appears to be Rails related as I have an older version of Redmine running the same version of Passenger, but on Rails 3 that doesn&#8217;t require this directive. \u00a0Redmine 3, using Rails 4+ appears to have this requirement.<\/p>\n<p>This secures your application by not placing your secret key in any of the application files (it exists only at the OS level). \u00a0Alternatively you can set secret_key_base:\u00a0&lt;%= ENV[&#8220;SECRET_KEY_BASE&#8221;] %&gt; and load it from the profile of the redmine user (assuming that this is the user which will be running the application).<\/p>\n<p>Finish by creating the database schema, default data set, and setting the file permissions as indicated.<\/p>\n<p>The last step is to let Apache know about the new application. \u00a0In general, I prefer, like many, to create a redmine.conf file in the \/etc\/apache2\/sites-available directory. \u00a0Within it, create the appropriate virtual host entry pointing to the public directory inside of the redline application (e.g. \/var\/www\/redmine\/public) for both the document root and the directory. \u00a0You may want to specify the following lines to ensure that Passenger runs correctly, but in my experience they are not entirely necessary:<\/p>\n<blockquote><p>PassengerRuby (path to ruby, see below)<\/p>\n<p>PassengerDefaultUser &lt;service account created earlier&gt;<\/p><\/blockquote>\n<p>If you are upgrading from an older Ubuntu version, vs. performing a clean install, make sure that you don&#8217;t have any passenger configuration items\u00a0in your apache2.conf file (typically in\u00a0\/etc\/apache2\/). \u00a0The passenger binary itself should be loaded as a module in Apache, and the PassengerRuby and Default user, although they can be defined in the apache2.conf should probably be specified within the virtual host definition. \u00a0It wouldn&#8217;t hurt to keep things in the apache2.conf file, but by keeping it in the sites definition, the option exists to run different rails apps using different rubies and users. \u00a0If, as I have had in the past, you have a legacy app, you can run it under a legacy ruby at the same time a newer app is running on the latest ruby.<\/p>\n<p>To determine the path to ruby, run the following command: \u00a0passenger-config about ruby-command, then copy the path to the redmine.conf file as indicated.<\/p>\n<p>Enable the redmine site (a2ensite redmine), restart apache, and all should work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Note: \u00a0This has been updated from its original post in 2015. I will be upgrading some Ubuntu 12 servers in the near future and will be deploying Redmine 3 (upgrading from 2.2). \u00a0In order to prepare for that, and because I needed a Redmine instance for a project I will be undertaking (an store management [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=\/wp\/v2\/posts\/198"}],"collection":[{"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=198"}],"version-history":[{"count":14,"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":229,"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions\/229"}],"wp:attachment":[{"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infosynergetics.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}