Search This Blog

Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Thursday, May 3, 2018

Redmine 3.45 install Debian 9 stretch with SystemD

Please notice this is a quick and slim example only for non-multi user environment.

It fits my need very well.

Can hold up to 50 Clients at same time.

I am using SQLite as database because I love it.

apt-get install curl dirmngr
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

source /etc/profile.d/rvm.sh
rvm requirements

rvm install 2.4

rvm use 2.4 --default
ruby -v

echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

gem install bundler --no-ri --no-rdoc
gem install sqlite3 --no-ri --no-rdoc


cd /var/www/redmine/
cp config/database.yml.example config/database.yml

My config/database.yml:
production:
  adapter: sqlite3
  database: db/redmine.sqlite3

Start install:
bundle install --without development test rmagick
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data

Testing it out:
bundle exec rails server webrick -e production -b 192.168.1.33 -p 80

Run as systemd service: add file

/etc/systemd/system/redmine.service
[Unit]
Description=Redmine server
After=syslog.target
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/bin/bash -c 'source /etc/profile.d/rvm.sh && cd /var/www/redmine && bundle exec rails server webrick -e production -b 192.168.1.33 -p 80'

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

To start it:
systemctl enable redmine.service
systemctl start redmine.service

What to improve:

  1. I run it as [root] user it may not super safe, but this is just for internal use.

  2. Redmine Log rotation, please reference my old post: Redmine Log rotation

Monday, September 30, 2013

Upgrade Redmine from 2.0.3 to 2.3.3, ruby 1.9.1 to 2.0

1.First backup everything:

1.1 backup database
1.2 backup redmine folder
1.3 backup /usr/local/ if you installed ruby manually.


2.Stop httpd service:

service httpd stop


3.Upgrade Rails version to 3.2.13

4.Remove ruby 1.9.1

rm -rf /usr/local/lib/ruby/1.9.1/
rm -rf /usr/local/lib/ruby/gems/1.9.1/
rm -rf /usr/local/include/ruby-1.9.1/


5.Install ruby 2.0

wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xzvf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247
./configure
make
make install
ruby -v
which ruby


6.Copy redmine config file to New stable 2.3.3


wget http://rubyforge.org/frs/download.php/77138/redmine-2.3.3.tar.gz
tar -xzvf redmine-2.3.3.tar.gz

cp /var/lib/redmine/config/database.yml ./config/database.yml
cp /var/lib/redmine/config/configuration.yml.example ./config/configuration.yml
cp /var/lib/redmine/files/* ./files/
rm ./files/delete.me


7.Copy plugins (version >= 2.0)

cp -r /var/lib/redmine/plugins/ ./plugins/


8.Re-compile passenger:

gem install passenger --no-rdoc --no-ri
passenger-install-apache2-module


9.Configure Apache mode: /etc/httpd/conf.d/passenger.conf

# Passenger Basic Setting
#
LoadModule passenger_module /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.19/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.19
PassengerDefaultRuby /usr/local/bin/ruby


10.Re-check redmine for Apache: /etc/httpd/conf.d/redmine.conf


ServerName localhost
DocumentRoot "/var/www/redmine-2.3.3/public/"

# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews

ErrorLog logs/redmine-error_log
CustomLog logs/redmine-access_log common



11.clear the cache and the existing sessions:

rake tmp:cache:clear
rake tmp:sessions:clear


12.ReStart httpd service:

service httpd start


13.Check the error log

cat /var/log/httpd/redmine-error_log


14.Check daily backup tasks