Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问是否支持php8?百度贴吧云签到 V5.00 (PHP 8.2.7) 在工作时发生致命的异常 消息:#0 - Undefined constant "EMAIL" #255

Closed
2 tasks done
Weltolk opened this issue Nov 12, 2023 · 28 comments
Labels

Comments

@Weltolk
Copy link
Contributor

Weltolk commented Nov 12, 2023

  • 我已升级贴吧云签到到最新版本,并且运行了升级脚本
  • 我已搜索过 Issue 区,没有找到相关问题

问题描述

升级debian版本到12后,php-fpm版本从7.4升级到了php8,升级之前是能正常用的,升级之后访问首页报错,看了README.md和issue,没找到关于版本的讨论,自己debug了一下,没搞明白

文件 代码
/var/www/tieba/lib/sfc.functions.php 178 [抛出异常]
/var/www/tieba/templates/index.php 14 getGravatar
/var/www/tieba/lib/ui.php 95 include
/var/www/tieba/templates/control.php 96 template
/var/www/tieba/lib/ui.php 95 include
/var/www/tieba/index.php 14 template

复现步骤

使用php-fpm8搭建,访问首页
我看lib/globals.php定义EMAIL时,是在有cookie有登录信息的时候才会调用,而报错点是访问首页返回头像的时候调用了这个变量,即使改成不用EMAIL,其他地方又会报错ISVIP未定义,应该确实是版本问题?这样的话是否只能用docker来快速解决这个问题?

环境

  • 云签到版本:v5.00,git clone的,最近2天的commit之前和之后的版本都会这样
  • 服务器系统和版本:Linux server0 5.10.0-25-arm64 #1 SMP Debian 5.10.191-1 (2023-08-16) aarch64 GNU/Linux debian12.2
  • 云签到是否在 Docker 中运行:否
  • PHP 版本:
PHP 8.2.7 (fpm-fcgi) (built: Jun  9 2023 19:37:27)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies
    with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans
  • MySQL 版本:mysql Ver 15.1 Distrib 10.11.5-MariaDB, for debian-linux-gnu (aarch64) using EditLine wrapper
@BANKA2017
Copy link
Collaborator

我在用 PHP8.2,没法复现问题。

常量 EMAILcookie 校验后才会定义的,没有那就意味着前面的校验出了问题,你提到的ISVIP未定义也是这个原因造成的,你可以检查一下下面这一行的前面哪部分出了问题

define('EMAIL', $p['email']);

@Weltolk
Copy link
Contributor Author

Weltolk commented Nov 12, 2023

我在用 PHP8.2,没法复现问题。

常量 EMAILcookie 校验后才会定义的,没有那就意味着前面的校验出了问题,你提到的ISVIP未定义也是这个原因造成的,你可以检查一下下面这一行的前面哪部分出了问题

define('EMAIL', $p['email']);

我是未登录状态,我看了前面的代码并测试了,第一层if就没进去:

if (isset($_COOKIE['uid']) && isset($_COOKIE['pwd'])) {

而貌似setcookie是在进去之后才设置的?

@BANKA2017
Copy link
Collaborator

理论上鉴权都没过不应该会调用到 getGravatar,而是跳到登录页

} elseif (!defined('UID') && !defined('SYSTEM_DO_NOT_LOGIN')) {
define('ROLE', 'visitor');
$i['user']['role'] = 'visitor';
ReDirect('index.php?mod=login');
}

所以我不太能理解为什么会出现这个问题

@Weltolk
Copy link
Contributor Author

Weltolk commented Nov 13, 2023

理论上鉴权都没过不应该会调用到 getGravatar,而是跳到登录页

} elseif (!defined('UID') && !defined('SYSTEM_DO_NOT_LOGIN')) {
define('ROLE', 'visitor');
$i['user']['role'] = 'visitor';
ReDirect('index.php?mod=login');
}

所以我不太能理解为什么会出现这个问题

