Hướng dẫn cài đặt môi trường phát triển trên CentOS

Hướng dẫn tổng hợp cài đặt trên môi trường phát triển trên CentOS

  • Java
  • Apache
  • Tomcat
  • Postgress
  • MySql
  • Redmine

Hướng dẫn config từ package, chứ không config auto dùng các trình quản lý như YUM.

1. Cài đặt Java

Các package cần thiết:

jdk-1_5_0_10-linux-i586-rpm.bin

Xóa toàn bộ các version java cũ trên CentOS :

# rpm -qa|grep java
gcc-java-3.4.6-3
java-1.4.2-gcj-compat-1.4.2.0-27jpp
# rpm -e java-1.4.2-gcj-compat-1.4.2.0-27jpp

Thông thường có thể dùng Yum để quản lý xóa thông tin version các package :    # yum remove java

Copy package java đã download vào thư mục bất kỳ

# cp jdk-1_5_0_10-linux-amd64-rpm.bin /root
# cd /root
# chmod a+x jdk-1_5_0_10-linux-amd64-rpm.bin
# ./jdk-1_5_0_10-linux-amd64-rpm.bin
|
|Do you agree to the above license terms? [yes or no]
|yes ← input yes
|Unpacking...
|Checksumming...
|0
|0
|Extracting...
|UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
|inflating: jdk-1_5_0_10-linux-amd64.rpm
|Preparing... ########################################### [100%]
| 1:jdk ########################################### [100%]
|
|Done.
|#

Kiểm tra lại cài đặt

# rpm -qa|grep jdk
|
|jdk-1.5.0_10-fcs
|
# /usr/java/jdk1.5.0_10/bin/java version
|
|java version "1.5.0_10"
|Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
|Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_10-b03, mixed mode)
|

2. Cài đặt apache và mode ssl

Các package cần thiết :

mod_ssl-2.2.3-43.el5.centos.i386.rpm
httpd-2.2.3-43.el5.centos.i386.rpm
distcache-1.4.5-14.1.i386.rpm

Cài đặt Apache :

# rpm -ivh httpd-2.2.3-43.el5.centos.i386.rpm
|
|warning: httpd-2.2.3-43.el5.centos.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
|Preparing... ########################################### [100%]
| 1:httpd
|

Cài đặt auto start :

# chkconfig --level 35 httpd on
#
# chkconfig --list httpd
|
|httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
|

Kiểm tra lại cấu hình start & stop :

# /usr/sbin/apachectl configtest
|
|Syntax OK
|
# service httpd start
|
|httpd を起動中: [ OK ]
|
~Apacheプロセスの確認 (/usr/sbin/httpd.workerプロセスが 20(オーナがapache)行表示される)~
# ps -ef |grep httpd|grep -v grep
|
|root 4212 1 0 22:31 ? 00:00:00 /usr/sbin/httpd.worker
|apache 4215 4212 0 22:31 ? 00:00:00 /usr/sbin/httpd.worker
| ・
| ・
|apache 8027 4212 0 22:31 ? 00:00:00 /usr/sbin/httpd.worker
|
~Apacheの停止(参考)~
# service httpd stop
|
|httpd を停止中: [ OK ]
|
~起動中のApacheを再起動(参考)~
# service httpd restart
|
|httpd を停止中: [ OK ]
|httpd を起動中: [ OK ]
|

Cấu hình SSL :

#rpm -Uvh distcache-1.4.5-14.1.i386.rpm
|
|warning: apache/distcache-1.4.5-14.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
|Preparing... ########################################### [100%]
| 1:distcache ########################################### [100%]
|
#rpm -Uvh mod_ssl-2.2.3-43.el5.centos.i386.rpm distcache-1.4.5-14.1.i386.rpm
# service httpd restart
|
|httpd を停止中: [ OK ]
|httpd を起動中: [ OK ]
|

Sau khi cấu hình xong hãy bật browser và gõ địa chỉ localhost để kiểm tra :

  • http://localhost
  • https://localhost

3. Cài đặt tomcat và mode jk

