年更系列,又开始折腾升级了……

0x00.前言

看见esterTion大佬的BiliPlus上了TLSv1.3,正巧实验室站证书也快一年该续签了,于是大折腾开始了

0x01.Python

2.7.173.8.2
今天先把本地配好了2.7.153.6.83.7.23.8.0a1,版本的选择靠环境变量的先后顺序决定,PyCharm里倒是可以单独选择

与官网相同步
与官网相同步
py 骨灰级玩家
py 骨灰级玩家

然后服务器是腾讯云的一元机

16 年购买的
16 年购买的

想想从零开始也快折腾了三年了,现在想想还是有必要有一台Windows Server 2012 R2 Database x64(救急)使用的,当然现在Linux也算熟悉了,所以后续再购买服务器就打算使用CentOS了,因为最近白嫖到了一台时长一年Ubuntu 18.04(据说我发现的第二天一刀套餐就木有了),目前搭了V2ray代理,这个之后单独再写……

月 500 GB 是真的用不完
月 500 GB 是真的用不完
云端有俩更新莫名安装不上
云端有俩更新莫名安装不上
先不管了
先不管了

云端只安装了3.6.83.7.2是因为2不打算再用了,本地配2是因为部分gh的旧项目以及jd-tools,不过它是在Cygwin倒是不受影响……本地配3.8.0a1是因为要达成成就看一看最新版本的特性……云端是要逐步从3.6.8迁移至3.7.2,根据Stack Overflow 的这个回答How to run celery on windows?

3.1.25
3.1.25
我一直用的就是 eventlet
我一直用的就是 eventlet

所以为了Celery还是留两个版本吧,顺便准备把pipenv也补上……

刚把 server 上的 py 升级完就突然又不想搞了……
刚把 server 上的 py 升级完就突然又不想搞了……

还是惯例配好pipy阿里云镜像,升级pip

0x01.Apache24

Download
Download
Files for Microsoft Windows
Files for Microsoft Windows
windows
windows

我个人使用的就是第一个,有br压缩,第二个木有……虽然第一个是VC14,第二个是VC15……

apachehaus
apachehaus

下载这个12.1 MB大小的httpd-2.4.43-o111f-x64-vc15.zip,含有with LibreSSL 3.0.2, brotli 1.0.7, nghttp 1.40.0, Zlib 1.2.10, PCRE 8.44, APR 1.7.0, APR-Util 1.6.1,目前LibreSSLOpenSSL版本均含有br
下载这个11.9 MB大小的httpd-2.4.38-o111a-x64-vc14.zip,含有with OpenSSL 1.1.1a, brotli 1.0.7, nghttp 1.36.0, Zlib 1.2.10, PCRE 8.42, APR 1.6.5, APR-Util 1.6.1,虽然有LibreSSL版本以及OpenSSL 1.0.2OpenSSL 1.1.0,但是我还是选择了这个,并不是下载量第一的1.0.2

点击此处 ← 查看折叠
apachelounge
apachelounge

VS16

wamp
wamp

bitnami的这个是一个PHP大软件环境……

WAMPSERVER
WAMPSERVER

玩具?

XAMPP
XAMPP

只有32位的还是算了吧……

修改配置文件:

/extra/httpd.ahssl.conf

注释掉这个日志:

1
2
3
4
5
#   Per-Server Logging:
# The home of a custom SSL log file. Use this when you want a
# compact non-error SSL logfile on a virtual host basis.
CustomLog "${SRVROOT}/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" env=HTTPS

增加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<VirtualHost *:443>
Protocols h2 http/1.1

SSLEngine on
ServerName lab.yuangezhizao.cn
SSLCertificateFile "${SRVROOT}/conf/ssl/2_lab.yuangezhizao.cn.crt"
SSLCertificateKeyFile "${SRVROOT}/conf/ssl/3_lab.yuangezhizao.cn.key"
SSLCertificateChainFile "${SRVROOT}/conf/ssl/1_root_bundle.crt"
DocumentRoot C:\LAB

Header always set Strict-Transport-Security "max-age=10"
Header always set X-XSS-Protection "1; mode=block"
Header always set x-content-type-options nosniff
Header always set X-Frame-Options SAMEORIGIN

WSGIScriptAlias / C:\LAB\wsgi.py

<Directory C:\LAB>
WSGIScriptReloading On
Require all granted
Require host ip
</Directory>
</VirtualHost>

/extra/httpd.info.conf

1
2
3
4
5
6
7
<Location /server-status>
SetHandler server-status
AuthName "server-status"
AuthType Basic
AuthUserFile "${SRVROOT}/bin/.htpasswd"
require user yuangezhizao
</Location>

取消注释:

1
ExtendedStatus On
1
2
3
4
5
6
7
8
9
10
<Location /server-info>
SetHandler server-info
# AuthBasicFake yuangezhizao <password>
# Require host lab.yuangezhizao.cn
# Require ip 61.161
AuthName "server-info"
AuthType Basic
AuthUserFile "${SRVROOT}/bin/.htpasswd"
require user yuangezhizao
</Location>

AuthBasicFake莫名不好使,所以只能采用AuthType Basic了……

/extra/httpd.vhosts.conf

1
2
3
4
<VirtualHost *:80>
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]
</VirtualHost>

80强制跳转443

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<VirtualHost *:80>
DocumentRoot "${SRVROOT}/htdocs/webui-aria2"
DirectoryIndex index.html
ServerName aria2.yuangezhizao.cn

<Directory "${SRVROOT}/htdocs/webui-aria2">
Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "${SRVROOT}/htdocs/status-page"
DirectoryIndex index.html
ServerName status.yuangezhizao.cn

<Directory "${SRVROOT}/htdocs/status-page">
Require all granted
</Directory>
</VirtualHost>

/httpd.conf

终于到了根配置文件了,可以看到Define ENABLE_TLS13 "Yes"就是TLSv1.3
增加LoadModule brotli_module modules/mod_brotli.so,取消注释LoadModule expires_module modules/mod_expires.so,取消注释

1
2
LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so

取消注释LoadModule http2_module modules/mod_http2.so
取消注释LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_http_module modules/mod_proxy_http.so备用,
取消注释LoadModule rewrite_module modules/mod_rewrite.so
取消注释LoadModule vhost_alias_module modules/mod_vhost_alias.so
增加LoadModule wsgi_module modules/mod_wsgi.cp38-win_amd64.pyd
修改ServerAdmin root@yuangezhizao.cnServerName lab.yuangezhizao.cn
取消注释Include conf/extra/httpd-vhosts.confInclude conf/extra/httpd-default.conf
最后是br压缩:

1
2
3
4
5
6
7
8
9
10
11
<IfModule brotli_module>
SetOutputFilter BROTLI_COMPRESS
# DEFLATE
# DeflateCompressionLevel 3
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-brotli dont-vary
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-brotli dont-vary
SetEnvIfNoCase Request_URI .(?:pdf|doc|avi|mov|mp3|rm)$ no-brotli dont-vary
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css
AddOutputFilterByType BROTLI_COMPRESS text/javascript application/javascript application/x-javascript
AddOutputFilterByType BROTLI_COMPRESS application/json
</IfModule>

0x02.mod_wsgi

Latest releasemod_wsgi-4.7.1版本

巧了,没下这个版本的
巧了,没下这个版本的

历史安装失败,限于版面折叠

点击此处 ← 查看终端
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(LAB-HVyfm2Bd) D:\yuangezhizao\Documents\PycharmProjects\LAB>pipenv install mod_wsgi
Installing mod_wsgi…
Looking in indexes: https://pypi.python.org/simple
Collecting mod_wsgi
Downloading https://files.pythonhosted.org/packages/47/69/5139588686eb40053f8355eba1fe18a8bee94dc3efc4e36720c73e07471a/mod_wsgi-4.6.5.tar.gz (490kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\YUANGE~1\AppData\Local\Temp\pip-install-aabgv042\mod-wsgi\setup.py", line 158, in <module>
raise RuntimeError('No Apache installation can be found. Set the '
RuntimeError: No Apache installation can be found. Set the MOD_WSGI_APACHE_ROOTDIR environment to its location.

----------------------------------------

Error: An error occurred while installing mod_wsgi!
Command "python setup.py egg_info" failed with error code 1 in C:\Users\YUANGE~1\AppData\Local\Temp\pip-install-aabgv042\mod-wsgi\

哦,设定环境变量

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
(LAB-HVyfm2Bd) D:\yuangezhizao\Documents\PycharmProjects\LAB>SET MOD_WSGI_APACHE_ROOTDIR=D:\Apache24
(LAB-HVyfm2Bd) D:\yuangezhizao\Documents\PycharmProjects\LAB>pipenv install mod_wsgi
Installing mod_wsgi…
Looking in indexes: https://pypi.python.org/simple
Collecting mod_wsgi
Using cached https://files.pythonhosted.org/packages/47/69/5139588686eb40053f8355eba1fe18a8bee94dc3efc4e36720c73e07471a/mod_wsgi-4.6.5.tar.gz
Building wheels for collected packages: mod-wsgi
Building wheel for mod-wsgi (setup.py): started
Building wheel for mod-wsgi (setup.py): still running...
Building wheel for mod-wsgi (setup.py): finished with status 'error'
Complete output from command c:\users\yuangezhizao\.virtualenvs\lab-hvyfm2bd\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\YUANGE~1\\AppData\\Lo
cal\\Temp\\pip-install-48e8tnl_\\mod-wsgi\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'ex
ec'))" bdist_wheel -d C:\Users\YUANGE~1\AppData\Local\Temp\pip-wheel-z03h3fox --python-tag cp38:
C:\Python38\Lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\mod_wsgi
copying src\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi
creating build\lib.win-amd64-3.8\mod_wsgi\server
copying src\server\apxs_config.py -> build\lib.win-amd64-3.8\mod_wsgi\server
copying src\server\environ.py -> build\lib.win-amd64-3.8\mod_wsgi\server
copying src\server\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server
creating build\lib.win-amd64-3.8\mod_wsgi\server\management
copying src\server\management\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management
creating build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
copying src\server\management\commands\runmodwsgi.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
copying src\server\management\commands\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
creating build\lib.win-amd64-3.8\mod_wsgi\docs
copying docs\_build\html\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\docs
creating build\lib.win-amd64-3.8\mod_wsgi\images
copying images\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\images
copying images\snake-whiskey.jpg -> build\lib.win-amd64-3.8\mod_wsgi\images
running build_ext
building 'mod_wsgi.server.mod_wsgi' extension
creating build\temp.win-amd64-3.8
creating build\temp.win-amd64-3.8\Release
creating build\temp.win-amd64-3.8\Release\src
creating build\temp.win-amd64-3.8\Release\src\server
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\Apache24/include -IC:
\Python38\include -IC:\Python38\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\Mi
crosoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows
Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "
-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcsrc/server\mod_wsgi.c /Fobuild\temp.win-amd64-3.8\Release\src/server\mod_wsgi.obj
mod_wsgi.c
d:\apache24\include\apr_network_io.h(29): fatal error C1083: 无法打开包括文件: “apr_perms_set.h”: No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

----------------------------------------
Running setup.py clean for mod-wsgi
Failed to build mod-wsgi
Installing collected packages: mod-wsgi
Running setup.py install for mod-wsgi: started
Running setup.py install for mod-wsgi: still running...
Running setup.py install for mod-wsgi: finished with status 'error'
Complete output from command c:\users\yuangezhizao\.virtualenvs\lab-hvyfm2bd\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\YUANGE~1\\AppData\\
Local\\Temp\\pip-install-48e8tnl_\\mod-wsgi\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, '
exec'))" install --record C:\Users\YUANGE~1\AppData\Local\Temp\pip-record-h7vjkitd\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\
yuangezhizao\.virtualenvs\lab-hvyfm2bd\include\site\python3.8\mod-wsgi:
C:\Python38\Lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\mod_wsgi
copying src\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi
creating build\lib.win-amd64-3.8\mod_wsgi\server
copying src\server\apxs_config.py -> build\lib.win-amd64-3.8\mod_wsgi\server
copying src\server\environ.py -> build\lib.win-amd64-3.8\mod_wsgi\server
copying src\server\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server
creating build\lib.win-amd64-3.8\mod_wsgi\server\management
copying src\server\management\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management
creating build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
copying src\server\management\commands\runmodwsgi.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
copying src\server\management\commands\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
creating build\lib.win-amd64-3.8\mod_wsgi\docs
copying docs\_build\html\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\docs
creating build\lib.win-amd64-3.8\mod_wsgi\images
copying images\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\images
copying images\snake-whiskey.jpg -> build\lib.win-amd64-3.8\mod_wsgi\images
running build_ext
building 'mod_wsgi.server.mod_wsgi' extension
creating build\temp.win-amd64-3.8
creating build\temp.win-amd64-3.8\Release
creating build\temp.win-amd64-3.8\Release\src
creating build\temp.win-amd64-3.8\Release\src\server
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\Apache24/include -I
C:\Python38\include -IC:\Python38\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\
Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Window
s Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcsrc/server\mod_wsgi.c /Fobuild\temp.win-amd64-3.8\Release\src/server\mod_wsgi.obj
mod_wsgi.c
d:\apache24\include\apr_network_io.h(29): fatal error C1083: 无法打开包括文件: “apr_perms_set.h”: No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

----------------------------------------

Error: An error occurred while installing mod_wsgi!
Failed building wheel for mod-wsgi
Command "c:\users\yuangezhizao\.virtualenvs\lab-hvyfm2bd\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\YUANGE~1\\AppData\\Local\\Temp\\pip-install
-48e8tnl_\\mod-wsgi\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --recor
d C:\Users\YUANGE~1\AppData\Local\Temp\pip-record-h7vjkitd\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\yuangezhizao\.virtualenv
s\lab-hvyfm2bd\include\site\python3.8\mod-wsgi" failed with error code 1 in C:\Users\YUANGE~1\AppData\Local\Temp\pip-install-48e8tnl_\mod-wsgi\

它……自动用VS2017编译了……果然还是不行……

4.4.12 是最后一个提供了 Windows binaries 的版本
4.4.12 是最后一个提供了 Windows binaries 的版本

然后就去下载whl

lfd
lfd

Running mod_wsgi on Windows这个上古教程实在是太老了……

神网站
神网站

pip安装即可,顺便解压找到mod_wsgi.cp37-win_amd64.pyd扔到models目录里
附上wgsi.py文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# activate_this = "C:\\Users\\Administrator\\.virtualenvs\\LAB-QaV1et56\\Scripts\\activate_this.py"
# with open(activate_this) as file_:
# exec(file_.read(), dict(__file__=activate_this))

import sys
import logging

logging.basicConfig(stream=sys.stderr)

# Expand Python classes path with your app's path
sys.path.insert(0, "C:\LAB")

from run import app

# Put logging code (and imports) here ...

# Initialize WSGI app object
application = app

0x03.RabbitMQ

看到日志文件竟有十兆之大,本能地随手就给打开了:C:/Users/Administrator/AppData/Roaming/RabbitMQ/log/rabbit@cn-tx-bj1-w2d.log
然后前面都是正常的,结果从code的预览就能看到后面全是一样的,每5s一条的:
2020-02-14 19:29:12.010 [error] <0.513.0> Could not find handle.exe, please install from sysinternals
谷歌一下子就搜到了解决方案,Could you help me to clarify what this error means?”Could not find handle.exe, please install from sysinternals”

第一个就解决了,好评
第一个就解决了,好评

Eddie Murphy (Employee)
2 months ago

When you first log in to the RabbitMQ web dashboard, under the Overview tab you will notice that in the File descriptors field there is a question mark about the missing Handle.exe. Handle.exe enables RabbitMQ to monitor the local file system. Download it from here: https://docs.microsoft.com/en-us/sysinternals/downloads/handle

  • Extract this file. It is important that you keep a note of the extracted path as we will need to add it to PATH environment variable so it is available to RabbitMQ.
  • Open the Environment Variables Windows, scroll down to the System Variables -> Path variable and click on Edit. At the end of the Variable Value, add the path to the Handle.exe by the path above
  • Restart the RabbitMQ
  • rabbitmq-service.bat stop
  • rabbitmq-service.bat start

于是下载Handle v4.22,才701 KB……解压之后将其路径加入环境变量,重启服务问题解决(^_−)☆

You can also get a GUI-based version of this program, Process Explorer, here at Sysinternals.

然后看到Process Explorer竟然是一个基于它的图形化程序,惊了

0x05.升级至Python 3.10.0

明明已经安装了VS2019,可还是报错草

编译火葬场
编译火葬场

今晚去下载编译工具发现Visual Studio 2022都出了草

17.0
17.0

于是,去下载Visual Studio 2022 生成工具

vs_BuildTools.exe
vs_BuildTools.exe

参照WindowsCompilers的说明,首先pip install --upgrade setuptools,然后Microsoft Visual C++ 14.2 standalone: Build Tools for Visual Studio 2019 (x86, x64, ARM, ARM64)

This is a standalone version of Visual C++ 14.2 compiler, you don’t need to install Visual Studio 2019.
Install Microsoft Build Tools for Visual Studio 2019.
In Build tools, install C++ build tools and ensure the latest versions of MSVCv142 - VS 2019 C++ x64/x86 build tools and Windows 10 SDK are checked.
The setuptools Python package version must be at least 34.4.0.
{i} Build Tools also allows to install any previous Visual C++ 14 version (Including 2015, 2017 ones).

空间不够
空间不够
E 盘来凑
E 盘来凑
继续
继续

然后终于好使了,最后卸载2019只留个2022就好啦(顺便py39也光速被卸载了

1
2
3
4
5
6
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.0.1
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************

E:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools>
rm
rm

0x04.后记

未完待续……