debug半天还是不懂,目前确定的是走了login分支,template("login")加载了,但是不知道为什么又跳转到template("index")了

} elseif (SYSTEM_PAGE == 'login') {

@Weltolk
Copy link
Contributor Author

Weltolk commented Feb 22, 2024

理论上鉴权都没过不应该会调用到 getGravatar,而是跳到登录页

} elseif (!defined('UID') && !defined('SYSTEM_DO_NOT_LOGIN')) {
define('ROLE', 'visitor');
$i['user']['role'] = 'visitor';
ReDirect('index.php?mod=login');
}

所以我不太能理解为什么会出现这个问题

有任何进展吗?我这里这个环境还是存在这个问题

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 17, 2024

理论上鉴权都没过不应该会调用到 getGravatar,而是跳到登录页

} elseif (!defined('UID') && !defined('SYSTEM_DO_NOT_LOGIN')) {
define('ROLE', 'visitor');
$i['user']['role'] = 'visitor';
ReDirect('index.php?mod=login');
}

所以我不太能理解为什么会出现这个问题

崩溃了, 今天重装了vps的系统, 从debian到ubuntu 22.04, php从8.2到8.1, 依旧报一样的错

百度贴吧云签到 V5.00 (PHP 8.1.2-1ubuntu2.14) 在工作时发生致命的异常 @ 2024-03-17 22:20:05
消息:#0 - Undefined constant "EMAIL"

文件 | 行 | 代码 -- | -- | -- /var/www/tieba/lib/sfc.functions.php | 178 | [抛出异常] /var/www/tieba/templates/index.php | 14 | getGravatar /var/www/tieba/lib/ui.php | 95 | include /var/www/tieba/templates/control.php | 96 | template /var/www/tieba/lib/ui.php | 95 | include /var/www/tieba/index.php | 14 | template

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 17, 2024

我在用 PHP8.2,没法复现问题。

常量 EMAILcookie 校验后才会定义的,没有那就意味着前面的校验出了问题,你提到的ISVIP未定义也是这个原因造成的,你可以检查一下下面这一行的前面哪部分出了问题

define('EMAIL', $p['email']);

你是什么系统?难道是cpu的问题?我vps是arm64的cpu

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

我原本用的是cloudflare zero trust的tunnel进行访问,刚刚尝试了直接通过ip访问,也是一样的报错,git clone的最新的代码,数据库删了重建的

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

从代码逻辑看是不可能报这个错的,希望有人解惑

@n0099
Copy link
Collaborator

n0099 commented Mar 21, 2024

cat /etc/php/8.2/{fpm,cli}/php.ini

@Weltolk

This comment was marked as resolved.

@Weltolk

This comment was marked as resolved.

@Weltolk

This comment was marked as resolved.

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

/etc/mysql/conf.d/mysql.cnf:

[mysql]


[mysqld]
innodb_buffer_pool_size=12G
secure_file_priv=""
bind-address=127.0.0.1

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

相关的日志:

mariadb在安装的第4步,也就是填写数据库相关信息之后,会有个报错,但是实际上安装提示成功了,查看数据库里,表也都创建了

nginx/error.log有报错

nginx/access.log:

127.0.0.1 - - [21/Mar/2024:17:50:31 +0800] "GET / HTTP/1.1" 200 1657 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/index.php
127.0.0.1 - - [21/Mar/2024:17:50:32 +0800] "GET /setup/install.php HTTP/1.1" 200 1362 "https://xxxx.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/setup/install.php
127.0.0.1 - - [21/Mar/2024:17:50:34 +0800] "GET /setup/install.php?step=1 HTTP/1.1" 200 1992 "https://xxxx.com/setup/install.php" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/setup/install.php
127.0.0.1 - - [21/Mar/2024:17:50:36 +0800] "GET /setup/install.php?step=2 HTTP/1.1" 200 1078 "https://xxxx.com/setup/install.php?step=1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/setup/install.php
127.0.0.1 - - [21/Mar/2024:17:50:43 +0800] "GET /setup/install.php?step=3 HTTP/1.1" 200 1633 "https://xxxx.com/setup/install.php?step=2" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/setup/install.php
127.0.0.1 - - [21/Mar/2024:17:51:00 +0800] "POST /setup/install.php?step=4 HTTP/1.1" 200 1960 "https://xxxx.com/setup/install.php?step=3" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/setup/install.php
127.0.0.1 - - [21/Mar/2024:17:51:08 +0800] "POST /setup/install.php?step=4 HTTP/1.1" 200 993 "https://xxxx.com/setup/install.php?step=3" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/setup/install.php
127.0.0.1 - - [21/Mar/2024:17:51:09 +0800] "GET /setup/install.php?step=5 HTTP/1.1" 200 1406 "https://xxxx.com/setup/install.php?step=4" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/setup/install.php
127.0.0.1 - - [21/Mar/2024:17:51:14 +0800] "GET /index.php HTTP/1.1" 302 5188 "https://xxxx.comp/setup/install.php?step=5" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/index.php
127.0.0.1 - - [21/Mar/2024:17:51:15 +0800] "GET /index.php?mod=login HTTP/1.1" 200 1749 "https://xxxx.com/setup/install.php?step=5" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "x.x.x.x" /var/www/tieba/index.php