Link download package : http://archive.apache.org/dist/tomcat/
Các package cần thiết :  apache-tomcat-5.5.17.tar.gz

Tạo user cho tomcat

# groupadd tomcat5
# useradd -g tomcat5 -d /opt/tomcat5 -s /sbin/nologin tomcat5

Cài đặt

# cp apache-tomcat-5.5.17.tar.gz /opt/tomcat5/
# chown tomcat5:tomcat5 /opt/tomcat5/apache-tomcat-5.5.17.tar.gz
# cd /opt/tomcat5
# tar zxvf apache-tomcat-5.5.17.tar.gz
(略)
# mv apache-tomcat-5.5.17/* .
# rm -r apache-tomcat-5.5.17
# chown -R tomcat5.tomcat5 *

Kiểm tra start & stop

(起動の例)
# /etc/rc.d/init.d/tomcat5.5 start
|
|Starting Tomcat 5.5 servlet engine using Java from /usr/java/jdk1.5.0_10: tomcat5.
|
(停止の例)
# /etc/rc.d/init.d/tomcat5.5 stop
|
|Stopping Tomcat 5.5 servlet engine: .............................. (killing) .tomcat5.
|

Cài đặt mode mod_jk

Link download package :

Package cần thiết : mod_jk-1.2.28-httpd-2.2.X.so mod_jk-ap20-1.2.15-1jpp.1AX.i386.rpm

Cài đặt mod_jk

# rpm -ivh mod_jk-ap20-1.2.15-1jpp.1AX.i386.rpm
|
|Preparing... ########################################### [100%]
| 1:mod_jk ########################################### [100%]
|

Kiểm tra mod_jk

# cd /etc/httpd/modules
# ls -l mod_jk.so
-r-xr-xr-x 1 root root 204680 8月 2 2006 mod_jk.so
# cd /etc/httpd/conf.d/
# ls -l mod_jk.conf
-rw-r--r-- 1 root root 832 8月 2 2006 mod_jk.conf
# cd /etc/httpd/conf/
# ls -l workers.properties
-rw-r--r-- 1 root root 2172 8月 2 2006 workers.properties

Nội dung file mod_jk.conf :

