My linux world » srv-redmine

srv-redmine


Prerequiste

I assume that you have a Centos installation.

Installation

You can copy/paste this script and use it to configure automatically your server.

  1. #!/bin/bash
  2.  
  3. ##################################################
  4. # PARAMETERS
  5. ##################################################
  6.  
  7. redmine_install_url=http://www.redmine.org/releases/redmine-3.4.2.tar.gz
  8. redmine_version=redmine-3.4.2
  9. ruby_version=2.4.1
  10.  
  11. ##################################################
  12. # INSTALLATION SCRIPT
  13. ##################################################
  14. echo "create database redmine, user/password redmine/redmine":
  15. mysql --user=root --password=root -e "CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine';"
  16. mysql --user=root --password=root -e "CREATE DATABASE IF NOT EXISTS redmine;"
  17. mysql --user=root --password=root -e "use redmine; GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost' WITH GRANT OPTION;"
  18.  
  19. echo "1 - install rvm (Ruby Version Manager)"
  20. dnf -y install curl
  21. gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
  22. curl -sSL https://get.rvm.io | bash -s stable
  23.  
  24. source ~/.bash_profile
  25. source /etc/profile.d/rvm.sh
  26. rvm get stable --auto-dotfiles
  27. rvm requirements
  28.  
  29. echo "2- install ruby"
  30. rvm install $ruby_version
  31. rvm use $ruby_version --default
  32.  
  33. echo "3- install rubygem"
  34. rvm rubygems current
  35.  
  36. echo "install bundle and nokogiri"
  37. gem install bundle --no-rdoc --no-ri
  38.  
  39. #dnf -y install libxml2-devel libxslt-devel
  40. #gem install nokogiri -v '1.5.10' --no-rdoc --no-ri
  41.  
  42. echo "install passenger"
  43. dnf -y install curl-devel httpd-devel
  44. gem install passenger --no-rdoc --no-ri
  45. passenger-install-apache2-module -a
  46.  
  47. echo "get redmine"
  48. mkdir -p /opt/redmine/download
  49. cd /opt/redmine/download
  50. wget $redmine_install_url # GET LATEST VERSION ON RUBYFORGE
  51. tar xvfz $redmine_version.tar.gz
  52. mv $redmine_version ../redmine
  53.  
  54. echo "configure database"
  55. cd /opt/redmine/redmine/config
  56. cp database.yml.example database.yml
  57. sed -i "s/username: root/username: redmine/g" /opt/redmine/redmine/config/database.yml
  58. sed -i "s/password: \"\"/password: redmine/g" /opt/redmine/redmine/config/database.yml
  59.  
  60. echo "install redmine"
  61. dnf -y install mariadb-devel ImageMagick-devel freetds-devel
  62. cd /opt/redmine/redmine
  63. bundle install
  64.  
  65. echo "now populate database"
  66. cd /opt/redmine/redmine
  67. rake generate_secret_token
  68. rake db:migrate RAILS_ENV="production"
  69. rake redmine:load_default_data RAILS_ENV="production" REDMINE_LANG="en"
  70.  
  71. echo "set chmod on tmp directory"
  72. chmod 777 /opt/redmine/redmine/tmp/ -R
  73.  
  74.  
  75. ##################################################
  76. # CONFIGURATION APACHE HTTPD
  77. ##################################################
  78. # NOTE REDMINE MUST BE STARTED "NORMALLY" BEFORE THIS STEP.
  79.  
  80. cat > /etc/httpd/conf.d/redmine.conf << EOF
  81. LoadModule passenger_module /usr/local/rvm/gems/ruby-$ruby_version/gems/passenger-5.1.6/buildout/apache2/mod_passenger.so
  82. PassengerRoot /usr/local/rvm/gems/ruby-$ruby_version/gems/passenger-5.1.6
  83. PassengerRuby /usr/local/rvm/wrappers/ruby-$ruby_version/ruby
  84.  
  85.  
  86. <VirtualHost *>
  87.   ServerName YOUR_SERVER
  88.   DocumentRoot /var/www/html
  89.   RailsEnv production
  90.   RailsBaseURI /redmine
  91.   PassengerDefaultUser apache
  92.  
  93.   ErrorLog "|/usr/sbin/rotatelogs /etc/httpd/logs/redmine-error.%Y-%m-%d.log 86400"
  94.   CustomLog "|/usr/sbin/rotatelogs /etc/httpd/logs/redmine-access.%Y-%m-%d.log 86400" "%h %l %u %t %D \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
  95.  
  96. </VirtualHost>
  97. EOF
  98. ln -s /opt/redmine/redmine/public /var/www/html/redmine
  99.  
  100. echo "restart httpd service"
  101. systemctl restart httpd.service
  102.  
  103. myip=`hostname -I`
  104. echo "Now meet you here: http://$myip"
  105.  

That’s all 🙂


Copyright © 2023 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.

Fork me on GitHub