phphub安装(搭建)教程及遇到的问题解决


安装前言

这里不再讲解基本的安装方法,请按照官方的Github文档进行操作,推荐在Contos64/lnmp集成环境下搭建,一定要细心不要错过任何一步,也不要放弃,
感谢那些帮助过我的朋友,这里我汇总一下常见的一些问题。

composer install走不下去

主要原因是官方的packagist其中的composer项目在github中被删除,请自行在composer.json替换为

"repositories": {
    "packagist": {
      "type": "composer",
      "url": "https://packagist.phpcomposer.com"
    }
  }

数据库报错

第一个错:

QueryException in Connection.php line 662:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'phpone.topics' doesn't exist (SQL: select count(*) as aggregate from `topics` where `topics`.`deleted_at` is null and `is_blocked` = no and `is_excellent` = yes)
PDOException in Connection.php line 319:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'phpone.topics' doesn't exist

不知道是不是phphub的BUG,安装完后提示没有这两个表,自行添加这两个表或者删除phphub数据里所有的表,然后重新安装即可

第二个错:

[Illuminate\Database\QueryException]                                                                                                                                                                                         
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `revisions` add index `revisions_revisionable_id_revisionable_type_index`(`revisionable_  
  id`, `revisionable_type`))   
  [PDOException]                                                                                                    
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes  

这里要注意mysq必须是5.7+,l必须使用inndb引擎,你使用lnmp集成环境在安装时会提示你选择哪种引擎

phphub无法发送邮寄

很多人出了这个问题,打字很累了,大家跟着我一起改代码吧先

app/Phphub/Handler/EmailHandler.php 里的 sendActivateMail方法改成

 public function sendActivateMail(User $user)
  {
      UserVerification::generate($user);
      $token = $user->verification_token;

     return Mail::raw(url('verification', $user->verification_token).'?email='.urlencode($user->email), function (Message $m) use ($user,$token) {
          $m->to($user->email)->subject(lang('Please verify your email address'));
      });

然后安装supervisor

sudo apt-get install supervisor

安装完了,看到 /etc/supervisor/supervisor.conf 里的最后一行

[include] files = /etc/supervisor/conf.d/*.conf

然后直接在 conf.d 文件下新建一个sendMail.conf

[program:waaQueue]
command                 = php artisan queue:work
directory               = (此行是你的项目绝对路径)/data/wwwroot/myself/phphub5/
process_name            = %(program_name)s_%(process_num)s
numprocs                = 6
autostart               = true
autorestart             = true
stdout_logfile          = (修改为你要的log地址)/data/wwwroot/myself/phphub5/storage/logs/supervisor_waaQueue.log
stdout_logfile_maxbytes = 10MB
stderr_logfile          = (修改为你要的log地址)/data/wwwroot/myself/phphub5/storage/logs/supervisor_wqqQueue.log
stderr_logfile_maxbytes = 10MB

执行

sudo chmod -R 777 /var/log/supervisor/supervisord.log
sudo chmod 777 /run

然后在执行

supervisord

这里会报一个错,但是的确收到邮件了,你可以自行测试一下,这里要感谢叶落山城秋博主,还有什么要补充的,希望大家提示我