Redmine 2.5.1 安裝文檔

1.gcc編譯環境mysql

$: yum -y install gcc

2.安裝依賴組件linux

$: yum install flex autoconf zlib curl zlib-devel curl-devel bzip2  bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel gcc+ gcc-c++ libxml2 libxml2-devel libxslt libxslt-devel

3.安裝libyaml-0.1.4c++

咱們選擇安裝在/usr/local/src目錄下web

$: cd /usr/local/src
$: wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$: tar xzvf yaml-0.1.4.tar.gz
$: cd yaml-0.1.4
$: ./configure --prefix=/usr/local
$: make
$: make install

4.安裝libyaml-develsql

本文安裝在64位Linux系統上,故選擇64位系統安裝源數據庫

// 64位系統
$: su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'

// 32位系統(32位系統選擇此源安裝)
$: su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'

安裝libyaml-develvim

$: yum install libyaml-devel

5.安裝MySql瀏覽器

本文mysql沒有指定安裝目錄,默認安裝在/var/lib/mysql安全

$: yum install mysql mysql-server mysql-devel
$: ls /etc/rc.d/init.d/mysqld -l
$: chkconfig --add mysqld
$: chkconfig mysqld on  # 設置mysql開機啓動
$: chmod 755 /etc/rc.d/init.d/mysqld  # 修改mysql執行權限
// 啓動mysql
$:service mysqld start
// 修改mysql密碼
$: mysqladmin -uroot password '123456' # 123456爲新設置的密碼
// 命令行登陸
$: mysql -uroot -p
Password 123456   # 輸入剛新設置的密碼
// 進行相關數據庫配置
mysql > create database redmine character set utf8;
mysql > create user 'redmine'@'localhost' identified by 'redmine';
mysql > grant all privileges on redmine.* to 'redmine'@'localhost';
mysql > FLUSH PRIVILEGES;
mysql > exit;  # 退出mysql

6.安裝Ruby 1.9.3ruby

咱們選在安裝在/usr/local/src目錄下咱們選在安裝在/usr/local/src目錄下

$: cd /usr/local/src
$: wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p547.tar.gz
$: tar zxvf ruby-1.9.3-p547.tar.gz
$: cd ruby-1.9.3-p547
$: ./configure --prefix=/usr/local/ruby --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
$: make
$: make install

Ruby環境變量配置

$: vi /etc/profile
// 在文件末尾添加以下內容
RUBY_HOME=/usr/local/ruby
PATH=$PATH:$RUBY_HOME/bin
export RUBY_HOME PATH

//保存退出,操做:ESC -> :wq
$: source /etc/profile  # 更新環境變量配置

測試ruby

$: ruby -v
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-linux]

$: gem -v
1.8.23.2

ROOT環境變量操做

$: alternatives --install /usr/bin/ruby ruby /usr/local/ruby/bin/ruby 300
$: alternatives --install /usr/bin/gem gem /usr/local/ruby/bin/gem 300

7.安裝Rails

$: gem install rails -v "3.2.17" -V  # 安裝指定的版本

8.安裝Bundler

$: gem install bundler -V
$: alternatives --install /usr/bin/bundle bundle /usr/local/ruby/bin/bundle 300

9.安裝Redmine、

9.1 準備工做

$: yum install ImageMagick-devel

9.2 咱們選擇安裝在/usr/local/src目錄下

$: cd /usr/local/src
$: wget http://www.redmine.org/releases/redmine-2.5.1.tar.gz
$: tar zxvf redmine-2.5.1.tar.gz
$: mv redmine-2.5.1 redmine

9.3 更改安裝路徑

$: mkdir /data
$: cd /data
$: mkdir www
$: cd /usr/local/src
$: mv /usr/local/src/redmine /data/www

9.4 修改配置文件

$: cd /data/www/redmine/config
// 修改配置信息文件
$: cp database.yml.example database.yml
// 進入修改
$: vim database.yml
// 修改內容以下
production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "redmine"
  encoding: utf8
development:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "redmine"
  encoding: utf8

$: cd /data/www/redmine
$: vi Gemfile
// 修改內容以下
# gem "rmagick", ">= 2.0.0"  // 註釋掉這行,添加下面這行
  gem "rmagick", :require => "RMagick"