nginx/error.log:

2024/03/21 17:50:31 [error] 383183#383183: *15 FastCGI sent in stderr: "PHP message: PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/tieba/lib/msg.php:26) in /var/www/tieba/init.php on line 41PHP message: PHP Fatal error:  Uncaught mysqli_sql_exception: Table 'tiebacloud.tc_options' doesn't exist in /var/www/tieba/lib/class.mysqli.php:119
Stack trace:
#0 /var/www/tieba/lib/class.mysqli.php(119): mysqli->query()
#1 /var/www/tieba/lib/reg.php(25): wmysql->query()
#2 /var/www/tieba/init.php(53): require('...')
#3 /var/www/tieba/index.php(10): require('...')
#4 {main}
  thrown in /var/www/tieba/lib/class.mysqli.php on line 119" while reading upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "xxxx.com"
2024/03/21 17:51:00 [error] 383183#383183: *15 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function query() on null in /var/www/tieba/lib/class.mysqli.php:119
Stack trace:
#0 /var/www/tieba/setup/install.php(183): wmysql->query()
#1 {main}
  thrown in /var/www/tieba/lib/class.mysqli.php on line 119" while reading upstream, client: 127.0.0.1, server: , request: "POST /setup/install.php?step=4 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "xxxx.com", referrer: "https://xxxx.com/setup/install.php?step=3"

php log:

- -  21/Mar/2024:17:50:31 +0800 "GET /index.php" 200 /var/www/tieba/index.php 11.268 2048 0.00%
- -  21/Mar/2024:17:50:32 +0800 "GET /setup/install.php" 200 /var/www/tieba/setup/install.php 0.306 2048 0.00%
- -  21/Mar/2024:17:50:34 +0800 "GET /setup/install.php?step=1" 200 /var/www/tieba/setup/install.php 0.271 2048 0.00%
- -  21/Mar/2024:17:50:36 +0800 "GET /setup/install.php?step=2" 200 /var/www/tieba/setup/install.php 0.225 2048 0.00%
- -  21/Mar/2024:17:50:43 +0800 "GET /setup/install.php?step=3" 200 /var/www/tieba/setup/install.php 0.258 2048 0.00%
- -  21/Mar/2024:17:51:00 +0800 "POST /setup/install.php?step=4" 200 /var/www/tieba/setup/install.php 21.243 2048 0.00%
- -  21/Mar/2024:17:51:08 +0800 "POST /setup/install.php?step=4" 200 /var/www/tieba/setup/install.php 2.700 2048 0.00%
- -  21/Mar/2024:17:51:09 +0800 "GET /setup/install.php?step=5" 200 /var/www/tieba/setup/install.php 0.309 2048 0.00%
- -  21/Mar/2024:17:51:14 +0800 "GET /index.php" 302 /var/www/tieba/index.php 10.494 2048 95.29%
- -  21/Mar/2024:17:51:15 +0800 "GET /index.php?mod=login" 200 /var/www/tieba/index.php 1.960 2048 0.00%

mariadb log:

Mar 21 17:51:08 server0 mariadbd[328140]: 2024-03-21 17:51:08 120 [Warning] Aborted connection 120 to db: 'tiebacloud' user: 'root' host: 'localhost' (Unknown error)
MariaDB [tiebacloud]> show tables;
+----------------------+
| Tables_in_tiebacloud |
+----------------------+
| tc_baiduid           |
| tc_cron              |
| tc_options           |
| tc_plugins           |
| tc_tieba             |
| tc_users             |
| tc_users_options     |
+----------------------+
7 rows in set (0.000 sec)

