【Redmine安装--CentOS篇】Redmine3.4.x (CentOS Linux release 7.5 , MySQL 5.6, Apache2 , Phusion Passenger)

Redmine管理工具

Tags: redmine 项目管理工具 团队管理工具 问题管理工具 centos下安装redmine

目录

  • 作者
  • 安装环境说明
  • 一.更新系统关键组件
  • 二.安装依赖项包
  • 三.安装Apache和Mysql
  • 四.关闭SELinux
  • 五.设置主机名
  • 六.配置防火墙
  • 七.安装PHP和phpMyAdmin
  • 八.安装ruby
  • 九.安装RubyGems
  • 十.安装Passenger
  • 十一.为Redmine创建数据库
  • 十二.安装Redmine
  • 十三.设置Rails
  • 十四.为Redmine创建虚拟主机
  • 十五.保存文件配置并退出

作者

水士白 WaterWrite

安装环境说明

  • redmine 3.4.6
  • CentOS Linux release 7.5
  • Mysql 5.5
  • Ruby 2.1.9
  • Passenger 5.3.4
  • Apache 2.4.7

一.更新系统关键组件

  1. 为方便起见,我们将按照以下方式进行操作:
  • 选择并复制命令(CTRL + C)

  • 右键单击Putty窗口以粘贴命令,然后按Enter执行

复制并执行以下命令以更新系统的关键组件:

sudo yum update
  • 显示信息如下,供参考:
Installed:
  kernel.x86_64 0:3.10.0-862.9.1.el7                                               

Updated:
  NetworkManager.x86_64 1:1.10.2-16.el7_5                                          
  NetworkManager-libnm.x86_64 1:1.10.2-16.el7_5                                    
  NetworkManager-team.x86_64 1:1.10.2-16.el7_5                                     
  NetworkManager-tui.x86_64 1:1.10.2-16.el7_5                                      
  binutils.x86_64 0:2.27-28.base.el7_5.1                                           
  ca-certificates.noarch 0:2018.2.22-70.0.el7_5                                    
  centos-release.x86_64 0:7-5.1804.4.el7.centos                                    
  dhclient.x86_64 12:4.2.5-68.el7.centos.1                                         
  dhcp-common.x86_64 12:4.2.5-68.el7.centos.1                                      
  dhcp-libs.x86_64 12:4.2.5-68.el7.centos.1                                        
  e2fsprogs.x86_64 0:1.42.9-12.el7_5                                               
  e2fsprogs-libs.x86_64 0:1.42.9-12.el7_5                                          
  gnupg2.x86_64 0:2.0.22-5.el7_5                                                   
  iptables.x86_64 0:1.4.21-24.1.el7_5                                              
  kernel-tools.x86_64 0:3.10.0-862.9.1.el7                                         
  kernel-tools-libs.x86_64 0:3.10.0-862.9.1.el7                                    
  libcom_err.x86_64 0:1.42.9-12.el7_5                                              
  libgcc.x86_64 0:4.8.5-28.el7_5.1                                                 
  libgomp.x86_64 0:4.8.5-28.el7_5.1                                                
  libss.x86_64 0:1.42.9-12.el7_5                                                   
  libstdc++.x86_64 0:4.8.5-28.el7_5.1                                              
  linux-firmware.noarch 0:20180220-62.2.git6d51311.el7_5                           
  nspr.x86_64 0:4.19.0-1.el7_5                                                     
  nss.x86_64 0:3.36.0-5.el7_5                                                      
  nss-softokn.x86_64 0:3.36.0-5.el7_5                                              
  nss-softokn-freebl.x86_64 0:3.36.0-5.el7_5                                       
  nss-sysinit.x86_64 0:3.36.0-5.el7_5                                              
  nss-tools.x86_64 0:3.36.0-5.el7_5                                                
  nss-util.x86_64 0:3.36.0-1.el7_5                                                 
  openldap.x86_64 0:2.4.44-15.el7_5                                                
  procps-ng.x86_64 0:3.3.10-17.el7_5.2                                             
  python.x86_64 0:2.7.5-69.el7_5                                                   
  python-libs.x86_64 0:2.7.5-69.el7_5                                              
  python-perf.x86_64 0:3.10.0-862.9.1.el7                                          
  rsyslog.x86_64 0:8.24.0-16.el7_5.4                                               
  selinux-policy.noarch 0:3.13.1-192.el7_5.4                                       
  selinux-policy-targeted.noarch 0:3.13.1-192.el7_5.4                              
  sudo.x86_64 0:1.8.19p2-14.el7_5                                                  
  yum-plugin-fastestmirror.noarch 0:1.1.31-46.el7_5                                
  yum-utils.noarch 0:1.1.31-46.el7_5                                               

