Centos6.5+Redmine

花了兩天時間,基於centos6.5操做系統,搭建了redmine環境,在這裏記錄下過程當中遇到的問題以及搭建流程。php

centos6.5;html

redmine2.5.0;mysql

Ruby1.9.3;linux

 

step 1:安裝相關軟件環境依賴

yum -y install zip unzip libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA

step 2:安裝apache和mysql

yum -y install httpd mysql mysql-server

step 3:將apache和mysql配置爲開機自啓動,並在當下啓動apache和mysql,以便作餘下的配置

chkconfig httpd on
chkconfig mysqld on

service httpd start
service mysqld start

step 4:配置mysql 帳號密碼信息,使用mysql_secure_installation來配置,也是一個簡單的交互式配置工具

Because we not have a password for the root account so you press Enter to skip.
Enter current password for root (enter for none):      
#輸入當前mysql的root密碼,由於yum套件關係,root密碼爲空,直接回車便可
Select Yes to set the password for the MySQL root account.  
#是否設置新的mysql root密碼,選是
Set root password? [Y/n] y
Enter and confirm your password, remove the anonymous user, select Yes
Remove anonymous users? [Y/n] y   
#是否移除匿名用戶,安全起見,選是
Allow remote login to MySQL as root account, select No.
Disallow root login remotely? [Y/n] n 
#是否關閉root遠程登陸,看你如何選擇了,官網說否,若是不是外網服務器的話,開放也無所謂。
Delete the test database, select Yes
Remove test database and access to it? [Y/n] y  
#移除測試數據庫
Reload privilege tables, select Yes  
#刷新權限配置信息
Reload privilege tables now? [Y/n] y

  

step 5: 關閉selinux

vi /etc/selinux/config
SELINUX=disabled

編輯保存退出後,輸入如下命令,不重啓系統關閉selinuxc++

setenforce 0

注:web

setenforce 1 設置SELinux 成爲enforcing模式sql

setenforce 0 設置SELinux 成爲permissive模式,即關閉selinux數據庫

step 6 :關閉iptables

service iptables stop

chkconfig iptables off

由於不是外網服務器用不到iptables作安全過濾。apache

step 7:安裝php環境

由於redmine是ruby開發,安裝php和phpmyadmin主要是爲了方便管理mysql數據庫vim

yum -y install php php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-soap

step 8:安裝ruby環境

\curl -L https://get.rvm.io | bash

運行成功會生成一個文件,而後運行如下命令

source /etc/profile.d/rvm.sh
rvm list known

2.6版本須要ruby 支持的版本,在這咱們選擇1.9.3 穩定版 

rvm install 1.9.3

注:這個ruby版本很考究的,目前安裝官網文檔,安裝redmine 2.5X的均可以用1.9.3

安裝完成後檢查ruby版本

ruby -v

返回顯示:ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux] ,說明安裝成功。

step 9:安裝rubygems

yum -y install rubygems

注:rubygems是Ruby’s packages management program 包管理程序,至關於yum 或者apt-get,全部ruby的東西由它來保(an)護(zhuang)

step 10:安裝Passenger

gem install passenger

passenger-install-apache2-module

注:

The full name of the Passenger is Phusion Passenger, known as mod_rails or mod_rack, it is a web application intergrate with Apache and it can operate as a standalone web server support for the Ruby On Rails applications.總的來講就是ruby和apache結合的代謝物,redmine的apache支持,這樣能夠經過apache訪問.

 

上述安裝完成後會提示:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.28/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.28
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>

注意是安裝完成的提示,複製出來而後使用,將複製的內容保存爲一個新的apache配置文件

vi /etc/httpd/conf.d/passenger.conf

粘貼內容後保存退出,重啓apache

service httpd restart

step 11: 建立redmine數據庫

mysql -u root -p
create database redmine_db character set utf8 ;    #建立數據庫
create user 'admin'@'localhost' identified by 'admin'; #建立用戶
grant all privileges on redmine_db.* to 'admin'@'localhost';  #受權
quit ;

step 12:安裝redmine

wget http://www.redmine.org/releases/redmine-2.5.0.tar.gz 
#下載最新版本,只要是2.5X範圍便可
tar xvfz redmine-2.5.0.tar.gz
mv redmine-2.5.0 redmine
rm -rf redmine-2.5.0.tar.gz

注:

教程是新建了一個文件夾來做爲存放目錄,我在這裏直接安裝到主目錄下,並更改文件名爲redmine.難怪按照教程的路徑去配置後面的文件會找不到...  

step 13:redmine相關配置

安裝完畢後,咱們須要在httpd的redmine.conf中進行修改: 

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

vi database.yml  #輸入mysql訪問信息,帳號,密碼,數據庫名字,使用第一個production配置,編輯完成後保存退出

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "redmine"
  encoding: utf8

注意:官網中說MySQL database using ruby 1.9 (adapter must be set to mysql2)

step 14:安裝rails

cd /var/www/redmine
gem install bundler
bundle install

注:

這一步驟,不少教程都在說因爲防火牆的緣由,不能直接安裝官網源。須要先作一步其餘配置,然而我人品好吧,沒有進行配置也成功了......

 

關於報錯,個人安裝過程只出現一個錯:

An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.

#執行gem install mysql2 -v '0.3.18'報錯:

checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing

#咱們執行yum install mysql-devel後成功安裝,接着再次bundle install 

其實仔細看提示,都會告訴你該執行什麼命令來解決問題。

安裝成功的提示:

Bundle complete! 21 Gemfile dependencies, 56 gems now installed.
------
Details here: http://www.elabs.se/blog/60-introducing-capybara-2-1

安裝完成後初始化數據庫,默認選擇便可。

rake generate_secret_token

#初始化redmine數據庫表名

RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

step 15:激活fcgi

cd redmine/public
mkdir plugin_assets
cp dispatch.fcgi.example dispatch.fcgi
cp htaccess.fcgi.example .htaccess

step 16: 安裝Apache and FastCGI模塊

rpm --import https://fedoraproject.org/static/0608B895.txt
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum -y install mod_fcgid
rm -rf epel-release-6-8.noarch.rpm

step 17:建立redmine的文件存儲目錄

mkdir -p /data/redmine-2.6.3/files   #因爲我本身把redmine安裝在主目錄下,執行這句命令時,提示我文件已存在...
cd redmine-2.6.3/config cp configuration.yml.example configuration.yml

因爲咱們的files目錄在redmine根目錄下,所以configuration不用配置了,若是files目錄在其餘地方,咱們須要 

vim configuration.yml
attachments_storage_path: /var/redmine/files

step 18:建立redmine虛擬主機

<VirtualHost *:80>
        ServerName your_domain                #我填的是所在服務器的IP地址
        ServerAdmin your_domain@domain.com    #沒有指定域名,因此我沒寫這句
        DocumentRoot /redmine/public/         # !!! Be sure to point DocumentRoot to 'public'!
        ErrorLog logs/redmine_error_log
        <Directory "/redmine/public/">
                Options Indexes ExecCGI FollowSymLinks
                Order allow,deny
                Allow from all       # This relaxes Apache security settings.
                AllowOverride all    # MultiViews must be turned off.
        </Directory>
</VirtualHost>

  

注:redmine目錄要正確,指定好對應的域名(若是有的話...)。  

step 19:受權apache權限到redmine目錄

以便apache能夠訪問redmine(先切到redmine安裝的目錄下,個人是根目錄,因此...)

chown -R apache:apache redmine
chmod -R 755 redmine

service httpd restart

 

測試試試看

binggo~

默認的用戶名和密碼都爲admin  

全部配置到此爲止(其實我沒有配置email...從此有空再說),主要參考文檔:
http://www.redmine.org/projects/redmine/wiki/Install_Redmine_25x_on_Centos_65_complete

http://www.tuicool.com/articles/UviYJr

http://www.linuxidc.com/Linux/2015-03/115545.htm

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息