又开始折腾升级了……

0x00.前言

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

0x01.Python

今天先把本地配好了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

下载这个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

VC15

wamp
wamp

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

WAMPSERVER
WAMPSERVER

玩具?

XAMPP
XAMPP

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

修改配置文件:

/extra/httpd.ahssl.conf

注释掉这个日志:

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

增加

1
<VirtualHost *:443>
2
    Protocols h2 http/1.1
3
4
    SSLEngine on
5
    ServerName lab.yuangezhizao.cn
6
    SSLCertificateFile "${SRVROOT}/conf/ssl/2_lab.yuangezhizao.cn.crt"
7
    SSLCertificateKeyFile "${SRVROOT}/conf/ssl/3_lab.yuangezhizao.cn.key"
8
    SSLCertificateChainFile "${SRVROOT}/conf/ssl/1_root_bundle.crt"
9
    DocumentRoot C:\LAB
10
11
    Header always set Strict-Transport-Security "max-age=60"
12
    Header always set X-XSS-Protection "1; mode=block"
13
    Header always set x-content-type-options nosniff
14
    Header always set X-Frame-Options SAMEORIGIN
15
16
    WSGIScriptAlias / C:\LAB\wsgi.py
17
18
    <Directory C:\LAB>
19
        WSGIScriptReloading On
20
        Require all granted
21
        Require host ip
22
    </Directory>
23
</VirtualHost>

/extra/httpd.info.conf

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

取消注释:

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

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

/extra/httpd.vhosts.conf

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

80强制跳转443

1
<VirtualHost *:80>
2
    DocumentRoot C:\Apache24\webui-aria2
3
    DirectoryIndex  index.html
4
    ServerName aria2.yuangezhizao.cn
5
6
    <Directory C:\Apache24\webui-aria2>
7
    	Require all granted
8
    </Directory>
9
</VirtualHost>
10
11
<VirtualHost *:80>
12
    DocumentRoot C:\Apache24\status-page
13
    DirectoryIndex  index.html
14
    ServerName status.yuangezhizao.cn
15
16
    <Directory C:\Apache24\status-page>
17
    	Require all granted
18
    </Directory>
19
</VirtualHost>

/httpd.conf

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

1
LoadModule filter_module modules/mod_filter.so
2
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.cp37-win_amd64.pyd
修改ServerAdmin root@yuangezhizao.cnServerName lab.yuangezhizao.cn
取消注释Include conf/extra/httpd-vhosts.confInclude conf/extra/httpd-default.conf
最后是br压缩:

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

0x02.mod_wsgi

Latest releasemod_wsgi-4.6.5版本,

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

尝试安装

1
(LAB-HVyfm2Bd) D:\yuangezhizao\Documents\PycharmProjects\LAB>pipenv install mod_wsgi
2
Installing mod_wsgi…
3
Looking in indexes: https://pypi.python.org/simple
4
Collecting mod_wsgi
5
  Downloading https://files.pythonhosted.org/packages/47/69/5139588686eb40053f8355eba1fe18a8bee94dc3efc4e36720c73e07471a/mod_wsgi-4.6.5.tar.gz (490kB)
6
    Complete output from command python setup.py egg_info:
7
    Traceback (most recent call last):
8
      File "<string>", line 1, in <module>
9
      File "C:\Users\YUANGE~1\AppData\Local\Temp\pip-install-aabgv042\mod-wsgi\setup.py", line 158, in <module>
