1. 程式人生 > 實用技巧 >Centos6.5安裝配置Mantisbt

Centos6.5安裝配置Mantisbt

Centos6.5安裝配置Mantisbt

一、安裝配置Apache

1.1.安裝依賴包(APR,APR-UTIL,pcre)

tar -zxf apr-1.4.5.tar.gz
[[email protected] apr-1.4.5]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.4.5]# make
[[email protected] apr-1.4.5]# make install

[[email protected] ]# tar -zxf apr-util-1.3.12.tar.gz
[[email protected]

apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[[email protected]]# make
[[email protected]]# make install

#unzip -o pcre-8.10.zip
#cd pcre-8.10
#./configure --prefix=/usr/local/pcre
#make
#make install

1.2.編譯安裝Apache(安裝包的獲取:http://www.apache.org

tar -zxf httpd-2.4.10.tar.gz

#./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-#pcre=/usr/local/pcre

#make
#make install

1.3.配置Apache

vi /usr/local/apache/conf/httpd.conf
找到下面這行
#ServerName www.example.com:80
修改為:
ServerName www.伺服器IP:80
儲存退出。

1.4.拷貝檔案
cp –a /usr/local/apache/bin/apachectl /etc/init.d/httpd

執行service命令
Service httpd restart

檢驗配置是否成功
IE位址列輸入:http://伺服器IP:80
看到It’s Work證明配置成功。
或者使用 ps –aux|grep httpd
如果看到多行資料,也證明配置成功

二、安裝Mysql(見本部落格文章“centos6.5編譯安裝mysql5.6.20”)

三、安裝GD庫(讓PHP支援GIF、PNG、JPEG)

注意:不安裝只會影響mantis的資料統計部分功能。

3.1.安裝jpeg6(jpegsrc.v6b.tar.gz)ftp://ftp.uu.net/graphics/jpeg/

mkdir -p /usr/local/jpeg6

mkdir -p /usr/local/jpeg6/bin

mkdir -p /usr/local/jpeg6/lib

mkdir -p /usr/local/jpeg6/include

mkdir -p /usr/local/jpeg6/man

mkdir -p /usr/local/jpeg6/man1

mkdir -p /usr/local/jpeg6/man/man1

tar –zxvf jpegsrc.v6b.tar.gz

./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static

報錯,解決方法如下:

yum -y install libtool

然後進入jpeg-6b的原始碼目錄,然後執行以下步驟,切記!COPY到當前目錄注意後面的點(.)
#cd jpeg
#cp /usr/share/libtool/config/config.sub .
#cp /usr/share/libtool/config/config.guess .
也就是把 libtool裡面的兩個配置檔案拿來覆蓋掉jpeg-6b目錄下的對應檔案
make clean 再重新configure(切記必須重新configure,否則仍會報錯)
沒有許可權的時候先建立對應的資料夾,再次make install就行了

./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
make
make install

3.2.安裝libpng(libpng-1.2.35-i486-1.gz) http://www.libpng.org/pub/png/libpng.html

tar –zxvf libpng-1.2.35-i486-1.gz

./configure --prefix=/usr/local/libpng/

Make &&make install

3.3.安裝freetype(freetype-2.3.9.tar.gz) http://freetype.fis.uniroma2.it/download.html

注意:需升級make version到3.80以上:下載地址:http://ftp.gnu.org/pub/gnu/make/

tar –zxvf freetype-2.3.9.tar.gz

mkdir -p /usr/local/freetype

./configure --prefix=/usr/local/freetype

Make &&make install

3.4.安裝zlib (zlib-1.2.3.tar.gz) http://zlib.net/index.html
tar –zxvf zlib-1.2.3.tar.gz
./configure --prefix=/usr/local/zlib
Make &&make install

3.5.安裝GD庫 (gd-2.0.35.tar.gz) http://www.libgd.org/Downloads
注意:需要對m4升級到1.4.12. 下載地址:http://ftp.gnu.org/pub/gnu/m4/
注意:需要對autoconf升級到2.58或者更高 下載地址:http://ftp.gnu.org/pub/gnu/autoconf/
tar –zxvf gd-2.0.35.tar.gz
mkdir -p /usr/local/gd2
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/libpng --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype
Make &&make install

3.6.安裝Curl庫(curl-7.19.4.tar.gz) http://curl.haxx.se/download.html
tar –zxvf curl-7.19.4.tar.gz
./configure --prefix=/usr/local/curl
Make &&make install

四、安裝PHP5.3.9(PHP必須有libxml2支援)
安裝包的獲取:http://www.php.net

4.1.安裝libxml2
cd libxml2-2.7.8
./configure --prefix=/usr/local/libxml2

4.2.安裝libxslt-1.1.24(可選安裝)
yum -y install python-devel依賴包
yum -y install libgcrypt-devel依賴包
cd libxslt-1.1.28
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2

4.3.安裝php5
tar –zxvf php-5.3.9.tar.gz
./configure --prefix=/usr/local/php --with-mysql=/hywl/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng --with-zlib-dir=/usr/local/zlib --with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl --with-xsl=/usr/local/libxslt --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-sockets --with-openssl
make && make install
如果出現以下錯誤:
/usr/local/jpeg/include/jpeglib.h:938: error: expected declaration specifiers or ‘...’ before ‘FILE’
/usr/local/jpeg/include/jpeglib.h:939: error: expected declaration specifiers or ‘...’ before ‘FILE’
make: *** [ext/gd/libgd/gd_compat.lo] Error 1
解決辦法:
修改 php-5.3.9/ext/gd/libgd/gd_compat.c
1.把 <png.h> 改成絕對路徑</usr/local/libpng/include/png.h>(這個在編譯gd庫的時候應該就碰到了,同樣的路徑即可)
2.並在 # include <jpeglib.h> 前面增加一行 #include <stdio.h>
然後 make clean
重新 configure、make、make install就可以了

4.4配置檔案
#cp php.ini-recommended /usr/local/php/lib/php.ini

五、新配置Apache

5.1. vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz在其下面新增一行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

找到 DirectoryIndex index.html修改為:
DirectoryIndex index.html default.php index.php

5.2設定php檔案
Vi /usr/local/php/lib/php.ini
找到register-globals這一行修改成:
register-globals=on
修改如下語句:
date.timezone = "Asia/Shanghai"

5.3第一個php程式
vi /usr/local/apache/htdocs/test.php
檔案內容為:

<?php

Phpinfo();

?>

5.4重啟apache服務
service httpd restart
5.5檢驗是否成功
在IE中輸入如下網址
http://伺服器IP/test.php
看到php的有關配置資訊就證明成功了。

六、安裝mantis

6.1將mantis解壓到/usr/local/apache/htdocs目錄下。
重新命名:mv mantisbt-1.2.17 mantisbt
修改許可權:chmod 755 mantisbt

6.2生成資料庫;

建立資料庫mantis,並對相應的使用者分配許可權。
mysql> create database mantis default character set utf8 collate utf8_general_ci;
grant all privileges on mantis.* to 'mantis'@'%' identified by 'mantis';
grant all privileges on mantis.* to 'root'@'%' identified by 'sqlroot' with grant option;

開啟網頁http://伺服器IP/mantis/admin/install.phpwKiom1QqM46yfWwsAAQvFUNcp8Y614.jpg

Type of Database: 預設資料庫是MySQL
Hostname (for Database Server): MySQL裝在本機,可以預設
Username (for Database) : 資料庫的使用者名稱(剛才建立的使用者名稱和密碼)
Password (for Database) : 資料庫的使用者名稱密碼(剛才建立的使用者名稱和密碼)
Database name (for Database) 剛才建立的資料庫名mantis
Admin Username (to create Database ifrequired): 資料庫管理員使用者名稱及密碼
Admin Password (to create Database ifrequired): 資料庫管理員使用者名稱及密碼
Print SQL Queries instead of Writing to theDatabase 選上此項,輸出SQL但不寫到資料庫,因為輸出的SQL語句中要修改
點選install/Upgrade Database

wKioL1QqJz2Dy-0YAAYiEOiyIfw013.jpg

wKioL1QqJz7RrDHLAAcLl7f1MPo505.jpg

將上圖頁面中的Installing Database部分拷出來
刪掉Database Creation Suppressed, SQL Queries follow
刪掉SYSTEM WARNING: Invalid argument supplied for foreach()
修改language VARCHAR(32) NOT NULL DEFAULT 'english',
為 language VARCHAR(32) NOT NULL DEFAULT 'chinese_simplified',
儲存為mantis_init_db.sql

以mantis使用者登入mysql
mysql> use mantis
mysql> source /home/XXX/mantis_init_db.sql
完成資料庫的建立
此時再次按照剛才的方式填寫,執行install/Upgrade Database(可以不執行,僅是檢查資料庫建立是否正確)wKiom1QqJxPBR-rJAARZTdYcHpQ415.jpg

七、配置mantis

7.1在mantis目錄下新建配置檔案config_inc.php

配置檔案載入順序:先載入config_defaults_inc.php,後加載config_inc.php。config_inc.php中的值會覆蓋config_defaults_inc.php

此處只是簡單寫了下配置檔案,各引數含義以及詳細配置可以參看config_defaults_inc.php,如果要修改,建議拷到config_inc.php中修改。

$ cp config_inc.php.simple config_inc.php
然後修改

# --- Database Configuration ---
$g_hostname = '伺服器IP';
$g_db_username = 'mantis';
$g_db_password = '密碼';
$g_database_name= 'mantis';
$g_db_type = 'mysql';

Mantis郵箱配置,在新版的Mantis配置裡面預設通過接收啟用郵件來設定使用者密碼。
註冊新使用者時同時可以繞過郵箱驗證:
在Mantis目錄下config_defaults_inc.php檔案中找到$g_send_reset_password = ON
然後設定成:$g_send_reset_password=OFF即可。
重新使用administrator賬號及密碼,登入mantis,依次選擇管理->使用者管理->“建立使用者”,可以看到填寫密碼的輸入框啦!

以下郵件部分沒有完全配置好,待修改

# ---Email Configuration ---
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host = 'mail.xxx.com.cn:25';
$g_smtp_username = '[email protected]';
$g_smtp_password = '密碼';
$g_administrator_email = ' [email protected] ';
$g_webmaster_email = ' [email protected] ';
$g_from_name = 'Mantis Bug Tracker';
$g_from_email = ' [email protected] '; #the "From: " field in emails
$g_return_path_email = ' [email protected]'; # thereturn address for bounced mail
$g_email_receive_own = OFF;
$g_email_send_using_cronjob = OFF;
$g_enable_email_notification = ON;

圖形統計部分還沒有配置,待修改

最後增加一句設定語言為中文
$g_default_language= 'chinese_simplified';

7.2瀏覽器中輸入http://伺服器IP/mantisbt/
自動會跳轉到登入頁面
預設的使用者名稱是administrator,密碼是root
然後可以修改管理員密碼,並將mantisbt下的admin目錄移除。

八.常見問題與解決方法

8.1Mantis提交缺陷時超慢的原因和解決辦法

Mantis安裝或者使用一段時間後提交問題、添加註釋、修改狀態等操作時頁面響應超慢,很簡單的缺陷不新增附件的情況下都需要5s左右的時間才會提交成功,同時提交問題、添加註釋、修改狀態等操作後均無郵件提醒。 如果出現以上情況,可以確定是由於mantis的郵件傳送出現問題導致資料庫負擔加重,寫入資料時間過長,Mantis訪問越來越慢。

解決問題:
很多情況下Mantis都是預設傳送郵件,如果Mantis裡面的使用者和專案過多且操作頻繁時就會有大量的郵件資料產生並寫入資料庫Mantis資料庫(預設:bugtracker)儲存Email的表:mantis_email_table

所有待發送的郵件都存在該表中,該表具有如下性質:
1.如果郵件傳送成功,表內資料將被自動刪除
2.如果郵件沒有傳送成功,或者沒有清理成功,就會造成表 mantis_email_table內資料的堆積。這樣會造提交時響應延遲
測試Mantis郵件傳送:
1.退出mantis登入使用者,點選‘忘記密碼
2.填寫使用者名稱和聯絡郵箱

3.登入郵箱檢視是否接受到郵件
如果沒有接受到郵件可以判斷是Mantis的郵件傳送出現問題,導致了全部的郵件提醒滯留在mantis_email_table中
4.檢視mantis_email_table
mysql>select * from mantis_email_table;

可以看到該表中存在大量的資料(實際檢視時已經超過3000條)
刪除表中全部資料(如果重要也可以不刪除,恢復傳送郵件功能會自動傳送)
mysql>truncate table mantis_email_table;


修改Mantis的郵箱配置
***/mantis/config_default_inc.php

1.只需要將相應的郵箱修改為正確的郵箱儲存設定;

重啟Mantis,提交缺陷此時有郵件提醒即可,如果之前未刪除資料庫會陸續收到資料庫表中全部的郵件

2.或者將郵件傳送開關關閉:$g_enable_email_notification = OFF;

如果進行以上操作Mantis仍然訪問慢,請檢查下列設定:
**/mantis/core/email_api.php
函式email_send()負責郵件傳送,檢查函式email_send() 中郵件傳送和郵件刪除功能是否正常
修改PHP配置檔案的memory_limit(預設為8M,可以修改為128M)

轉載於:https://blog.51cto.com/77jiayuan/1559697