安装环境
- CentOS release 5.9 (Final)
- Apache 2.2.25
- MySQL 5.5.33
- Ruby 2.1.0p0
- Rails 3.2.13
- Passenger 4.0.37
- Redmine 2.5.1.stable
整体系统结构
apache安装
1.apache下载
apache2.2最新版下载
apache2.2以前版本下载
2.必要的包安装
yum install gcc
yum install apr-devel
yum install apr-util-devel
yum install pcre-devel
yum install zlib-devel
yum install openssl-devel
3.apache安装
./configure \
--prefix=/usr/local/apache2 \
--sbindir=/usr/local/apache2/sbin \
--datadir=/home/www \
--with-apr=/usr/bin/apr-1-config \
--with-apr-util=/usr/bin/apu-1-config \
--with-suexec-caller=www \
--with-suexec-docroot=/home/www \
--enable-ssl \
--with-ssl=shared \
--enable-proxy=shared \
--enable-so \
--enable-mods-shared=all<pre name="code" class="plain">make
make install
4.apache启动文件
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /usr/local/apaceh2/conf/httpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/sbin/apachectl
#httpd=${HTTPD-/usr/sbin/httpd}
httpd=${HTTPD-/usr/local/apache2/sbin/httpd}
prog=httpd
RETVAL=0
# check for 1.3 configuration
check13 () {
CONFFILE=/usr/local/apache2/conf/httpd.conf
GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
GONE="${GONE}AccessConfig|ResourceConfig)"
if grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
echo
echo 1>&2 " Apache 1.3 configuration directives found"
echo 1>&2 " please read /usr/share/doc/httpd-2.2.22/migration.html"
failure "Apache 1.3 config directives test"
echo
exit 1
fi
}
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
check13 || exit 1
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}
reload() {
echo -n $"Reloading $prog: "
check13 || exit 1
killproc $httpd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/run/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
5.apache证书
mkdir /usr/local/apache2/conf/ssl
cd /usr/local/apache2/conf/ssl
<pre name="code" class="plain" style="color: rgb(34, 34, 34);">#秘密锁作成
openssl genrsa -aes128 1024 > server.key
<pre name="code" class="plain">#公开锁作成
openssl req -new -key server.key > server.csr
#证书作成,apache启动时不需要输入密码
openssl x509 -in server.csr -days 365 -req -signkey server.key > server.crt
#秘密锁备份
mv server.key server.key.back
openssl rsa -in server.key.back > server.key
6.apache配置
#Include conf/extra/httpd-ssl.conf
↓
Include conf/extra/httpd-ssl.conf
httpd-ssl.conf配置
SSLCertificateFile "/usr/local/httpd-2.2.26/conf/server.crt"
↓
SSLCertificateFile "/usr/local/apache2/conf/ssl/server.crt"
SSLCertificateKeyFile "/usr/local/httpd-2.2.26/conf/server.key"
↓
SSLCertificateKeyFile "/usr/local/apache2/conf/ssl/server.key"
7.apache自动启动设置
chkconfig --add httpd
chkconfig httpd on
service httpd start
mysql安装
1.必要包安装
yum install gcc
yum install gcc-c++
yum install ncurses-devel
yum install cmake
2.mysql安装
<pre name="code" class="plain">useradd -m mysql -g mysql
tar zxvf mysql-5.5.33.tar.gz
cd mysql-5.5.33
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=true \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_READLINE=ON
<pre name="code" class="plain">make
make test
make install
</pre><pre name="code" class="plain">cd /usr/local
ln -s /usr/local/mysql5.5 mysql
</pre><pre name="code" class="plain"><pre name="code" class="plain" style="color: rgb(34, 34, 34);"><pre name="code" class="plain">vi /etc/profile
#在最后下面内容追加
export PATH=$PATH:/usr/local/mysql/bin;
cd /usr/local/src/mysql-5.5.33/support-files/
cp my-large.cnf /etc/my.cnf
vi /etc/my.cnf
#下面内容追加
[mysqld]
user=root
/usr/local/mysql/scripts/mysql_install_db --user=root --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
chkconfig --add mysql
chkconfig --list mysql
#启动
/etc/rc.d/init.d/mysql start
#停止
/etc/rc.d/init.d/mysql stop
mysql -uroot
mysql> CREATE DATABASE IF NOT EXISTS `db_redmine` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT ALL ON db_redmine.* TO user_redmine@localhost IDENTIFIED BY '********';
mysql> FLUSH PRIVILEGES;
mysql> EXIT
ruby安装
1.libyaml安装
cd /usr/local/src
wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
tar -xzvf yaml-0.1.5.tar.gz
cd yaml-0.1.5
./configure
make
make install
cd /usr/local/src
rm -rf yaml-0.1.5
tar -xzvf yaml-0.1.5.tar.gz
cd yaml-0.1.5
./configure --prefix=/usr/local/ruby-2.1.0
make
make install
2.ruby安装
cd /usr/local/src
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz
tar zxvf ruby-2.1.0.tar.gz
cd ruby-2.1.0
./configure --prefix=/usr/local/ruby-2.1.0 --enable-shared --disable-install-doc --with-opt-dir=/usr/local/ruby-2.1.0/lib
make
make install
3.ruby路径设定
vi /etc/profile
#ruby
export PATH=$PATH:/usr/local/ruby/bin;
source /etc/profile
ruby -v
redmine安装
1.redmine安装
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 /var/lib/redmine-2.5.1
cd /var/lib
ln -s /var/lib/redmine-2.5.1 redmine
cat /var/lib/redmine/lib/redmine/version.rb
2.redmine设定
#mysql连接文件设定
cd /var/lib/redmine/config
cd database.yml.example database.yml
vi database.yml
production:
adapter: mysql2
database: db_redmine
host: localhost
username: user_redmine
password: ********
encoding: utf8
#发送邮件设定
cd /var/lib/redmine/config<pre name="code" class="html">cd /var/lib/redmine
rake generate_secret_token
RAILS_ENV=production rake db:migrate
touch configuration.ymlvi configuration.ymlproduction: email_delivery: delivery_method: :smtp smtp_settings: address: "localhost" port: 25 domain: 'dev-redmine-01' #相关gem安装
cd /usr/local/src/
wget http://www.imagemagick.org/download/legacy/ImageMagick-6.8.4-10.tar.gz
tar xvfz ImageMagick-6.8.4-10.tar.gz
cd ImageMagick-6.8.4-10
./configure --prefix=/usr/local/ImageMagick-6.8.4-10
make
make install
<pre name="code" class="plain" style="color: rgb(34, 34, 34);">cd /var/lib/redmine
PKG_CONFIG_PATH=/usr/local/ImageMagick-6.8.4-10/lib/pkgconfig PATH=$PATH:/usr/local/ImageMagick-6.8.4-10/bin gem install rmagick --no-ri --no-rdoc
bundle install --without development test postgresql sqlite
#redmine初始化
cd /var/lib/redmine
rake generate_secret_token
RAILS_ENV=production rake db:migrate
gem install passenger --no-rdoc --no-ri
passenger-install-apache2-module
apahce中redmine设定
vi /usr/local/apache2/conf/httpd.conf
LoadModule passenger_module /usr/local/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/passenger-4.0.37
PassengerDefaultRuby /usr/local/ruby-2.1.0/bin/ruby
</IfModule>
vi /usr/local/apache2/conf/extra/httpd-ssl.conf
RailsBaseURI /redmine
/etc/init.d/httpd restart
https://localhost/redmine/