##### For mod_jk Module Load Config
LoadModule jk_module modules/mod_jk.so
<IfModule mod_jk.c>
##### For mod_jk Worker Config
JkWorkersFile conf/workers.properties
##### For mod_jk Log
JkLogFile logs/mod_jk.log
JkLogLevel info
##### JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat "%w(%R) %V %T"
##### Log Format JkShmFile
# FIXME
JkShmFile logs/jk-runtime-status
##### For JK Status
JkMount /jkstatus jkstatus
##### For Application
JkMount /jsp-examples/* ajp13w
##### For Watchdog Thread
#JkWatchdogInterval 30
</IfModule>

Nội dung file workers.properties

# workers.properties.minimal -
# This file provides minimal jk configuration properties needed to
# connect to Tomcat.
# The workers that jk should create and work with
worker.list=ajp13w
# Defining a worker named ajp13w and of type ajp13
# Note that the name and the type do not have to match.
worker.ajp13.type=ajp13
worker.ajp13.port=8009
worker.ajp13.lbfactor=1
worker.ajp13.socket_timeout=5
worker.ajp13.connect_timeout=3000
worker.ajp13.prepost_timeout=3000
worker.ajp13.reply_timeout=310000
worker.ajp13.recovery_options=3
worker.ajp13.connection_pool_size=60
########## For ows11014 or ows12014
worker.ajp13w.reference=worker.ajp13
worker.ajp13w.host=localhost
# Define status worker
worker.jkstatus.type=status

Thay đổi cấu hình file tomcat server.xml

#vi /opt/tomcat5/conf/server.xml

Nội dung thay đổi

<!-- Define a non-SSL HTTP/1.1 Connector on port 8080
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
maxThreads="1002"
maxSpareThreads="200" minSpareThreads="100"
connectionTimeout="20000"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" >
<!-- Define the top level container in our container hierarchy >
<Engine name="Catalina" defaultHost="localhost" jvmRoute="ajp13w">

Kiểm tra lại apache đã config được mod_jk hay chưa

Restart tomcat
# /etc/rc.d/init.d/tomcat5.5 restart
|
|Stopping Tomcat 5.5 servlet engine: tomcat5.
|
|Starting Tomcat 5.5 servlet engine using Java from /usr/java/jdk1.5.0_10: tomcat5.
|
# service httpd stop
|
|httpd [ OK ]
|
#
# service httpd start
|
|httpd [ OK ]
|
#
# service httpd restart
|
|httpd [ OK ]
|httpd [ OK ]
|
#

Sau khi cấu hình xong hãy bật browser và gõ địa chỉ localhost để kiểm tra :

  • http://localhost
  • https://localhost

4. Cài đặt database Postgress

Các package cần thiết:

postgresql-8.1.11-1.el5_1.1.i386.rpm
postgresql-contrib-8.1.11-1.el5_1.1.i386.rpm
postgresql-docs-8.1.11-1.el5_1.1.i386.rpm
postgresql-libs-8.1.11-1.el5_1.1.i386.rpm
postgresql-server-8.1.11-1.el5_1.1.i386.rpm

Tạo user Postgres

# groupadd -g 26 postgres
# useradd -u 26 -d /var/lib/pgsql -m -g postgres -s /bin/bash postgres

Xóa toàn bộ version Postgres cũ

# rpm -qa | grep postgresql
|
|postgresql-libs-7.4.*-*.RHEL4.1
|

Hoặc

# rpm -qa | grep postgresql
|
|postgresql-server-7.4.*-*PGDG
|postgresql-libs-7.4.*-*PGDG
|postgresql-7.4.*-*PGDG
|postgresql-contrib-7.4.*-*PGDG
|postgresql-libs-7.4.*-*.RHEL4.1
|postgresql-docs-7.4.*-*PGDG
|
# rpm -e postgresql-server-7.4.11-1PGDG
# rpm -e postgresql-contrib-7.4.11-1PGDG
# rpm -e postgresql-7.4.11-1PGDG
# rpm -e postgresql-libs-7.4.11-1PGDG
# rpm -e postgresql-docs-7.4.11-1PGDG

Cài đặt Postgres

# rpm -ivh postgresql-libs-8.1.11-1.el5_1.1.i386.rpm
|
|Preparing... ########################################### [100%]
| 1:postgresql-libs ########################################### [100%]
|
# rpm -ivh postgresql-server-8.1.11-1.el5_1.1.i386.rpm
|
|Preparing... ########################################### [100%]
| 1:postgresql ########################################### [100%]
|
# rpm -ivh postgresql-8.1.11-1.el5_1.1.i386.rpm
|
|Preparing... ########################################### [100%]
| 1:postgresql-server ########################################### [100%]
|
# rpm -ivh postgresql-docs-8.1.11-1.el5_1.1.i386.rpm
|
|Preparing... ########################################### [100%]
| 1:postgresql-docs ########################################### [100%]
|
# rpm -ivh postgresql-contrib-8.1.11-1.el5_1.1.i386.rpm
|
|Preparing... ########################################### [100%]
| 1:postgresql-contrib ########################################### [100%]
|
#

Kiểm tra cài đặt Postgres

# rpm -qa | grep postgres

Tạo thư mục data và set quyền cho user postgres

# mkdir -p /dbfp/data
# chown -R postgres:postgres /dbfp
# su postgres
$ /usr/bin/initdb -D /dbfp/data --encoding=UTF8
|(中略)
|
|Success. You can now start the database server using:
|
| /usr/bin/postmaster -D /dbfp/data
|or
| /usr/bin/pg_ctl -D /dbfp/data -l logfile start
|

Kiểm tra việc set data cho postgres

$ df
|
|Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
|/dev/cciss/c0d0p3 1035660 404176 578876 42% /
|/dev/cciss/c0d0p1 124427 12940 105063 11% /boot
|none 6152884 0 6152884 0% /dev/shm
|

Start and stop service Postgres

# df
|
|Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
|/dev/cciss/c0d0p3 1035660 404176 578876 42% /
|/dev/cciss/c0d0p1 124427 12940 105063 11% /boot
|none 6152884 0 6152884 0% /dev/shm
|
$ /usr/bin/pg_ctl -D /dbfp/data start
|
|server starting
|

Kiểm tra các thông tin log và data

$ ps -ef | grep postgres
|
|(中略)
|postgres 8167 8166 0 11:21 pts/12 00:00:00 -bash
|postgres 8361 1 3 12:05 pts/12 00:00:00 /usr/bin/postgres
|postgres 8362 8361 0 12:05 ? 00:00:00 postgres: logger process
|postgres 8364 8361 0 12:05 ? 00:00:00 postgres: writer process
|postgres 8365 8361 0 12:05 ? 00:00:00 postgres: archiver process
|postgres 8366 8361 0 12:05 ? 00:00:00 postgres: stats collector process
|
|(以降省略)
|
$ /usr/bin/psql -l
|
| List of databases
| Name | Owner | Encoding
|-----------+----------+----------
|postgres | postgres | UTF8
|template0 | postgres | UTF8
|template1 | postgres | UTF8
|(3 rows)
|
# tail /var/log/messages

$ /usr/bin/pg_ctl -D /dbfp/data stop
|
|waiting for server to shut down....LOG: logger shutting down
| done
|server stopped
|
$ ps -ef | grep postgres
|
|postgres 8228 8167 0 11:27 pts/12 00:00:00 grep postgres
|↑ PostgreSQLサーバが動作していない
|

Cấu hình tự động khởi động và cấu hình service

# vi /etc/init.d/postgresql
----------------------------------------------
(中略)
# Set defaults for configuration variables
PGENGINE=/usr/bin
PGPORT=5432
#PGDATA=/var/lib/pgsql/data
PGDATA=/dbfp/data
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base/template1" ]
then
echo "Using old-style directory structure"
else
#PGDATA=/var/lib/pgsql/data
PGDATA=/dbfp/data
fi
(中略)
----------------------------------------------
# chmod 755 /etc/init.d/postgresql
#
# chkconfig --level 345 postgresql off
#
# chkconfig --list postgresql
|
|postgresql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
|

Tạo và check thử database

$ createuser -dRS -P test
Enter password for new role: test
Enter it again: test
$ createuser -DRS -P test01
Enter password for new role: test01
Enter it again: test01
$ createuser -DRS -P test02
Enter password for new role: test02
Enter it again: test02
$ psql
# CREATE DATABASE test01 with owner test ENCODING 'UTF8';
$ /usr/bin/pg_ctl -D /dbfp/data restart
$ /usr/bin/psql -l
|
| List of databases
| Name | Owner | Encoding
|-----------+----------+----------
|postgres | postgres | UTF8
|template0 | postgres | UTF8
|template1 | postgres | UTF8
|(3 rows)
|

5. Cài đặt Database MySQL

Các package cần thiết:

  • perl-DBI-1.52-2.el5.i386.rpm
  • mysql-5.0.77-4.el5_4.2.i386.rpm
  • mysql-bench-5.0.77-4.el5_4.2.i386.rpm
  • perl-DBD-MySQL-3.0007-2.el5.i386.rpm
  • mysql-server-5.0.77-4.el5_4.2.i386.rpm

Cài đặt

# rpm -ivh perl-DBI-1.52-2.el5.i386.rpm
|
|warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
|Preparing... ########################################### [100%]
| 1:perl-DBI ########################################### [100%]
|
# rpm -ivh mysql-5.0.77-4.el5_4.2.i386.rpm
|
|warning: mysql-5.0.77-4.el5_4.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
|Preparing... ########################################### [100%]
| 1:mysql ########################################### [100%]
|
# rpm -ivh mysql-bench-5.0.77-4.el5_4.2.i386.rpm
warning: mysql-bench-5.0.77-4.el5_4.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:mysql-bench ########################################### [100%]
# rpm -ivh perl-DBD-MySQL-3.0007-2.el5.i386.rpm
|
|warning: perl-DBD-MySQL-3.0007-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
|Preparing... ########################################### [100%]
| 1:perl-DBD-MySQL ########################################### [100%]
|
# rpm -ivh mysql-server-5.0.77-4.el5_4.2.i386.rpm
|
|warning: mysql-server-5.0.77-4.el5_4.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
|Preparing... ########################################### [100%]
| 1:mysql-server ########################################### [100%]
|

Cấu hình file config

#cp /etc/my.cnf /etc/my.cnf.bak
#vi /etc/my.cnf
----------------------------------------------
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set = utf8
[mysql]
default-character-set = utf8

Kiểm tra hoạt động start & stop

# /etc/rc.d/init.d/mysqld start
|
|MySQL データベースを初期化中: Installing all prepared tables
|Fill help tables
|
|To start mysqld at boot time you have to copy support-files/mysql.server
|to the right place for your system
|
|PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
|To do so, start the server, then issue the following commands:
|/usr/bin/mysqladmin -u root password 'new-password'
|/usr/bin/mysqladmin -u root -h centos.centossrv.com password 'new-password'
|See the manual for more instructions.
|
|You can start the MySQL daemon with:
|cd /usr ; /usr/bin/mysqld_safe ​&
|
|You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
|cd sql-bench ; perl run-all-tests
|
|Please report any problems with the /usr/bin/mysqlbug script!
|
|The latest information about MySQL is available on the web at
|http://www.mysql.com
|Support MySQL by buying support/licenses at http://shop.mysql.com
| [ OK ]
|MySQL を起動中: [ OK ]
|
# /etc/rc.d/init.d/mysqld restart
# /etc/rc.d/init.d/mysqld stop

Cấu hình tự động start

# chkconfig --level 345 mysqld on
# chkconfig --list mysqld
|
|mysqld 0:off 1:off 2:off 3:on 4:on 5:on 6:off
|

Cách thêm user và mật khẩu trong Mysql

# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10 to server version: 4.1.12
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select user,host,password from mysql.user;
+------+----------------------+----------+
| user | host | password |
+------+----------------------+----------+
| root | localhost | |
| root | centos.centossrv.com | |
| root | 127.0.0.1 | |
+------+----------------------+----------+
3 rows in set (0.00 sec)
mysql> set password for [email protected]=password('root');
Query OK, 0 rows affected (0.00 sec)
mysql> set password for [email protected]'localhost.localdomain'=password('root');
Query OK, 0 rows affected (0.00 sec)
mysql> set password for [email protected]=password('root');
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+----------------------+------------------+
| user | host | password |
+------+----------------------+------------------+
| root | localhost | **************** |
| root | centos.centossrv.com | **************** |
| root | 127.0.0.1 | **************** |
+------+----------------------+------------------+
3 rows in set (0.00 sec)
mysql> exit
Bye

Kiểm tra login sử dụng MySQL

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 4.1.12
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit
Bye
#

6. Cài đặt Hudson

Link download package : http://hudson-ci.org/latest/redhat/hudson.rpm

Các package cần thiết: hudson-1.366-1.1.noarch.rpm

Cách 1:

Cài đặt giống như một webapp của tomcat

#cp hudson.war /opt/tomcat5/webapps/
#
# /etc/rc.d/init.d/tomcat5.5 restart
|
|Stopping Tomcat 5.5 servlet engine: .............................. (killing) .tomcat5.
|Starting Tomcat 5.5 servlet engine using Java from /usr/java/jdk1.5.0_10: tomcat5.
|
#

Cách 2:

Cài đặt giống như một application

# rpm -ivh hudson-1.366-1.1.noarch.rpm
|
|警告: hudson-1.335-1.1.noarch.rpm: ヘッダ V4 DSA signature: NOKEY, key ID d50582e6
|準備中... ########################################### [100%]
| 1:hudson ########################################### [100%]
|
#rpm -ql hudson -v
|
|-rwxr-xr-x 1 root root 5360 11月 21 16:53 /etc/init.d/hudson
|-rw-r--r-- 1 root root 256 11月 21 16:53 /etc/logrotate.d/hudson
|-rw------- 1 root root 1707 11月 21 16:53 /etc/sysconfig/hudson
|drwxr-xr-x 2 root root 0 11月 21 16:53 /usr/lib/hudson
|-rw-r--r-- 1 root root 27735969 11月 21 16:53 /usr/lib/hudson/hudson.war
|rwxrwxrwx 1 root root 23 11月 21 16:53 /usr/sbin/rchudson -> ../../etc/init.d/hudson
|drwxr-xr-x 2 hudson hudson 0 11月 21 16:53 /var/lib/hudson
|drwxr-x--- 2 hudson hudson 0 11月 21 16:53 /var/log/hudson
|
#grep hudson /etc/passwd
|
|hudson:x:102:106:Hudson Continuous Build server:/var/lib/hudson:/bin/false
|

Thay đổi file config

#vi /etc/init.d/hudson

Thông tin thay đổi với config java

for candidate in /usr/lib/jvm/java-1.6.0/bin/java /usr/lib/jvm/jre-1.6.0/bin/java /usr/lib/jvm/java-1.5.0/bin/java /usr/lib/jvm/jre-1.5.0/bin/java /usr/bin/java /usr/java/jdk1.5.0_10/bin/java
--> for candidate in /usr/java/jdk1.5.0_10/bin/java
$PARAMS="--prefix=/hudson"

Cài đặt khởi động tự động

# chkconfig --level 345 hudson on
# chkconfig hudson off

Kiểm tra hoạt động start & stop

# service hudson start
# service hudson stop
# service hudson restart

Kiểm tra trạng thái của hudson

# service hudson status

Cách thay đổi cổng truy cập cho hudson

( chỉ áp dụng cho trường hợp đang setting như application )

#vi /etc/sysconfig/hudson
----------------------------------------------
HUDSON_PORT=8081
HUDSON_ARGS="--ajp13Port=-1"
----------------------------------------------
# service hudson restart

Cài đặt mode mod_proxy

#cp hudson.conf /etc/httpd/conf.d/
#
----------------------------------------------
<IfModule mod_proxy.c​>
ProxyRequests Off
<Proxy http://localhost:8081/hudson*​>
Order deny,allow
Allow from all
</Proxy​>
ProxyPass /hudson http://localhost:8081/hudson
ProxyPassReverse /hudson http://localhost:8081/hudson
</IfModule​>
----------------------------------------------

#service hudson restart
#
# service httpd restart
|
|httpd を停止中: [ OK ]
|httpd を起動中: [ OK ]
|

7. Cài đặt Ruby on Rails, Redmine-083

Link download package :

Các package cần thiết:

  • ruby-libs-1.8.5-5.el5_4.8.i386.rpm
  • ruby-1.8.5-5.el5_4.8.i386.rpm
  • rubygems-1.3.5.tgz
  • passenger-2.2.15.tar.gz
  • redmine-0.8.3.tar.gz

Cài đặt Ruby

#rpm -Uvh ruby-libs-1.8.5-5.el5_4.8.i386.rpm
#rpm -Uvh ruby-1.8.5-5.el5_4.8.i386.rpm

check version
#ruby -v
|
|ruby 1.8.5 (2006-08-25) [i386-linux]
|

Cài đặt Rubygem

# tar xzvf rubygems-1.3.5.tgz
# cd rubygems-1.3.2

# ruby setup.rb --- Cài đặt

# gem -v --- Check version
|
|1.3.5
|
#gem install rack -v'1.0.1' --- Update version rack

# gem list --remote mysql --- Kiểm tra version Mysql

Cài đặt Rails

# gem update --system
# gem install rails
# rails -v
|
|Rails 2.3.2
|
#rails test --- Tạo project rails
#cd test
#ruby script/server --- Run test
|
|=> Booting WEBrick...
|=> Rails 2.1.2 application started on http://0.0.0.0:3000
|=> Ctrl-C to shutdown server; call with --help for options
|

Truy cập : http://localhost:3000

Cài đặt Redmine

Chú ý : Trong trường hợp version Redmine cao hơn 0.9.x thì phải update Ruby.

Link download package : http://mirror.centos.org/centos/5/os/i386/CentOS/

Các package cần thiết:

  • zlib-devel-1.2.3-3.i386.rpm
  • apr-devel-1.2.7-11.el5_3.1.i386.rpm
  • apr-util-devel-1.2.7-11.el5.i386.rpm
  • cyrus-sasl-devel-2.1.22-5.el5_4.3.i386.rpm
  • db4-devel-4.3.29-10.el5.i386.rpm
  • e2fsprogs-devel-1.39-23.el5.i386.rpm
  • expat-devel-1.95.8-8.3.el5_4.2.i386.rpm
  • gcc-4.1.2-48.el5.i386.rpm
  • gcc-c++-4.1.2-48.el5.i386.rpm
  • glibc-devel-2.5-49.i386.rpm
  • glibc-headers-2.5-49.i386.rpm
  • httpd-devel-2.2.3-43.el5.centos.i386.rpm
  • kernel-headers-2.6.18-194.el5.i386.rpm
  • keyutils-libs-devel-1.2-1.el5.i386.rpm
  • krb5-devel-1.6.1-36.el5_4.1.i386.rpm
  • libgomp-4.4.0-6.el5.i386.rpm
  • libselinux-devel-1.33.4-5.5.el5.i386.rpm
  • libsepol-devel-1.15.2-3.el5.i386.rpm
  • libstdc++-devel-4.1.2-48.el5.i386.rpm
  • openldap-devel-2.3.43-12.el5.i386.rpm
  • openssl-devel-0.9.8e-12.el5_4.6.i386.rpm
  • ruby-devel-1.8.5-5.el5_4.8.i386.rpm
  • mysql-devel-5.0.77-4.el5_4.2.i386.rpm

Để chung cùng vào một thư mục

#rpm -Uvh import/*.rpm
# gem install mongrel
|
|Building native extensions. This could take a while...
|Building native extensions. This could take a while...
|Successfully installed fastthread-1.0.7
|Successfully installed cgi_multipart_eof_fix-2.5.0
|Successfully installed mongrel-1.1.5
|3 gems installed
|
#tar xzvf redmine-0.8.3.tar.gz
# cd /redmine-0.8.3/config
# cp -p database.yml.example database.yml
# vi database.yml

Nội dung thay đổi

production:
adapter: mysql
database: redmine
host: localhost
username: root
password: root
encoding: utf8
socket: /var/lib/mysql/mysql.sock

Phần quyền :

#chmod -R 666 redmine-0.8.3/tmp
#chmod -R 666 redmine-0.8.3/log

Cài đặt database

# rake db:migrate RAILS_ENV="production"
# ruby script/server -e production
|
|=> Booting WEBrick...
|=> Rails 2.1.2 application started on http://0.0.0.0:3000
|=> Ctrl-C to shutdown server; call with --help for options
|

1. Truy cập : http://localhost:3000

  • Login : admin
  • Pass: admin

2. Có thể xảy ra lỗi thông báo như bên dưới (chỉ xảy ra ở version 0.9.x)

rake aborted!
A key is required to write a cookie containing the session data. Use config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb

(See full trace by running task with --trace)

3. Cách fix là sửa trong file enveronment.rb

config.action_controller.session = { :key => "_hello_session", :secret => "f6278517da0e78e79bc2120004cfe2e4" }

Cài đặt plugin cho Redmine(redmine_reivew_code)

# unzip redmine_code_review-0.2.9.3.zip
# mv redmine_code_review /var/www/redmine_10/vendor/plugins/
# chown -R apache:apache /var/www/redmine_10
# cd /var/www/redmine_10/
# rake db:migrate_plugins RAILS_ENV=production
# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

Gỡ bỏ plugin trong Redmine

# ruby script/plugin remove redmine_reivew_code

Cài đặt mode mod_passenger

#gem install passenger

Có thể xảy ra trường hợp lỗi :

Building native extensions. This could take a while...
ERROR: Error installing passenger:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
can't find header files for ruby.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.7 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.7/ext/fastthread/gem_make.out

Trong trường hợp lỗi thì cài passenger bằng tay như sau

#tar zxvf passenger-2.2.15.tar.gz
#/passenger-2.2.15/bin/passenger-install-apache2-module

#cp /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/passenger.conf
#vi /etc/httpd/conf.d/passenger.conf

Nội dung file :

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /usr/bin/ruby
RailsMaxPoolSize 3
RailsPoolIdleTime 300
RailsBaseURI /redmine

Tạo thư muc Redmine trong DocumentRoot của Apache

#mkdir /var/www/redmine
#cp -rp /redmine-0.8.3/* /var/www/redmine

# chown -R apache:apache /var/www/redmine
# ln -s /var/www/redmine/public /var/www/html/redmine
# chmod -R 755 /var/www/redmine/

# service httpd restart
|
|httpd を停止中: [ OK ]
|httpd を起動中: [ OK ]
|

8. Cài đặt SVN

Các package cần thiết:

  • mod_dav_svn-1.4.2-4.el5_3.1.i386.rpm
  • perl-URI-1.35-3.noarch.rpm
  • subversion-1.4.2-4.el5_3.1.i386.rpm
  • subversion-devel-1.4.2-4.el5_3.1.i386.rpm

Cài đặt svn

# rpm -Uvh svn/*.rpm
warning: svn/mod_dav_svn-1.4.2-4.el5_3.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:perl-URI ########################################### [ 25%]
2:subversion ########################################### [ 50%]
3:mod_dav_svn ########################################### [ 75%]
4:subversion-devel ########################################### [100%]
# mkdir /var/www/svn
# chown apache:apache /var/www/svn
# mkdir /var/www/svn/conf
# cp /etc/httpd/conf.d/subversion.conf /var/www/svn/conf/svn_template.conf
# vi /etc/httpd/conf.d/subversion.conf

Include /var/www/svn/conf/*.conf --- Thêm dòng này vào file

# vi /var/www/svn/conf/svn_template.conf
----------------------------------------------
#<Location /repos​>
# DAV svn
# SVNParentPath /var/www/svn/repos
#
# <LimitExcept GET PROPFIND OPTIONS REPORT​>
# # Require SSL connection for password protection.
# SSLRequireSSL
#
# AuthType Basic
# AuthName "Authorization Realm"
# AuthUserFile /var/www/svn/conf/.htpasswd
# Require valid-user
# </LimitExcept​>
# </Location>

Tạo project mới

# svnadmin create /var/www/svn/test
# chown -R apache:apache /var/www/svn/test/
# cp /var/www/svn/conf/svn_template.conf /var/www/svn/conf/svn_test.conf
# vi /etc/httpd/conf.d/svn_test.conf
----------------------------------------------
<Location /repos​>
DAV svn
SVNParentPath /var/www/svn/repos
<LimitExcept GET PROPFIND OPTIONS REPORT​>
# Require SSL connection for password protection.
SSLRequireSSL
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /var/www/svn/conf/.htpasswd
Require valid-user
</LimitExcept​>
</Location​>
----------------------------------------------
# htpasswd -c /var/www/svn/conf/.htpasswd hiendt
New password: ←
Re-type new password:
Adding password for user centos
Restart apache
# service httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]

Chú ý : Các bạn cần có kiến thức cơ bản về sử dụng command line trên CentOS.

5 (100%) 1 vote
Đinh Thế Hiển
 

Mình là người thích viết lách, chia sẻ các trải nghiệm trong cuộc sống. Thích thể thao đặc biệt là thể hình. Hãy kết nối với mình nhé.

Click Here to Leave a Comment Below 0 comments