9.5 安裝Redmine的ruby組件

首先,咱們須要除root之外的一位用戶,如user1 建立user1

$: useradd -d /usr/user1 -g users -m user1
$: passwd user1
# 設置user1新密碼

// 爲user1添加sudo權限,該步驟在root用戶下操做
$: chmod u+w /etc/sudoers # 添加sudo文件的寫權限
$: vi /etc/sudoers
// 找到這行 root ALL=(ALL) ALL,在他下面添加:
user1    ALL=(ALL)       ALL
$: chmod u-w /etc/sudoers # 撤銷sudoers文件寫權限

由於redmine在執行bunder install時是不能使用root權限來執行的,故咱們更改權限給其餘帳戶,如user1,咱們更改redmine根目錄權限給user1

$: cd /data/www
$: sudo chown -R user1:users redmine

進入redmine根目錄,bundle執行注意不要使用root權限執行,在user1權限下執行

$: cd /data/www/redmine 
$: su user1
$: bundle install

安裝完畢如圖:

輸入圖片說明

9.6 生成安全Token,此時可切回root用戶

$: su root
$: bundle exec rake generate_secret_token

9.7 生成數據表,導入初始化數據

$: cd /data/www/redmine/config
$: RAILS_ENV=production bundle exec rake generate_secret_token
$: RAILS_ENV=production bundle exec rake db:migrate
$: RAILS_ENV=production bundle exec rake redmine:load_default_data
// 這一步會讓你選擇 language,咱們選擇 zh 便可

9.8 激活FCGI4

$: cd /data/www/redmine/public
$: cp dispatch.fcgi.example dispatch.fcgi
$: cp htaccess.fcgi.example .htaccess
$: yum install epel-release
$: yum install mod_fcgid

9.9 Redmine配置

$: cd /data/www/redmine/config
$: cp configuration.yml.example configuration.yml
$: vi configuration.yml
// 修改內容以下
attachments_storage_path: /data/www/redmine/files  # 冒號後面有個空格,不能漏

正式啓動前關閉防火牆:

$: service iptables stop # 重啓後失效
$: chkconfig iptables off # 禁用防火牆

10.啓動Rdemine

$: cd /data/www/redmine
$: nohup bundle exec rails server webrick -p3000 -b 0.0.0.0 -e production >/dev/null 2>&1 &

若啓動失敗,能夠執行以下代碼查看報錯,沒有報錯Ctrl + C 退出便可

$: bundle exec rails server webrick -e production

11.打開瀏覽器登陸

瀏覽器地址爲安裝的主機IP:3000,如192.168.1.120:3000 默認帳戶名:admin,默認密碼:admin

注意:在點擊頁面上的「幫助」時,頁面會跳轉到http://www.redmine.org/guide,此時登陸帳號時,IP爲http://www.redmine.org/login,帳號登陸不了,咱們必須將IP地址修改成http://192.168.1.120:3000/login,才能登陸帳號!

12.Redmine後臺修改密碼

$: cd /data/www/redmine/script
$: ./rails console production
// 進入ruby環境
ruby > admin_user = User.find_by_login('admin')
ruby > admin_user.password = 'password' # 登陸密碼修改成 password
ruby > admin_user.save!
ruby > quit

常見錯誤解決方案:

報錯1:

運行bundle install時可能會遇到"Could not load OpenSSL."

解決方案:

$: yum install openssl openssl-devel
$: cd /usr/local/src/ruby-1.9.3-p547/ext/openssl
$: ruby extconf.rb
$: make && make install

報錯2: 運行bundle install時可能會遇到

"Gem::InstallError: nokogiri requires Ruby version >= 2.1.0. An error occurred while installing nokogiri (1.8.1), and Bundler cannot continue. Make sure that gem install nokogiri -v '1.8.1' succeeds before bundling."

解決方案:

$: cd /data/www/redmine
$: vi Gemfile
// 修改內容以下
# gem "rmagick", :require => "RMagick"  // 註釋掉這行,修改成下面這行
  gem "rmagick", ">= 2.0.0"

報錯3:

運行RAILS_ENV=production bundle exec rake db:migrate時可能會遇到

"Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"

解決方案:

$: ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
相關文章
相關標籤/搜索