Flask 应用程序通过 Apache 2 上传图像文件不起作用

Flask 应用程序通过 Apache 2 上传图像文件不起作用

在 Fedora 30 和 上运行 Apache/2.4.41 python3-mod_wsgi-4.6.4-3.fc30.x86_64。并进行测试:mod_wsgi-express start-server /var/www/flask/upload_pictures.wsgi --user myuser大部分工作正常,只是使用 Python 2.7 和一些警告。浏览 URL 工作正常。该应用程序只允许用户上传图片。

[Tue Oct 29 10:05:05.365111 2019] [mpm_event:notice] [pid 17160:tid 140276832493888] AH00489: Apache/2.4.41 (Fedora) mod_wsgi/4.6.4 Python/2.7 configured -- resuming normal operations
[Tue Oct 29 10:05:05.365167 2019] [core:notice] [pid 17160:tid 140276832493888] AH00094: Command line: 'httpd (mod_wsgi-express)    -f /tmp/mod_wsgi-localhost:8000:16836/httpd.conf -D MOD_WSGI_MPM_ENABLE_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_WORKER_MODULE -D MOD_WSGI_MPM_EXISTS_PREFORK_MODULE -D FOREGROUND'
[Tue Oct 29 10:05:05.809860 2019] [wsgi:error] [pid 17162:tid 140276832493888] /usr/lib/python2.7/site-packages/nilearn/__init__.py:73: DeprecationWarning: Python2 support is deprecated and will be removed in the next release. Consider switching to Python 3.6 or 3.7.
[Tue Oct 29 10:05:05.809882 2019] [wsgi:error] [pid 17162:tid 140276832493888]   _python_deprecation_warnings()
[Tue Oct 29 10:05:38.461053 2019] [mpm_event:notice] [pid 17160:tid 140276832493888] AH00491: caught SIGTERM, shutting down
[Tue Oct 29 10:05:41.124861 2019] [mpm_event:notice] [pid 17414:tid 140153494917440] AH00489: Apache/2.4.41 (Fedora) mod_wsgi/4.6.4 Python/2.7 configured -- resuming normal operations
[Tue Oct 29 10:05:41.124923 2019] [core:notice] [pid 17414:tid 140153494917440] AH00094: Command line: 'httpd (mod_wsgi-express)    -f /tmp/mod_wsgi-localhost:8000:16836/httpd.conf -D MOD_WSGI_MPM_ENABLE_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_WORKER_MODULE -D MOD_WSGI_MPM_EXISTS_PREFORK_MODULE -D FOREGROUND'
[Tue Oct 29 10:05:41.598057 2019] [wsgi:error] [pid 17417:tid 140153494917440] /usr/lib/python2.7/site-packages/nilearn/__init__.py:73: DeprecationWarning: Python2 support is deprecated and will be removed in the next release. Consider switching to Python 3.6 or 3.7.
[Tue Oct 29 10:05:41.598077 2019] [wsgi:error] [pid 17417:tid 140153494917440]   _python_deprecation_warnings()

文件内容如下upload_pictures.wsgi

#!/usr/local/bin/anaconda3/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)

sys.path.insert(0, '/home/myhome/myuser/public_html')

from upload_pictures2 import app as application

application.root_path = '/home/myhome/myuser/public_html'

文件末尾的内容如下httpd.conf

<VirtualHost *:8000>
    WSGIDaemonProcess upload_pictures2 user=apache group=apache threads=5
    WSGIScriptAlias / /var/www/flask/upload_pictures.wsgi

    <Directory /home/myhome/myuser/public_html>
        WSGIProcessGroup upload_pictures2
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptReloading On
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

我看过类似的问题这里这里,但这些似乎与我的问题无关。我在日志中没有看到任何错误,也netstat -ln|grep 8000没有显示正在使用的端口 8000。我的路径有问题吗?

以下是唯一打印的日志:

[Tue Oct 29 10:29:47.742916 2019] [wsgi:info] [pid 26598:tid 140684965835072] mod_wsgi (pid=26598): Attach interpreter ''.
[Tue Oct 29 10:29:47.746480 2019] [wsgi:info] [pid 26598:tid 140684965835072] mod_wsgi (pid=26598): Imported 'mod_wsgi'.
[Tue Oct 29 10:29:47.746798 2019] [wsgi:debug] [pid 26598:tid 140684920149760] src/server/mod_wsgi.c(9068): mod_wsgi (pid=26598): Started thread 0 in daemon process 'upload_pictures2'

相关内容