@n0099
Copy link
Collaborator

n0099 commented Mar 21, 2024

#255 (comment)

源里默认的php8的版本是8.1了

大脑升级php83,请 https://launchpad.net/~ondrej/+archive/ubuntu/php

short_open_tag = Off

开,请 https://github.com/search?q=repo%3AMoeNetwork%2FTieba-Cloud-Sign+%3C%3F%3D&type=code
https://www.php.net/manual/en/ini.core.php#ini.short-open-tag

This directive does not affect the shorthand <?=, which is always available.

$ grep -rP '<\?(?!php|=)'
grep: source/doc/baiduid.png: binary file matches
grep: source/fonts/captcha.ttf: binary file matches
grep: source/fonts/glyphicons-halflings-regular.woff: binary file matches
grep: source/fonts/glyphicons-halflings-regular.woff2: binary file matches
source/fonts/glyphicons-halflings-regular.svg:<?xml version="1.0" standalone="no
grep: source/fonts/glyphicons-halflings-regular.eot: binary file matches

;open_basedir =
disable_functions =

建议设置

allow_url_fopen = On

关,请

@n0099
Copy link
Collaborator

n0099 commented Mar 21, 2024

#255 (comment)

[PHP Modules]
amqp
apcu
ast
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ds
enchant
exif
FFI
fileinfo
filter
ftp
gd
gearman
gettext
gmp
gnupg
hash
http
iconv
igbinary
imagick
imap
intl
json
ldap
libxml
mbstring
memcache
memcached
mongodb
msgpack
mysqli
mysqlnd
OAuth
odbc
openssl
pcntl
pcov
pcre
PDO
pdo_dblib
PDO_Firebird
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
ps
pspell
psr
raphf
readline
redis
Reflection
rrd
session
shmop
SimpleXML
snmp
soap
sockets
sodium
solr
SPL
sqlite3
ssh2
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
uopz
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

为什么要装这么多?

@n0099
Copy link
Collaborator

n0099 commented Mar 21, 2024

#255 (comment)

[tieba]

为什么改默认的[www]pool名?

pm = ondemand

您内存很少吗?
然而innodb_buffer_pool_size=12G