Complete!
  1. 更新完成后,我们需要使用以下命令重新启动系统:
reboot

二.安装依赖项包

这些是用于编译其他包的环境设置和实用工具的基本软件包。

复制块命令并在命令行中执行:

这是一个很长的命令行,负责全部内容。

sudo yum -y install nano 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
  • 显示信息如下,供参考:
Installed:
  ImageMagick-devel.x86_64 0:6.7.8.9-15.el7_2                                      
  apr-devel.x86_64 0:1.4.8-3.el7_4.1                                               
  apr-util-devel.x86_64 0:1.5.2-6.el7                                              
  gcc.x86_64 0:4.8.5-28.el7_5.1                                                    
  gcc-c++.x86_64 0:4.8.5-28.el7_5.1                                                
  httpd-devel.x86_64 0:2.4.6-80.el7.centos.1                                       
  libcurl-devel.x86_64 0:7.29.0-46.el7                                             
  libyaml-devel.x86_64 0:0.1.4-11.el7_0                                            
  mariadb-devel.x86_64 1:5.5.56-2.el7                                              
  nano.x86_64 0:2.3.1-10.el7                                                       
  openssl-devel.x86_64 1:1.0.2k-12.el7                                             
  perl-Digest-SHA.x86_64 1:5.85-4.el7                                              
  perl-LDAP.noarch 1:0.56-5.el7                                                    
  postgresql-devel.x86_64 0:9.2.23-3.el7_4                                         
  ruby-devel.x86_64 0:2.0.0.648-33.el7_4                                           
  sqlite-devel.x86_64 0:3.7.17-8.el7                                               
  unzip.x86_64 0:6.0-19.el7                                                        
  zip.x86_64 0:3.0-11.el7                                                          
  zlib-devel.x86_64 0:1.2.7-17.el7                                                 

