redmine安裝需要首先需要查看對ruby的版本依賴,每個版本安裝的軟件都需要對應的版本,如果選錯了,就會導致后面的安裝失敗。
各個版本之間的依賴可以到https://rubygems.org/gems/mysql2/versions該網址下查看
1、首先安裝必要的依賴包:
[root@localhost ~]# yum -y install patch make gcc gcc-c++ gcc-g77 flex* bison file
[root@localhost ~]# yum -y install libtool libtool-libs autoconf kernel-devel
[root@localhost ~]# yum -y install libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel
[root@localhost ~]# yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
[root@localhost ~]# yum -y install glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel
[root@localhost ~]# yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs
[root@localhost ~]# yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
[root@localhost ~]# yum -y install openssl openssl-devel vim-minimal nano sendmail
[root@localhost ~]# yum -y install fonts-chinese gettext gettext-devel
[root@localhost ~]# yum -y install ncurses-devel
[root@localhost ~]# yum -y install gmp-devel pspell-devel
[root@localhost ~]# yum -y install unzip
[root@localhost ~]# yum -y install automake libmcrypt* libtool-ltdl-devel*
[root@localhost ~]# yum -y install readline* libxslt* pcre* net-snmp* gmp* libtidy*
[root@localhost ~]# yum -y install ImageMagick* svnversion*
2、安裝rvm以及需要的軟件
(Ruby version manager) 顧名思義,就是安裝ruby的包版本管理
由於國內無法直接訪問外網,所以需要修改下配置才能正常安裝,首先執行下面第一條命令,會提示443,無法訪問的錯誤,這時候就要修改/etc/hosts值了
[root@localhost ~]# bash < <( curl -L https://get.rvm.io ) #第(1)步 [root@localhost ~]# source /etc/profile.d/rvm.sh #第(2)步
會提示443,無法訪問的錯誤,這時候就要修改/etc/host文件,首先打開/etc/hosts (有s不能丟),將199.232.28.133 raw.githubusercontent.com粘貼到打開的文件下面,保存,退出。
[root@localhost ~]# vi /etc/hosts
之后再執行 source /etc/profile.d/rvm.sh 上面的第(2)步,應用一下。
到這里,就把rvm 安裝完成了。使用rvm -v查看一下版本,沒有問題就進行下一步。
[root@localhost ~]# rvm -v
接下來就要安裝ruby版本了,我這里選的是2.5.8,版本依賴參考 https://rubygems.org/gems/mysql2/versions
[root@localhost ~]# rvm list #可以查看當前的ruby
[root@localhost ~]# rvm install 2.5.8
#擴展小知識
1. rvm list //查看當前安裝的ruby版本
2. rvm install 2.5.8 //安裝1.9.2的ruby版本
3. ruby -version //查看當前版本
4. rvm use 1.9.2 --default //修改指定特定的ruby版本
5. rvm list known //查詢已知版本
這里安裝的時候會比較慢,下載,安裝,編譯,一樣都少不了,需要耐心等待哦!
ruby安裝結束后來安裝rails,我這里選的是 5.2.2版本
[root@localhost ~]# gem install rails -v 5.2.2 -V #后面的-V是為了回顯,不然都不知道它有沒有在干活
#擴展知識
安裝特定的 rails版本
1. gem list --local rails //查看所有已經安裝的rails版本
2. rails --version //查看當前rails的版本
3. gem install rails --version 3.0.5 //安裝3.0.5 版本的rails
rails安裝成功后安裝rake版本,我選的是10.5.0,但是好像沒啥用,后面bundle install的時候會覆蓋掉
[root@localhost ~]# gem install rake -v 10.5.0 -V
安裝mysql2,我選的是0.5.0版本
[root@localhost ~]# gem install mysql2 -v 0.5.0
#安裝這個的時候會提示沒有安裝客戶端
如果遇到該問題,執行如下語句
[root@localhost ~]# yum install mysql-devel
3、安裝redmine
下面打開要安裝的路徑,我這里安裝到/opt路徑下
[root@localhost ~]# cd /opt/
[root@localhost opt]# yum -y install subversion -v 1.7.14 #沒有安裝svn的要先裝下
[root@localhost opt]# svn co http://svn.redmine.org/redmine/branches/3.3-stable redmine
4、運行bundle install 補全缺失的包以及版本不對的包
[root@localhost redmine]# cd /redmine
[root@localhost redmine]# bundle install #如果按照正常的步驟,這里是一路飄綠,看着很爽.如果版本沖突,一路飄紅,看着很難受
5、配置mysql2數據庫
5.1 重命令名
[root@localhost redmine]# cd config/
[root@localhost ~]# mv database.yml.example database.yml #重命名數據庫連接配置
[root@localhost ~]# mv configuration.yml.example configuration.yml #重命名redmine配置
5.2修改數據庫配置
[root@localhost config]# vim database.yml production: adapter: mysql2 database: redmine #數據庫名稱redmine host: 127.0.0.1 #數據庫ip地址 username: root password: "******" #這個是mysql數據庫密碼,你需要自己裝,如果有更好,只需要創建一個數據庫redmine encoding: utf8
6、初始化redmin[root@localhost config]# cd ..
[root@localhost redmine]# rake config/initializers/secret_token.rb
[root@localhost redmine]# rake db:migrate RAILS_ENV="production"
#如果數據庫沒有配置或者丟失文件manifest.js都會報錯,如果市文件丟失,定位到要求的文件下面新建一個就可以了
提示無法連接到127.0.0.1時,需要去配置mysql數據庫,請參考 《mysql數據庫配置》
7、如果一切都配置好了,就可以啟動redmine了
[root@localhost redmine]# ./bin/rails server -p3000 -b127.0.0.1 -e production #阻塞運行,ctrl+c停止
[root@localhost redmine]# ./bin/rails server -p3000 -b0.0.0.0 -e production -d #后台運行
[root@localhost redmine]# ps -ef | grep rails #查看開始的進程
8、登錄
初始賬號密碼是admin/admin,首次登陸后需要修改密碼
9、配置郵箱
root@localhost ~]# ps auxf | grep sendmail 如果沒有啟動,啟動下 [root@localhost ~]# service sendmail start 如果沒有安裝安裝下 [root@localhost ~]# yum -y install sendmail [root@localhost ~]# mail -s "mail from baoguo" baoguo.ding@roadshare.com < mail.txt # 如果報
-bash: mail: command not found [root@localhost ~]# yum -y install mailx 如果還報錯,查看執行如下命令 [root@localhost ~]# tail /var/log/maillog [root@localhost ~]# vim /opt/redmine/config/configuration.yml default: # Outgoing emails configuration # See the examples below and the Rails guide for more configuration options: # http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration email_delivery: # ==== Simple SMTP server at localhost # # email_delivery: # delivery_method: :smtp # smtp_settings: # address: "localhost" # port: 25 # # ==== SMTP server at example.com using LOGIN authentication and checking HELO for foo.com # # email_delivery: delivery_method: :smtp smtp_settings: address: "******" port: 25 authentication: :login domain: '*******' user_name: 'xxxx@qq.com' password: 'qq授權碼' #
如果設置郵件,需要把郵件的smtp打開,尤其是qq的需要找到對應的地方打開,並且密碼填寫的那個授權碼。
設置完成后,重新啟動,安裝完成。
這里有幾個踩的坑:
1、redmine高版本的數據庫有字段修改的情況,這里如果是數據遷移的話,最好同版本修改,高版本的可以從零開始,否則建議找到好的遷移方式再遷移。
2、在使用高版本的rails時,會出現語法升級的情況,遇到這種情況不要慌,到log文件下查看日志,然后到github上找源碼,對照着修改對應的文件就可以了。
3、修改文件到掛載盤需要到配置/opt/redmin/config/configuration.yml中去配置掛載的路徑attachment_**,然后再重新啟動就可以了。