如题

用 nginx1.14.0 运行 Discuz,网页响应非常慢

环境

  1. windows 10 中文企业版
  2. web 服务器:nginx1.14.0
  3. PHP 版本:php-7.2.6-nts-Win32-VC15-x64(Non Thread Safe)
    环境搭建,请参考我的另外一篇文章:在 win10 下配置 nginx1.14.0 + PHP7.2.6

“症状”,卡顿严重

  1. UCenter,【应用列表】,第一个应用,检测通信,提示【正在连接…】很久,甚至是一直这样,第二个应用会等第一个应用检查结束再检查,第二个应用就表现成一直没有检测。
  2. 进入管理中心,验证码没有出来,要刷新很多次才能看到有验证码。
  3. 网页切换非常慢,响应速度不能容忍。

运行遇到的问题

1
Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in C:\workspace\DiscuzX\upload\source\class\class_core.php on line 27

解决:
打开 C:\workspace\DiscuzX\upload\source\class\class_core.php
将 24 行开始的代码:

1
2
3
4
5
6
7
if(function_exists('spl_autoload_register')) {
spl_autoload_register(array('core', 'autoload'));
} else {
function __autoload($class) {
return core::autoload($class);
}
}

改为:

1
2
3
4
5
6
7
8
if(function_exists('spl_autoload_register')) {
spl_autoload_register(array('core', 'autoload'));
}
//else {
// function __autoload($class) {
// return core::autoload($class);
// }
//}

就是把 else 部分删除即可。

尝试解决网页响应慢的问题

起初以为是 php 版本在 windows 上有问题,换成 PHP7.0.30、PHP5.6.36,还是一样。
应该是 nginx 对 windows 的支持不如对 unix 系列支持的好,对 socket 的支持比较差。在 CentOS7.5 上,同样是 nginx1.14.0 + PHP7.2.6 + Discuz! X3.4,运行良好,速度很快。

将 nginx1.14.0 换成 Apache2.4.33,网页响应非常快

环境

  1. windows 10 中文企业版
  2. web 服务器:Apache2.4.33
  3. PHP 版本:php-7.2.6-Win32-VC15-x64(Thread Safe)
    环境搭建,请参考我的另外一篇文章:在 win10 下配置 Apache2.4.33 + PHP 7.2.6

以上环境配置好这后,网页响应速度终于正常了,图片验证码也正常了,通信检测也快了…,那叫一个爽呀,终于可以用 PHPStorm 调试了。

安装界面对运行环境的检查结果,如下图所示:
【环境检查】部分


【目录、文件权限检查】、【函数依赖检查】部分

系统邮箱设置

windows 下和 CentOS7.5 下用相同的配置,均可发送测试邮件。
SMTP 服务器 必须使用:ssl://前缀

密码、邮箱修改

uc_server\model\user.php 下的 函数:edit_user

  1. 找回密码:通过邮箱找回,会修改密码,会传用户名、密码、邮箱。
  2. 修改密码,只会传用户名和密码。
  3. 邮箱验证,只会传用户名和邮箱。

修改时,接收的参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
C:\workspace\php\dzt\uc_server\control\user.php

function onedit() {
$this->init_input();
$username = $this->input('username');
$oldpw = $this->input('oldpw');
$newpw = $this->input('newpw');
$email = $this->input('email');
$ignoreoldpw = $this->input('ignoreoldpw');
$questionid = $this->input('questionid');
$answer = $this->input('answer');
$newUsername = $this->input('newUsername');

if(!$ignoreoldpw && $email && ($status = $this->_check_email($email, $username)) < 0) {
return $status;
}
$status = $_ENV['user']->edit_user($username, $oldpw, $newpw, $email, $ignoreoldpw, $questionid, $answer, $newUsername);

if($newpw && $status > 0) {
$this->load('note');
$_ENV['note']->add('updatepw', 'username='.urlencode($username).'&password=');
$_ENV['note']->send();
}
return $status;
}

修改网站,在浏览器 tab 上的 logo

在网站根目录,将文件 favicon.ico 替换成自己的即可。