Dependency Installed:
  ImageMagick.x86_64 0:6.7.8.9-15.el7_2                                            
  OpenEXR-libs.x86_64 0:1.7.1-7.el7                                                
  apr.x86_64 0:1.4.8-3.el7_4.1                                                     
  apr-util.x86_64 0:1.5.2-6.el7                                                    
  avahi-libs.x86_64 0:0.6.31-19.el7                                                
  bzip2-devel.x86_64 0:1.0.6-13.el7                                                
  cairo.x86_64 0:1.14.8-2.el7                                                      
  cpp.x86_64 0:4.8.5-28.el7_5.1                                                    
  cups-libs.x86_64 1:1.6.3-35.el7                                                  
  cyrus-sasl.x86_64 0:2.1.26-23.el7                                                
  cyrus-sasl-devel.x86_64 0:2.1.26-23.el7                                          
  expat-devel.x86_64 0:2.1.0-10.el7_3                                              
  fontconfig.x86_64 0:2.10.95-11.el7                                               
  fontpackages-filesystem.noarch 0:1.44-8.el7                                      
  freetype-devel.x86_64 0:2.4.11-15.el7                                            
  gdk-pixbuf2.x86_64 0:2.36.5-1.el7                                                
  ghostscript.x86_64 0:9.07-28.el7_4.2                                             
  ghostscript-devel.x86_64 0:9.07-28.el7_4.2                                       
  ghostscript-fonts.noarch 0:5.50-32.el7                                           
  glibc-devel.x86_64 0:2.17-222.el7                                                
  glibc-headers.x86_64 0:2.17-222.el7                                              
  graphite2.x86_64 0:1.3.10-1.el7_3                                                
  harfbuzz.x86_64 0:1.3.2-1.el7                                                    
  httpd.x86_64 0:2.4.6-80.el7.centos.1                                             
  httpd-tools.x86_64 0:2.4.6-80.el7.centos.1                                       
  ilmbase.x86_64 0:1.0.3-7.el7                                                     
  jasper-devel.x86_64 0:1.900.1-31.el7                                             
  jasper-libs.x86_64 0:1.900.1-31.el7                                              
  jbigkit-libs.x86_64 0:2.0-11.el7                                                 
  kernel-headers.x86_64 0:3.10.0-862.9.1.el7                                       
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7                                         
  krb5-devel.x86_64 0:1.15.1-19.el7                                                
  lcms2.x86_64 0:2.6-3.el7                                                         
  libICE.x86_64 0:1.0.9-9.el7                                                      
  libICE-devel.x86_64 0:1.0.9-9.el7                                                
  libSM.x86_64 0:1.2.2-2.el7                                                       
  libSM-devel.x86_64 0:1.2.2-2.el7                                                 
  libX11.x86_64 0:1.6.5-1.el7                                                      
  libX11-common.noarch 0:1.6.5-1.el7                                               
  libX11-devel.x86_64 0:1.6.5-1.el7                                                
  libXau.x86_64 0:1.0.8-2.1.el7                                                    
  libXau-devel.x86_64 0:1.0.8-2.1.el7                                              
  libXdamage.x86_64 0:1.1.4-4.1.el7                                                
  libXext.x86_64 0:1.3.3-3.el7                                                     
  libXext-devel.x86_64 0:1.3.3-3.el7                                               
  libXfixes.x86_64 0:5.0.3-1.el7                                                   
  libXfont.x86_64 0:1.5.2-1.el7                                                    
  libXft.x86_64 0:2.3.2-2.el7                                                      
  libXrender.x86_64 0:0.9.10-1.el7                                                 
  libXt.x86_64 0:1.1.5-3.el7                                                       
  libXt-devel.x86_64 0:1.1.5-3.el7                                                 
  libXxf86vm.x86_64 0:1.1.4-1.el7                                                  
  libcom_err-devel.x86_64 0:1.42.9-12.el7_5                                        
  libdb-devel.x86_64 0:5.3.21-24.el7                                               
  libfontenc.x86_64 0:1.1.3-3.el7                                                  
  libjpeg-turbo.x86_64 0:1.2.90-5.el7                                              
  libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7                                        
  libkadm5.x86_64 0:1.15.1-19.el7                                                  
  libmpc.x86_64 0:1.0.1-3.el7                                                      
  libpng.x86_64 2:1.5.13-7.el7_2                                                   
  librsvg2.x86_64 0:2.40.16-1.el7                                                  
  libselinux-devel.x86_64 0:2.5-12.el7                                             
  libsepol-devel.x86_64 0:2.5-8.1.el7                                              
  libstdc++-devel.x86_64 0:4.8.5-28.el7_5.1                                        
  libthai.x86_64 0:0.1.14-9.el7                                                    
  libtiff.x86_64 0:4.0.3-27.el7_3                                                  
  libtiff-devel.x86_64 0:4.0.3-27.el7_3                                            
  libtool-ltdl.x86_64 0:2.4.2-22.el7_3                                             
  libverto-devel.x86_64 0:0.2.5-4.el7                                              
  libwayland-client.x86_64 0:1.14.0-2.el7                                          
  libwayland-server.x86_64 0:1.14.0-2.el7                                          
  libwmf-lite.x86_64 0:0.2.8.4-41.el7_1                                            
  libxcb.x86_64 0:1.12-1.el7                                                       
  libxcb-devel.x86_64 0:1.12-1.el7                                                 
  libxshmfence.x86_64 0:1.2-1.el7                                                  
  libyaml.x86_64 0:0.1.4-11.el7_0                                                  
  mailcap.noarch 0:2.1.41-2.el7                                                    
  mesa-libEGL.x86_64 0:17.2.3-8.20171019.el7                                       
  mesa-libGL.x86_64 0:17.2.3-8.20171019.el7                                        
  mesa-libgbm.x86_64 0:17.2.3-8.20171019.el7                                       
  mesa-libglapi.x86_64 0:17.2.3-8.20171019.el7                                     
  mpfr.x86_64 0:3.1.1-4.el7                                                        
  openldap-devel.x86_64 0:2.4.44-15.el7_5                                          
  pango.x86_64 0:1.40.4-1.el7                                                      
  pcre-devel.x86_64 0:8.32-17.el7                                                  
  perl.x86_64 4:5.16.3-292.el7                                                     
  perl-Authen-SASL.noarch 0:2.15-10.el7                                            
  perl-Business-ISBN.noarch 0:2.06-2.el7                                           
  perl-Business-ISBN-Data.noarch 0:20120719.001-2.el7                              
  perl-Carp.noarch 0:1.26-244.el7                                                  
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7                                     
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7                                      
  perl-Convert-ASN1.noarch 0:0.26-4.el7                                            
  perl-Data-Dumper.x86_64 0:2.145-3.el7                                            
  perl-Digest.noarch 0:1.17-245.el7                                                
  perl-Digest-HMAC.noarch 0:1.03-5.el7                                             
  perl-Digest-MD5.x86_64 0:2.52-3.el7                                              
  perl-Encode.x86_64 0:2.51-7.el7                                                  
  perl-Encode-Locale.noarch 0:1.03-5.el7                                           
  perl-Exporter.noarch 0:5.68-3.el7                                                
  perl-File-Listing.noarch 0:6.04-7.el7                                            
  perl-File-Path.noarch 0:2.09-2.el7                                               
  perl-File-Temp.noarch 0:0.23.01-3.el7                                            
  perl-Filter.x86_64 0:1.49-3.el7                                                  
  perl-GSSAPI.x86_64 0:0.28-9.el7                                                  
  perl-Getopt-Long.noarch 0:2.40-3.el7                                             
  perl-HTML-Parser.x86_64 0:3.71-4.el7                                             
  perl-HTML-Tagset.noarch 0:3.20-15.el7                                            
  perl-HTTP-Cookies.noarch 0:6.01-5.el7                                            
  perl-HTTP-Daemon.noarch 0:6.01-7.el7                                             
  perl-HTTP-Date.noarch 0:6.02-8.el7                                               
  perl-HTTP-Message.noarch 0:6.06-6.el7                                            
  perl-HTTP-Negotiate.noarch 0:6.01-5.el7                                          
  perl-HTTP-Tiny.noarch 0:0.033-3.el7                                              
  perl-IO-Compress.noarch 0:2.061-2.el7                                            
  perl-IO-HTML.noarch 0:1.00-2.el7                                                 
  perl-IO-Socket-IP.noarch 0:0.21-5.el7                                            
  perl-IO-Socket-SSL.noarch 0:1.94-7.el7                                           
  perl-JSON.noarch 0:2.59-2.el7                                                    
  perl-LWP-MediaTypes.noarch 0:6.02-2.el7                                          
  perl-Mozilla-CA.noarch 0:20130114-5.el7                                          
  perl-Net-HTTP.noarch 0:6.06-2.el7                                                
  perl-Net-LibIDN.x86_64 0:0.12-15.el7                                             
  perl-Net-SSLeay.x86_64 0:1.55-6.el7                                              
  perl-PathTools.x86_64 0:3.40-5.el7                                               
  perl-Pod-Escapes.noarch 1:1.04-292.el7                                           
  perl-Pod-Perldoc.noarch 0:3.20-4.el7                                             
  perl-Pod-Simple.noarch 1:3.28-4.el7                                              
  perl-Pod-Usage.noarch 0:1.63-3.el7                                               
  perl-Scalar-List-Utils.x86_64 0:1.27-248.el7                                     
  perl-Socket.x86_64 0:2.010-4.el7                                                 
  perl-Storable.x86_64 0:2.45-3.el7                                                
  perl-Text-ParseWords.noarch 0:3.29-4.el7                                         
  perl-Text-Soundex.x86_64 0:3.04-4.el7                                            
  perl-Text-Unidecode.noarch 0:0.04-20.el7                                         
  perl-Time-HiRes.x86_64 4:1.9725-3.el7                                            
  perl-Time-Local.noarch 0:1.2300-2.el7                                            
  perl-TimeDate.noarch 1:2.30-2.el7                                                
  perl-URI.noarch 0:1.60-9.el7                                                     
  perl-WWW-RobotRules.noarch 0:6.02-5.el7                                          
  perl-XML-Filter-BufferText.noarch 0:1.01-17.el7                                  
  perl-XML-NamespaceSupport.noarch 0:1.11-10.el7                                   
  perl-XML-SAX-Base.noarch 0:1.08-7.el7                                            
  perl-XML-SAX-Writer.noarch 0:0.53-4.el7                                          
  perl-constant.noarch 0:1.27-2.el7                                                
  perl-libs.x86_64 4:5.16.3-292.el7                                                
  perl-libwww-perl.noarch 0:6.05-2.el7                                             
  perl-macros.x86_64 4:5.16.3-292.el7                                              
  perl-parent.noarch 1:0.225-244.el7                                               
  perl-podlators.noarch 0:2.5.1-3.el7                                              
  perl-threads.x86_64 0:1.87-4.el7                                                 
  perl-threads-shared.x86_64 0:1.43-6.el7                                          
  pixman.x86_64 0:0.34.0-1.el7                                                     
  poppler-data.noarch 0:0.4.6-3.el7                                                
  postgresql.x86_64 0:9.2.23-3.el7_4                                               
  postgresql-libs.x86_64 0:9.2.23-3.el7_4                                          
  ruby.x86_64 0:2.0.0.648-33.el7_4                                                 
  ruby-irb.noarch 0:2.0.0.648-33.el7_4                                             
  ruby-libs.x86_64 0:2.0.0.648-33.el7_4                                            
  rubygem-bigdecimal.x86_64 0:1.2.0-33.el7_4                                       
  rubygem-io-console.x86_64 0:0.4.2-33.el7_4                                       
  rubygem-json.x86_64 0:1.7.7-33.el7_4                                             
  rubygem-psych.x86_64 0:2.0.0-33.el7_4                                            
  rubygem-rdoc.noarch 0:4.0.0-33.el7_4                                             
  rubygems.noarch 0:2.0.14.1-33.el7_4                                              
  stix-fonts.noarch 0:1.1.0-5.el7                                                  
  urw-fonts.noarch 0:2.4-16.el7                                                    
  xorg-x11-font-utils.x86_64 1:7.5-20.el7                                          
  xorg-x11-proto-devel.noarch 0:7.7-20.el7                                         

Complete!

三.安装Apache和Mysql

Apache是一个通过HTTP协议进行通信的服务器应用程序。 Apache可在Unix,Linux,Microsoft Windows和其他操作系统等操作系统上运行。

Apache在互联网和万维网的发展中发挥着重要作用。

MySQL是世界上最流行的数据库管理免费开源,MySQL具有高速,稳定和易用性,可移植性,在多个操作系统上运行,提供了一个非常强大的实用功能系统。

凭借速度和高安全性,MySQL非常适合访问互联网上数据库的应用程序。

  1. 使用以下命令安装Apache:
sudo yum -y install httpd 
  • 操作系统启动时允许启动服务:
sudo chkconfig httpd on
sudo service httpd start
  1. centos7默认不支持mysql,默认支持的是mariadb,mariadb是mysql一个开源分支。
  • 如果已经安装mariadb,请使用以下方法将其卸载:

a.卸载mariadb,否则安装mysql会出现冲突,

  • 执行命令
rpm -qa | grep mariadb

列出所有被安装的mariadb rpm 包;

  • 执行命令
rpm -e --nodeps 包名称(比如:rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64)

逐个将所有列出的mariadb rpm 包给卸载掉

  1. 增加官方的yum源
  • 以安装mysql5.6为例:

创建并编辑mysql-community.repo文件

vi /etc/yum.repos.d/mysql-community.repo

将以下内容粘贴进去并保存

[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

注意:gpgcheck是GPG加密校验,官方文档中,值为1,但check会报错误,所以这里改为0跳过检查,对安装无影响。

  1. 安装Mysql,执行命令:
sudo yum install mysql-community-server

显示效果如下,供参考:

Installed:
  mysql-community-server.x86_64 0:5.6.41-2.el7                                     

Dependency Installed:
  mysql-community-client.x86_64 0:5.6.41-2.el7                                     
  mysql-community-common.x86_64 0:5.6.41-2.el7                                     
  mysql-community-libs.x86_64 0:5.6.41-2.el7                                       
  net-tools.x86_64 0:2.0-0.22.20131004git.el7                                      
  perl-DBI.x86_64 0:1.627-4.el7                                                    
  perl-Net-Daemon.noarch 0:0.48-5.el7                                              
  perl-PlRPC.noarch 0:0.2020-14.el7                                                

Complete!
  • 操作系统启动时允许启动服务:
sudo chkconfig mysqld on
sudo service mysqld start
  1. 设置mysql的root密码
 /usr/bin/mysql_secure_installation
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "zh_CN.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
# 因为我们没有root帐户的密码所以请按Enter跳过。
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
# 选择“y”以设置MySQL root帐户的密码。
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
# 输入并确认您的密码,删除匿名用户,选择y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
# 允许以root帐户远程登录MySQL,选择n。
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
# 删除测试数据库,选择“y”
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
# 重新加载权限表,选择y
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...

四.关闭SELinux

SELinux是Linux操作系统的高级安全功能,在安装系统时,您需要关闭此功能才能顺利完成该过程,成功后您可以根据需要打开。

 sudo nano /etc/selinux/config

按照以下内容修改 :

SELINUX=disabled
  • 修改效果如下,供参考:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are prote$
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
  • 按CTRL + O保存文件,然后按CTRL + X退出。

五.设置主机名

默认情况下,在安装新的操作系统Centos时未设置主机名,因此我们需要使用以下命令进行设置:

 sudo nano /etc/hosts
  GNU nano 2.3.1               File: /etc/hosts                                    

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

添加您在命令行上设置的域名或主机名,保存文件并退出,重新启动时将更改服务器名称。

六.配置防火墙

我们不想关闭防火墙,因为它非常重要,因此您需要添加规则以允许HTTP端口80和HTTPS端口443。

CentOS 7中防火墙是一个非常的强大的功能,在CentOS 6.5中在iptables防火墙中进行了升级了。CentOS 7 中默认Firewall动态管理防火墙

  1. 检查动态防火墙是否开启
 ps -ef | grep firewalld
root     17724     1  0 14:49 ?        00:00:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
root     17851 17562  0 15:01 pts/1    00:00:00 grep --color=auto firewalld

如果firewalld进程不存在,请输入启动命令:

 sudo systemctl start firewalld.service 
  1. 添加端口22、80、8080、443和3306端口
 sudo firewall-cmd --zone=public --add-port=22/tcp --permanent 
 sudo firewall-cmd --zone=public --add-port=80/tcp --permanent 
 sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent 
 sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
 sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
 sudo firewall-cmd --reload
  1. 检查端口是否配置成功
 sudo firewall-cmd --list-ports
80/tcp 8080/tcp 443/tcp 3306/tcp 22/tcp
  1. 配置防火墙开机自启动
 sudo chkconfig firewalld on
Note: Forwarding request to 'systemctl enable firewalld.service'.
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
  1. 最后,我们需要重新启动系统以将更改应用于SELinux和Hostname。
 sudo reboot

七.安装PHP和phpMyAdmin

因为我们使用MySQL数据库管理系统,所以我们需要安装phpMyAdmin程序管理。

phpMyAdmin是一个免费的开源工具,由PHP语言编写,通过Web浏览器管理MySQL数据库。

它可以创建,修改或删除数据库,表,字段或记录,执行SQL语句或管理用户和权限。

  1. 安装PHP和包的命令:
 sudo 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

命令执行后显示如下,供参考:

Installed:
  php.x86_64 0:5.4.16-45.el7             php-gd.x86_64 0:5.4.16-45.el7            
  php-ldap.x86_64 0:5.4.16-45.el7        php-mbstring.x86_64 0:5.4.16-45.el7      
  php-mysql.x86_64 0:5.4.16-45.el7       php-odbc.x86_64 0:5.4.16-45.el7          
  php-pear.noarch 1:1.9.4-21.el7         php-soap.x86_64 0:5.4.16-45.el7          
  php-xml.x86_64 0:5.4.16-45.el7         php-xmlrpc.x86_64 0:5.4.16-45.el7        

Dependency Installed:
  libXpm.x86_64 0:3.5.12-1.el7               libxslt.x86_64 0:1.1.28-5.el7         
  libzip.x86_64 0:0.10.1-8.el7               php-cli.x86_64 0:5.4.16-45.el7        
  php-common.x86_64 0:5.4.16-45.el7          php-pdo.x86_64 0:5.4.16-45.el7        
  php-process.x86_64 0:5.4.16-45.el7         t1lib.x86_64 0:5.1.2-14.el7           
  unixODBC.x86_64 0:2.3.1-11.el7            

Complete!
  1. 重新启动Apache服务
 sudo service httpd restart
  1. 然后,安装phpMyadmin:
 sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
 sudo yum -y install phpmyadmin

命令执行后显示内容如下,供参考:

Installed:
  phpMyAdmin.noarch 0:4.4.15.10-3.el7                                              

Dependency Installed:
  compat-libtidy.x86_64 0:0.99.0-37.20091203.el7                                   
  dejavu-fonts-common.noarch 0:2.33-6.el7                                          
  dejavu-sans-fonts.noarch 0:2.33-6.el7                                            
  php-bcmath.x86_64 0:5.4.16-45.el7                                                
  php-fedora-autoloader.noarch 0:1.0.0-1.el7                                       
  php-php-gettext.noarch 0:1.0.12-1.el7                                            
  php-tcpdf.noarch 0:6.2.13-1.el7                                                  
  php-tcpdf-dejavu-sans-fonts.noarch 0:6.2.13-1.el7                                
  php-tidy.x86_64 0:5.4.16-7.el7                                                   

Complete!
  1. 编辑虚拟主机文件以允许远程登录phpMyadmin。
 sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
  1. 编辑phpMyadmin的配置文件
    默认情况下,CentOS 7上的phpMyAdmin只允许从回环地址(127.0.0.1)访问。为了能远程连接,你需要改动它的配置。

用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉带有"Require ip XXXX"字样的代码行。会有四处这样的代码行,用"Require all granted"取而代之。重新改动过的配置文件如下所示。


   AddDefaultCharset UTF-8

   
     # Apache 2.4
     
#       Require ip 127.0.0.1   
#       Require ip ::1             
       Require all granted    
     
   
   
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   



   
     # Apache 2.4
     
#       Require ip 127.0.0.1    
#       Require ip ::1               
       Require all granted   
     
   
   
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   


# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#

    Order Deny,Allow
    Deny from All
    Allow from None



    Order Deny,Allow
    Deny from All
    Allow from None



    Order Deny,Allow
    Deny from All
    Allow from None

  1. 最后,重启httpd使改动生效
$ sudo systemctl restart httpd
  1. 成功安装phpMyadmin后,您可以在以下地址查看:

HTTP://你的域名/ phpMyAdmin的

使用帐户登录:root / your_password

用密码已经设置在上面安装MySQL数据库的步骤。

phpMyadmin界面

注意:如果在PC上或不在专用服务器上的虚拟机中安装Redmine系统,我们需要将应用程序phpMyadmin切换为在端口8080上运行,因为端口80将在后续步骤中用于Redmine。

我们需要向防火墙添加端口8080(已在第六章配置防火墙描述并添加)并更改phpMyadmin的VirtualHost。

  • 编辑VirtualHost文件以在端口8080上运行phpMyadmin
$ sudo nano /etc/httpd/conf/httpd.conf

修改如下内容,供参考:


    DocumentRoot /usr/share/phpmyadmin/
    ServerName your_domain.com

接下来,添加命令以允许侦听文件“httpd.conf”中的端口8080

$ sudo nano /etc/httpd/conf/httpd.conf

添加以下命令:

Listen 8080

保存文件并退出,重新启动Apache服务:

$ sudo service httpd restart

现在,phpMyadmin将在地址8080上运行:

八.安装ruby

Ruby是一种面向对象的编程语言,能够反射。 语法继承自Ada和Perl,具有Smalltalk的面向对象特性,并且还与Python,Lisp,Dylan和CLU共享一些特性,Ruby是单阶段解释器。

Ruby提供编程模式,包括函数式编程,面向对象,命令式,反射式,它使用动态变量和自动内存管理。

  1. 使用版本管理程序RVM安装Ruby解释器:
$ \curl -L https://get.rvm.io | bash
  1. 成功之后,我们将推出RVM
$ source /home/parallels/.rvm/scripts/rvm
  1. 以下命令将列出要安装的Ruby版本:
$ rvm list known

显示内容如下,供参考:

# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.7]
[ruby-]2.4[.4]
[ruby-]2.5[.1]
[ruby-]2.6[.0-preview2]
ruby-head
  1. 我们选择稳定版本[ruby-] 2.2 [.10],并执行以下命令:
$ rvm install 2.2

安装过程相当长,但您不需要任何干预,成功后,请使用以下命令进行检查:

注:如果下载非常慢,可以输入以下指令修改gem源,然后再运行rvm install 2.2

$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com

请确保只有 https://gems.ruby-china.com

$ ruby -v
ruby 2.2.10p489 (2018-03-28 revision 63023) [x86_64-linux]

九.安装RubyGems

Rubygems是一个Ruby的包管理程序,在Ruby语言和Ruby On Rails框架编写的应用程序中非常流行。

$ yum -y install rubygems

十.安装Passenger

Passenger的全名是Phusion Passenger,称为mod_rails或mod_rack,它是一个与Apache集成的Web应用程序,它可以作为Ruby On Rails应用程序的独立Web服务器支持。

  1. 执行以下命令:
$ gem install passenger
$ passenger-install-apache2-module

显示如下,供参考:

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.


--------------------------------------------

Which languages are you interested in?

Use  to select.
If the menu doesn't display correctly, press '!'

   ⬢  Ruby
 ‣ ⬡  Python
   ⬡  Node.js
   ⬡  Meteor

  1. 完成后,我们在窗口中复制通知块以在后续步骤中创建配置文件(选择块通知并按C进行复制)。
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so

   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.37
   PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p545/wrappers/ruby

  1. 为Passenger创建一个新的虚拟主机文件:
$ nano /etc/httpd/conf.d/passenger.conf
  1. 将命令块粘贴到空文件中并保存,然后重新启动Apache服务。
$ service httpd restart

十一.为Redmine创建数据库

使用MySQLAdmin为Redmine创建一个空数据库,保存密码以在接下来的步骤中填写配置文件。

$ mysql --user=root --password=root_password_mysql
> create database redmine_db character set utf8;
> create user 'redmine_admin'@'localhost' identified by 'your_new_password';
> grant all privileges on redmine_db.* to 'redmine_admin'@'localhost';
> quit;

十二.安装Redmine

Redmine是项目管理系统的主要程序,我们将从Redmine网站下载并安装该程序。

  1. 将Redmine版本3.4.6下载到Centos OS上的目录“/ var / www”。
$ cd /var/www
$ yum install wget
$ wget http://www.redmine.org/releases/redmine-3.4.6.tar.gz
  1. 解压缩文件夹并重命名目录
$ tar xvfz redmine-3.4.6.tar.gz
$ mv redmine-3.4.6 redmine
$ rm -rf redmine-3.4.6.tar.gz
  1. 配置数据库

接下来,我们需要配置数据库是从上面的步骤创建的。

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

配置"production"内容如下:

production:
  adapter: mysql2
  database: redmine_db
  host: localhost
  username: redmine_admin
  password: "123456"
  encoding: utf8

输入数据库名称,输入数据库的用户名和密码。 按CTRL + O保存文件,按CTRL + X退出。

十三.设置Rails

  1. 使用Bundle安装Rails的软件包库支持。
$ bundle config mirror.https://rubygems.org https://gems.ruby-china.org
$ cd /var/www/redmine
$ gem install bundler
$ bundle install
$ rake generate_secret_token
  1. 接下来,我们为Redmine应用程序创建数据库表。
$ RAILS_ENV=production rake db:migrate
$ RAILS_ENV=production rake redmine:load_default_data
Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] zh
  1. 激活FCGI
$ cd /var/www/redmine/public
$ cp dispatch.fcgi.example dispatch.fcgi
$ cp htaccess.fcgi.example .htaccess
  1. 设置Apache和FastCGI
$ cd /var/www/
$ 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
  1. 创建文件目录
    该目录包含在Redmine作为文档或图像文件操作期间生成的数据文件,我们在“/ opt”中创建一个新目录。
$ mkdir -p /opt/redmine/files
$ chown -R apache:apache /opt/redmine
$ cd /var/www/redmine/config
$ cp configuration.yml.example configuration.yml
$ nano configuration.yml

  # Configuration of the autologin cookie.
  # autologin_cookie_name: the name of the cookie (default: autologin)bsolute path to the directory where attachments are stored.
  # The default is the 'files' directory in your Redmine instance.
  # Your Redmine instance needs to have write permission on this
  # directory.
  # Examples:
   attachments_storage_path: /opt/redmine/files
  # attachments_storage_path: D:/redmine/files
  #attachments_storage_path:

将包含刚刚在上一步中创建的数据文件的目录路径输入“attachments_storage_path”行。

注意:您必须在字符“:”之后的路径“/ opt / redmine / files”的开头添加一个空格

十四.为Redmine创建虚拟主机

在端口80上为Redmine应用程序创建Apache配置文件。