10
        raise RuntimeError('No Apache installation can be found. Set the '
11
    RuntimeError: No Apache installation can be found. Set the MOD_WSGI_APACHE_ROOTDIR environment to its location.
12
    
13
    ----------------------------------------
14
15
Error:  An error occurred while installing mod_wsgi!
16
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
(LAB-HVyfm2Bd) D:\yuangezhizao\Documents\PycharmProjects\LAB>SET MOD_WSGI_APACHE_ROOTDIR=D:\Apache24
1
(LAB-HVyfm2Bd) D:\yuangezhizao\Documents\PycharmProjects\LAB>pipenv install mod_wsgi
2
Installing mod_wsgi…
3
Looking in indexes: https://pypi.python.org/simple
4
Collecting mod_wsgi
5
  Using cached https://files.pythonhosted.org/packages/47/69/5139588686eb40053f8355eba1fe18a8bee94dc3efc4e36720c73e07471a/mod_wsgi-4.6.5.tar.gz
6
Building wheels for collected packages: mod-wsgi
7
  Building wheel for mod-wsgi (setup.py): started
8
  Building wheel for mod-wsgi (setup.py): still running...
9
  Building wheel for mod-wsgi (setup.py): finished with status 'error'
10
  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
11
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
12
ec'))" bdist_wheel -d C:\Users\YUANGE~1\AppData\Local\Temp\pip-wheel-z03h3fox --python-tag cp38:
13
  C:\Python38\Lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'bugtrack_url'
14
    warnings.warn(msg)
15
  running bdist_wheel
16
  running build
17
  running build_py
18
  creating build
19
  creating build\lib.win-amd64-3.8
20
  creating build\lib.win-amd64-3.8\mod_wsgi
21
  copying src\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi
22
  creating build\lib.win-amd64-3.8\mod_wsgi\server
23
  copying src\server\apxs_config.py -> build\lib.win-amd64-3.8\mod_wsgi\server
24
  copying src\server\environ.py -> build\lib.win-amd64-3.8\mod_wsgi\server
25
  copying src\server\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server
26
  creating build\lib.win-amd64-3.8\mod_wsgi\server\management
27
  copying src\server\management\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management
28
  creating build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
29
  copying src\server\management\commands\runmodwsgi.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
30
  copying src\server\management\commands\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
31
  creating build\lib.win-amd64-3.8\mod_wsgi\docs
32
  copying docs\_build\html\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\docs
33
  creating build\lib.win-amd64-3.8\mod_wsgi\images
34
  copying images\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\images
35
  copying images\snake-whiskey.jpg -> build\lib.win-amd64-3.8\mod_wsgi\images
36
  running build_ext
37
  building 'mod_wsgi.server.mod_wsgi' extension
38
  creating build\temp.win-amd64-3.8
39
  creating build\temp.win-amd64-3.8\Release
40
  creating build\temp.win-amd64-3.8\Release\src
41
  creating build\temp.win-amd64-3.8\Release\src\server
42
  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:
43
\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
44
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
45
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" "
46
-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
47
  mod_wsgi.c
48
  d:\apache24\include\apr_network_io.h(29): fatal error C1083: 无法打开包括文件: “apr_perms_set.h”: No such file or directory
49
  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
50
  
51
  ----------------------------------------
52
  Running setup.py clean for mod-wsgi
53
Failed to build mod-wsgi
54
Installing collected packages: mod-wsgi
55
  Running setup.py install for mod-wsgi: started
56
    Running setup.py install for mod-wsgi: still running...
57
    Running setup.py install for mod-wsgi: finished with status 'error'
58
    Complete output from command c:\users\yuangezhizao\.virtualenvs\lab-hvyfm2bd\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\YUANGE~1\\AppData\\
59
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__, '
60
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\
61
yuangezhizao\.virtualenvs\lab-hvyfm2bd\include\site\python3.8\mod-wsgi:
62
    C:\Python38\Lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'bugtrack_url'
63
      warnings.warn(msg)
64
    running install
65
    running build
66
    running build_py
67
    creating build
68
    creating build\lib.win-amd64-3.8
69
    creating build\lib.win-amd64-3.8\mod_wsgi
70
    copying src\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi
71
    creating build\lib.win-amd64-3.8\mod_wsgi\server
72
    copying src\server\apxs_config.py -> build\lib.win-amd64-3.8\mod_wsgi\server
73
    copying src\server\environ.py -> build\lib.win-amd64-3.8\mod_wsgi\server
74
    copying src\server\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server
75
    creating build\lib.win-amd64-3.8\mod_wsgi\server\management
76
    copying src\server\management\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management
77
    creating build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
78
    copying src\server\management\commands\runmodwsgi.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
79
    copying src\server\management\commands\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\server\management\commands
80
    creating build\lib.win-amd64-3.8\mod_wsgi\docs
81
    copying docs\_build\html\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\docs
82
    creating build\lib.win-amd64-3.8\mod_wsgi\images
83
    copying images\__init__.py -> build\lib.win-amd64-3.8\mod_wsgi\images
84
    copying images\snake-whiskey.jpg -> build\lib.win-amd64-3.8\mod_wsgi\images
85
    running build_ext
86
    building 'mod_wsgi.server.mod_wsgi' extension
87
    creating build\temp.win-amd64-3.8
88
    creating build\temp.win-amd64-3.8\Release
89
    creating build\temp.win-amd64-3.8\Release\src
90
    creating build\temp.win-amd64-3.8\Release\src\server
91
    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
92
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)\
93
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
94
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"
95
 "-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
96
    mod_wsgi.c
97
    d:\apache24\include\apr_network_io.h(29): fatal error C1083: 无法打开包括文件: “apr_perms_set.h”: No such file or directory
98
    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
99
    
100
    ----------------------------------------
101
102
Error:  An error occurred while installing mod_wsgi!
103
  Failed building wheel for mod-wsgi
104
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
105
-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
106
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
107
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编译了……
Running mod_wsgi on Windows
果然还是不行……

4.4.12 是最后一个提供了 Windows binaries 的版本
4.4.12 是最后一个提供了 Windows binaries 的版本
才发现这里有 4.6.5
才发现这里有 4.6.5

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

1
# activate_this = "C:\\Users\\Administrator\\.virtualenvs\\LAB-QaV1et56\\Scripts\\activate_this.py"
2
# with open(activate_this) as file_:
3
#    exec(file_.read(), dict(__file__=activate_this))
4
5
import sys
6
import logging
7
8
logging.basicConfig(stream=sys.stderr)
9
10
# Expand Python classes path with your app's path
11
sys.path.insert(0, "C:\LAB")
12
13
from run import app
14
15
# Put logging code (and imports) here ...
16
17
# Initialize WSGI app object
18
application = app

0x03.后记

未完待续……