鲲鹏云安装MantisBT

2020/10/8 posted in  鲲鹏云

此次安装未采用Docker形式,因为鲲鹏云采用ARM架构,很多现有的Docker Image支持,需要自己更改Image,为了快速安装和上线,所以抛弃了Docker模式
系统版本:CentOS 7.6 64bit
Mantis版本:2.24.3

1. 安装PHP

1.1 yum安装依赖库

yum install -y make cmake gcc gcc-c++ autoconf automake   libpng-devel libjpeg-devel zlib libxml2-devel ncurses-devel bison   libtool-ltdl-devel libiconv libmcrypt mhash mcrypt pcre-devel openssl-devel   freetype-devel libcurl-devel

1.2下载PHP源码

wget https://www.php.net/distributions/php-7.2.20.tar.gz

解压安装包

tar -zxvf php-7.2.20.tar.gz
cd php-7.2.20

配置编译参数

./configure --prefix=/usr/local/php --with-mysql   --with-mysqli --with-pdo_mysql --with-iconv-dir --with-zlib --with-libxml-dir   --enable-xml --with-curl --enable-fpm --enable-mbstring --with-gd --with-openssl   --with-mhash --enable-sockets --with-xmlrpc --enable-zip --enable-soap   --with-freetype-dir=/usr/lib64

开始编译安装

make && make install

1.2配置php-fpm

cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf

编辑php-fpm.conf

pid = run/php-fpm.pid

建立软连接

ln -s /usr/local/php/sbin/php-fpm /usr/local/bin
ln -s /usr/local/php/bin/php /usr/bin/php

验证

php -v

2.安装Nginx

sudo yum install -y nginx

启动Nginx并设置开机自动运行

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

配置conf文件

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

#     server {
#         listen       80 default_server;
#         listen       [::]:80 default_server;
#         server_name  _;
#         root         /usr/share/nginx/html;
# 
#         # Load configuration files for the default server block.
#         include /etc/nginx/default.d/*.conf;
# 
#         location / {
#         }
# 
#         error_page 404 /404.html;
#             location = /40x.html {
#         }
# 
#         error_page 500 502 503 504 /50x.html;
#             location = /50x.html {
#         }
#     }
    
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        # 这里改动了,也可以写你的域名
        server_name  _;
        
        # 默认网站根目录(www目录)
        root         /var/www/html/mantis;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
            # 这里改动了 定义首页索引文件的名称
            index index.php index.html index.htm;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

        # 这里新加的
        # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI协议默认配置.
        # Fastcgi服务器和程序(PHP,Python)沟通的协议.
        location ~ \.php$ {
            # 设置监听端口
            fastcgi_pass   127.0.0.1:9000;
            # 设置nginx的默认首页文件(上面已经设置过了,可以删除)
            fastcgi_index  index.php;
            # 设置脚本文件请求的路径
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_split_path_info ^(.+\.php)(.*)$;     #增加这一句  
            fastcgi_param PATH_INFO $fastcgi_path_info;    #增加这一句
            # 引入fastcgi的配置文件
            include        fastcgi_params;
        }
    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

3.Mantis安装与配置

3.1解压Mantis

tar xvf mantisbt-2.24.3.tar.gz

3.2移动到nginx相关目录

mv mantisbt-2.24.3 /var/www/html/mantis

3.3访问

http://ip:port/mantis
输入Hostname、Username、Password、Database name,点击【Install/Upgrade Database】初始化数据库

邮箱配置

在mantis源文件文档里面,找到config目录下的config_inc.php文件
添加如下代码:

# ----- EMAIL CONFIGURATION -----
$g_administrator_email = 'dengyuanke@stepiot.com';
$g_webmaster_email  = 'dengyuanke@stepiot.com';
$g_from_email   = 'dengyuanke@stepiot.com';
$g_from_name   = '邓元柯';
$g_return_path_email = 'dengyuanke@stepiot.com';
$g_phpMailer_method  = PHPMAILER_METHOD_SMTP;
$g_use_phpMailer = ON; # 使用 PHPMailer 发送邮件
$g_smtp_host   = 'smtp.exmail.qq.com';
$g_smtp_username = 'dengyuanke@stepiot.com';
$g_smtp_password = 'e9G6rQQ5adEiX23T';
$g_smtp_port = 25;

注: $g_smtp_password为邮件设置生成的密码,不是邮箱的登录密码

  • 为了安全起见,使用rm -rf admin/删除mantis下的admin目录。
  • 禁止默认 'administrator' 帐号或修改其密码

4.0 完成