$ ln -s /var/www/redmine/public/ /var/www/html/redmine
$ nano /etc/httpd/conf.d/redmine.conf

复制下面的文本并粘贴到编辑器窗口,记下要更改域名的信息。



        DocumentRoot /var/www/html/redmine

        ErrorLog logs/redmine_error_log

        PassengerAppRoot /var/www/redmine/

十五.保存文件配置并退出

在第一次执行Redmine之前,我们必须对安装Redmine的目录进行权限并重新启动Apache服务。

$ cd /var/www
$ chown -R apache:apache redmine
$ chmod -R 755 redmine
$ service httpd restart

Redmine将在以下地址URL运行:

HTTP://您的域

使用管理员帐户登录系统:admin / admin

您可以在成功登录后更改密码。

我们可以看到Redmine已经运行但非常原始,在接下来的步骤中我们将安装支持插件和自定义Redmine使用专业。

参考资料:
1.https://www.redmine.org/projects/redmine/wiki/Install_Redmine_25x_on_Centos_65_complete
2.https://blog.csdn.net/yyycheng/article/details/79753032
3.https://blog.csdn.net/u011304615/article/details/78871479
4.http://www.bubuko.com/infodetail-2276084.html

你可能感兴趣的:(【Redmine安装--CentOS篇】Redmine3.4.x (CentOS Linux release 7.5 , MySQL 5.6, Apache2 , Phusion Passenger))