zoukankan      html  css  js  c++  java
  • ubuntu14安装mantis实践(包含LAMP/PHP)

    安装LAMP

    参考 https://www.linuxidc.com/Linux/2016-12/138757.htm

    sudo add-apt-repository ppa:ondrej/apache2
    sudo apt update

    apt-get -y install apache2 php mysql-server php-mysql libapache2-mod-php  lynx

    中间遇到错误,

    E:could not get lock /var/lib/dpkg/lock -open

      原因是:可能是有另外一个程序正在运行,导致资源被锁不可用。而导致资源被锁的原因,可能是上次安装时没正常完成,而导致出现此状况。

      解决办法是:

        sudo rm /var/cache/apt/archives/lock

        sudo rm /var/lib/dpkg/lock

      再重新安装即可成功。

    另一个错误,

    Set the 'ServerName' directive globally

    参考 https://www.jianshu.com/p/275b17d6a73e

      在/etc/apache2/apache2.conf中添加下面代码:
      ServerName localhost

    中间安装mysql-server迟迟不能完成,top一下,看到mysql正在运行,
    service mysql stop

    安装完毕。重启MySQL,Apache,命令是:

      sudo service mysql restart
      sudo service apache2 restart

    验证http服务,

    lynx localhost

    安装 mantis

    但参考:http://www.linuxdiyf.com/linux/29157.html

    另外安装,
    sudo apt-get install php-mbstring php-xml

    配置php时,/etc/php好几个版本,php -v确定当前版本是7.2

    在/etc/php/7.2/apache2/php.ini下查找 ";extension=mysqli.so"将前面的分号删除
    访问http://localhost/mantis/admin/install.php,完成配置即可(访问数据库的用户名需要跟安装mysql时配置的一致)

    安装完后,要重启apathe2,访问192.168.1.26/mantis/admin/install.php配置

    这时不知道mysl的用户名,密码,可以进入 /etc/mysql/debian.conf里去找,得知用户名:debian-sys-maint,密码 dST3vD6t5Rp9TmzH

    mysql -u debian-sys-maint -p

    进入。结果提示错误:Can't connect to local MySQL server through socket 

    尝试重启mysqld,折腾了一番: service mysqld restart or pkill mysqld 不知为啥就好了。

    mysql设置root密码

    现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!):
    方法一:
    # /etc/init.d/mysql stop
    # mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
    # mysql -u root mysql
    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
    mysql> FLUSH PRIVILEGES;
    mysql> quit

    # /etc/init.d/mysql restart
    # mysql -uroot -p
    Enter password: <输入新设的密码newpassword>

    mysql>


    方法二:
    直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
    # mysql -udebian-sys-maint -p
    Enter password: <输入[client]节的密码>
    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
    mysql> FLUSH PRIVILEGES;
    mysql> quit

    # mysql -uroot -p
    Enter password: <输入新设的密码newpassword>

    PHP和邮箱配置

    PHP配置类似于:

    记得配置php.ini中smtp选项

    [mail function]

    ; For Win32 only.

    ; http://php.net/smtp

    SMTP = smtp.163.com #此处需要配置邮箱smtp服务地址

    ; http://php.net/smtp-port

    smtp_port = 25

    邮箱配置:

    在/var/www/html/mantis/config/config_inc.php后添加:

    $g_phpMailer_method = PHPMAILER_METHOD_SMTP;
    $g_smtp_host = 'smtp.21cn.com';
    #$g_smtp_host = 'smtp.mxhichina.com';
    #$g_smtp_connection_mode = 'ssl';
    $g_smtp_port = 25;
    $g_smtp_username = 'tangxiaosheng@21cn.com';
    $g_smtp_password = 'xxxx';
    #$g_smtp_username = 'mantisadmin@estonecn.com';
    #$g_smtp_password = 'Mantis1234';
    $g_webmaster_email = 'mantisadmin@estonecn.com';
    $g_from_name = 'Mantis Bug Tracker';
    $g_from_email = 'tangxiaosheng@21cn.com'; #the "From: " field in emails
    $g_return_path_email = 'tangxiaosheng@21cn.com'; # the return address for bounced mail
    #$g_return_path_email = 'mantisadmin@estonecn.com'; # the return address for bounced mail
    $g_email_receive_own = OFF;


    $g_email_send_using_cronjob = ON;
    $g_enable_email_notification = ON;

    之前g_return_path_email = 'tangxiaosheng@21cn.com',填的是 ‘tangjian@estonecn.com’,后来改了以后就可以了。

    https://my.oschina.net/yyping/blog/89411 提到:
    $g_return_path_email = xxxxxx@souhu.com #将后面的邮件地址改为有效的地址,这一点非常重要,不然将无法正常发送激活注册的邮件.

    难道 tangjian@estonecn.com不被认为是有效的邮件地址?事实证明了这点,$g_return_path_email 和 $g_from_email 都不支持estonecn.com (阿里邮箱)。

    一遍用 delete from mantis_user_table where username = 'tangjian'; 从数据库里删东西,一边用tangjian这个用户名建新用户。

    确保 $g_return_path_email 和 $g_from_email 不用阿里邮箱,仅仅是$g_smtp_username用阿里邮箱,发现也不行。

    修改完config_inc.config后,不用重启apache2服务。

    用这个sql语句:
    select * from mantis_email_table; 

    可以查询那些邮件没有发出去,一般是空的,因为已经在发送的路上了。如果非空,一般发送回失败。

    用命令: php /var/www/html/mantis/scripts/send_emails.php 可以看到发送失败的原因。如果成功,一般就显示:

    Sending emails...
    Done.

    解决Mantis无法发送邮件的问题 这个的价值挺高,之前没有设置 $g_email_send_using_cronjob = ON; 导致其它都设置合理的情况下,邮件发不出去。
    但是仅仅把这个设为ON,接收邮件速度还是慢了些。

    中间还发现经过管理员设置后,用administrator:root无法登陆。那么重新来,按照 h

    按照 centos7.3 安装mantis ,重新建立数据库bugtracker,

    >create database bugtracker;

    >grant all privileges on bugtracker.* to admin@localhost identified by 'yishi';

    >flush privileges;

    等等操作。

    mantis发送邮件的原理:定时任务中的send_emails.php,会读取数据库的邮件队列表mantis_email_table.获取发送的列表后,依次按照ID的升序发送,发送完毕后清空。等待下次队列,周而复始。

    可以把 */1 * * * *   root php /var/www/html/mantis/scripts/send_emails.php >/dev/null 加入到/etc/crontab,每分钟都尝试发一次邮件。

    提交时超慢的原因和解决办法: 

    解决方案:
    发送表 mantis_email_table中的邮件 ,并及时清理。
    检查函数email_send() 中邮件发送和邮件删除功能是否正常,步骤是否都一一走完。

    我的体验是,对于总是失败的邮件,可以在表中进行删除。

    有人提议:

    无法发送邮件,而又不知道如何解决的问题,可以通过以下方法进行调试:

    增加调试语句,在文件/core/email_api.php的1032行,增加调试语句:var_dump(LOG_EMAIL);var_dump($t_log_msg . $mail->ErrorInfo);

    我加了这个语句。不知道之前发送后打印的错误信息,是否和我加了这个语句有关。

    提示不允许使用免费邮件地址

    APPLICATION ERROR #1201
    It is not allowed to use disposable e-mail addresses.

    询问开发者得知,程序中使用了DisposableEmailChecker的插件,用于检测一次性邮箱地址的域。

    解决方法为,将
    /var/www/html/mantis/vendor/vboctor/disposable_email_checker/data/domains.txt

    文件中 qq.com 从文件中移除取可。目前已经处理了21cn,yeah, sohu, qq邮箱。

  • 相关阅读:
    10.31JS日记
    10.24JS日记
    10.23JS日记
    10.22JS日记
    10.19JS日记
    10.18JS日记
    Tomcat—Bad Request
    2016年上半年总结
    线程间操作无效
    压缩字符串的函数
  • 原文地址:https://www.cnblogs.com/tangxiaosheng/p/10299496.html
Copyright © 2011-2022 走看看