server {
    listen 127.0.0.1:8881;
-    listen [::1}:8881;
+    listen [::1]:8881;

-    location / {
-        root /var/www/tieba;
+    root   /var/www/tieba;
-        index index.html index.htm index.php;
+    index  index.php index.html;
-    }

-    location ~ \.php$ {
+    # https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/
+    location ~ [^/]\.php(/|$) {
-        root /var/www/tieba;
+        fastcgi_split_path_info  ^(.+?\.php)(/.*)$;
+
+        # https://serverfault.com/questions/627903/is-the-php-option-cgi-fix-pathinfo-really-dangerous-with-nginx-php-fpm
+        if (!-f $request_filename) {
+            return 404;
+        }
+        try_files $uri =404;
+    
+        # Mitigate https://httpoxy.org/ vulnerabilities
+        fastcgi_param  HTTP_PROXY "";
+
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
-        # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
-        # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
+        # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#use-request-filename-for-script-filename
+        fastcgi_param  SCRIPT_FILENAME $request_filename;
+        # https://serverfault.com/questions/465607/nginx-document-rootfastcgi-script-name-vs-request-filename
+        # fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    }
}

@n0099
Copy link
Collaborator

n0099 commented Mar 21, 2024

#255 (comment)

secure_file_priv=""

为什么? https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_secure_file_priv 用完了LOAD DATA就应该重置

@n0099
Copy link
Collaborator

n0099 commented Mar 21, 2024

#255 (comment)

2024/03/21 17:50:31 [error] 383183#383183: *15 FastCGI sent in stderr: "PHP message: PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/tieba/lib/msg.php:26) in /var/www/tieba/init.php on line 41PHP message: PHP Fatal error:  Uncaught mysqli_sql_exception: Table 'tiebacloud.tc_options' doesn't exist in /var/www/tieba/lib/class.mysqli.php:119
Stack trace:
#0 /var/www/tieba/lib/class.mysqli.php(119): mysqli->query()
#1 /var/www/tieba/lib/reg.php(25): wmysql->query()
#2 /var/www/tieba/init.php(53): require('...')
#3 /var/www/tieba/index.php(10): require('...')
#4 {main}
  thrown in /var/www/tieba/lib/class.mysqli.php on line 119" while reading upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "xxxx.com"

$this->result = $this->conn->query($sql);

$ws = $m->query("SELECT * FROM " . DB_PREFIX . "options");

$i['db']['prefix'] = DB_PREFIX;

define('DB_PREFIX', 'tc_');

require SYSTEM_ROOT . '/config.php';
require SYSTEM_ROOT . '/lib/mysql_autoload.php';
require SYSTEM_ROOT . '/lib/class.former.php';
require SYSTEM_ROOT . '/lib/class.smtp.php';
require SYSTEM_ROOT . '/lib/class.zip.php';
require SYSTEM_ROOT . '/lib/reg.php';

require dirname(__FILE__) . '/init.php';

所以config.php在那一瞬是空文件(文件不存在require会报E_COMPILE_ERROR )?

2024/03/21 17:51:00 [error] 383183#383183: *15 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function query() on null in /var/www/tieba/lib/class.mysqli.php:119
Stack trace:
#0 /var/www/tieba/setup/install.php(183): wmysql->query()
#1 {main}
  thrown in /var/www/tieba/lib/class.mysqli.php on line 119" while reading upstream, client: 127.0.0.1, server: , request: "POST /setup/install.php?step=4 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "xxxx.com", referrer: "https://xxxx.com/setup/install.php?step=3"

$testInstall = $m->fetch_row($m->query("SHOW TABLES LIKE '" . DB_PREFIX . "users'"));

$m = new S(DB_HOST, DB_USER, DB_PASSWD, DB_NAME, LONGSQL); //以后直接使用$m->函数()即可操作数据库

class S extends wmysql

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

#255 (comment)

源里默认的php8的版本是8.1了

大脑升级php83,请 https://launchpad.net/~ondrej/+archive/ubuntu/php

short_open_tag = Off

开,请 https://github.com/search?q=repo%3AMoeNetwork%2FTieba-Cloud-Sign+%3C%3F%3D&type=code https://www.php.net/manual/en/ini.core.php#ini.short-open-tag

This directive does not affect the shorthand <?=, which is always available.

$ grep -rP '<\?(?!php|=)'
grep: source/doc/baiduid.png: binary file matches
grep: source/fonts/captcha.ttf: binary file matches
grep: source/fonts/glyphicons-halflings-regular.woff: binary file matches
grep: source/fonts/glyphicons-halflings-regular.woff2: binary file matches
source/fonts/glyphicons-halflings-regular.svg:<?xml version="1.0" standalone="no
grep: source/fonts/glyphicons-halflings-regular.eot: binary file matches

;open_basedir =
disable_functions =

建议设置

allow_url_fopen = On

关,请

8.3会可用吗(

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

#255 (comment)

[PHP Modules]
amqp
apcu
ast
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ds
enchant
exif
FFI
fileinfo
filter
ftp
gd
gearman
gettext
gmp
gnupg
hash
http
iconv
igbinary
imagick
imap
intl
json
ldap
libxml
mbstring
memcache
memcached
mongodb
msgpack
mysqli
mysqlnd
OAuth
odbc
openssl
pcntl
pcov
pcre
PDO
pdo_dblib
PDO_Firebird
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
ps
pspell
psr
raphf
readline
redis
Reflection
rrd
session
shmop
SimpleXML
snmp
soap
sockets
sodium
solr
SPL
sqlite3
ssh2
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
uopz
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

为什么要装这么多?

怕万一用到什么的,就装了一堆(

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

#255 (comment)

[tieba]

为什么改默认的[www]pool名?

pm = ondemand

您内存很少吗? 然而innodb_buffer_pool_size=12G

server {
    listen 127.0.0.1:8881;
-    listen [::1}:8881;
+    listen [::1]:8881;

-    location / {
-        root /var/www/tieba;
+    root   /var/www/tieba;
-        index index.html index.htm index.php;
+    index  index.php index.html;
-    }

-    location ~ \.php$ {
+    # https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/
+    location ~ [^/]\.php(/|$) {
-        root /var/www/tieba;
+        fastcgi_split_path_info  ^(.+?\.php)(/.*)$;
+
+        # https://serverfault.com/questions/627903/is-the-php-option-cgi-fix-pathinfo-really-dangerous-with-nginx-php-fpm
+        if (!-f $request_filename) {
+            return 404;
+        }
+        try_files $uri =404;
+    
+        # Mitigate https://httpoxy.org/ vulnerabilities
+        fastcgi_param  HTTP_PROXY "";
+
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
-        # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
-        # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
+        # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#use-request-filename-for-script-filename
+        fastcgi_param  SCRIPT_FILENAME $request_filename;
+        # https://serverfault.com/questions/465607/nginx-document-rootfastcgi-script-name-vs-request-filename
+        # fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    }
}

因为有一个[www],一共2个php套接字(

我看注释貌似ondemand更合理一些?空闲的时候就杀死进程

nginx好复杂(

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

#255 (comment)

secure_file_priv=""

为什么? https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_secure_file_priv 用完了LOAD DATA就应该重置

我记得这项是因为好久之前在网上看到,这一项设置为空可以阻止sql写文件,提高安全性(原来现在为空是无效的了,要写NULL

@Weltolk
Copy link
Contributor Author

Weltolk commented Mar 21, 2024

#255 (comment)

2024/03/21 17:50:31 [error] 383183#383183: *15 FastCGI sent in stderr: "PHP message: PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/tieba/lib/msg.php:26) in /var/www/tieba/init.php on line 41PHP message: PHP Fatal error:  Uncaught mysqli_sql_exception: Table 'tiebacloud.tc_options' doesn't exist in /var/www/tieba/lib/class.mysqli.php:119
Stack trace:
#0 /var/www/tieba/lib/class.mysqli.php(119): mysqli->query()
#1 /var/www/tieba/lib/reg.php(25): wmysql->query()
#2 /var/www/tieba/init.php(53): require('...')
#3 /var/www/tieba/index.php(10): require('...')
#4 {main}
  thrown in /var/www/tieba/lib/class.mysqli.php on line 119" while reading upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "xxxx.com"

$this->result = $this->conn->query($sql);

$ws = $m->query("SELECT * FROM " . DB_PREFIX . "options");

$i['db']['prefix'] = DB_PREFIX;

define('DB_PREFIX', 'tc_');

require SYSTEM_ROOT . '/config.php';
require SYSTEM_ROOT . '/lib/mysql_autoload.php';
require SYSTEM_ROOT . '/lib/class.former.php';
require SYSTEM_ROOT . '/lib/class.smtp.php';
require SYSTEM_ROOT . '/lib/class.zip.php';
require SYSTEM_ROOT . '/lib/reg.php';

require dirname(__FILE__) . '/init.php';

所以config.php在那一瞬是空文件(文件不存在require会报E_COMPILE_ERROR )?

2024/03/21 17:51:00 [error] 383183#383183: *15 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function query() on null in /var/www/tieba/lib/class.mysqli.php:119
Stack trace:
#0 /var/www/tieba/setup/install.php(183): wmysql->query()
#1 {main}
  thrown in /var/www/tieba/lib/class.mysqli.php on line 119" while reading upstream, client: 127.0.0.1, server: , request: "POST /setup/install.php?step=4 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "xxxx.com", referrer: "https://xxxx.com/setup/install.php?step=3"

$testInstall = $m->fetch_row($m->query("SHOW TABLES LIKE '" . DB_PREFIX . "users'"));

$m = new S(DB_HOST, DB_USER, DB_PASSWD, DB_NAME, LONGSQL); //以后直接使用$m->函数()即可操作数据库

class S extends wmysql

所以这报错是正常的?

@n0099
Copy link
Collaborator

n0099 commented Mar 21, 2024

8.3会可用吗(

我就在用

怕万一用到什么的,就装了一堆(

建议全部卸载只装tc用到的

因为有一个[www],一共2个php套接字(

那为什么不用默认的[www]pool?

我看注释貌似ondemand更合理一些?空闲的时候就杀死进程

但启动新phpfpm进程慢,pm.start_servers = 2也就是说在phpfpm启动后立即有2个并行请求(现实中更可能是没有请求于是10s后这两个start_servers也被kill)打进来后续请求就得等创建新phpfpm进程并且在请求完成pm.process_idle_timeout = 10s后就立即kill使得下次后续请求仍然要等疑似梦回win下只能用的phpcgi完全JIT地创建进程(相当于pm=ondemand; pm.start_servers=0; pm.process_idle_timeout=0;),而pm = dynamic会让phpfpm进程在创建后sleep下去除非所有进程数量超过了pm.max_children

nginx好复杂(

您不在乎安全性也大可直接无脑一行include fastcgi_params;

我记得这项是因为好久之前在网上看到,这一项设置为空可以阻止sql写文件,提高安全性(原来现在为空是无效的了,要写NULL

5.7也是一样的 https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_secure_file_priv 估计是分不清NULL""emptystr,建议直接删掉使用.deb打包默认的/var/lib/mysql-files

所以这报错是正常的?

所以config.php在那一瞬是空文件

@Weltolk
Copy link
Contributor Author

Weltolk commented May 25, 2024

8.3会可用吗(

我就在用

怕万一用到什么的,就装了一堆(

建议全部卸载只装tc用到的

因为有一个[www],一共2个php套接字(

那为什么不用默认的[www]pool?

我看注释貌似ondemand更合理一些?空闲的时候就杀死进程

但启动新phpfpm进程慢,pm.start_servers = 2也就是说在phpfpm启动后立即有2个并行请求(现实中更可能是没有请求于是10s后这两个start_servers也被kill)打进来后续请求就得等创建新phpfpm进程并且在请求完成pm.process_idle_timeout = 10s后就立即kill使得下次后续请求仍然要等疑似梦回win下只能用的phpcgi完全JIT地创建进程(相当于pm=ondemand; pm.start_servers=0; pm.process_idle_timeout=0;),而pm = dynamic会让phpfpm进程在创建后sleep下去除非所有进程数量超过了pm.max_children

nginx好复杂(

您不在乎安全性也大可直接无脑一行include fastcgi_params;

我记得这项是因为好久之前在网上看到,这一项设置为空可以阻止sql写文件,提高安全性(原来现在为空是无效的了,要写NULL

5.7也是一样的 https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_secure_file_priv 估计是分不清NULL""emptystr,建议直接删掉使用.deb打包默认的/var/lib/mysql-files

所以这报错是正常的?

所以config.php在那一瞬是空文件

thanks, 已解决

@Weltolk
Copy link
Contributor Author

Weltolk commented May 25, 2024

8.3会可用吗(

我就在用

怕万一用到什么的,就装了一堆(

建议全部卸载只装tc用到的

因为有一个[www],一共2个php套接字(

那为什么不用默认的[www]pool?

我看注释貌似ondemand更合理一些?空闲的时候就杀死进程

但启动新phpfpm进程慢,pm.start_servers = 2也就是说在phpfpm启动后立即有2个并行请求(现实中更可能是没有请求于是10s后这两个start_servers也被kill)打进来后续请求就得等创建新phpfpm进程并且在请求完成pm.process_idle_timeout = 10s后就立即kill使得下次后续请求仍然要等疑似梦回win下只能用的phpcgi完全JIT地创建进程(相当于pm=ondemand; pm.start_servers=0; pm.process_idle_timeout=0;),而pm = dynamic会让phpfpm进程在创建后sleep下去除非所有进程数量超过了pm.max_children

nginx好复杂(

您不在乎安全性也大可直接无脑一行include fastcgi_params;

我记得这项是因为好久之前在网上看到,这一项设置为空可以阻止sql写文件,提高安全性(原来现在为空是无效的了,要写NULL

5.7也是一样的 https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_secure_file_priv 估计是分不清NULL""emptystr,建议直接删掉使用.deb打包默认的/var/lib/mysql-files

所以这报错是正常的?

所以config.php在那一瞬是空文件

apt安装的各种php8.1-*模块删了, 只安装php-mysql, 就可以访问了

@Weltolk Weltolk closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants