我已经在虚拟环境中的 ubuntu 桌面上构建了一个 flask 应用程序。
但是现在我正尝试将其上传到实时的 ubuntu 服务器 16.04。
我已经安装了所有依赖项,并且我的启用站点 apache 文件如下所示;
<VirtualHost *:80>
ServerName xx.xxx.xxx.xxx
WSGIDaemonProcess /var/www/WebScraper/WebScraper user='user' group='group' threads=5
WSGIScriptAlias / /var/www/WebScraper/webscraper.wsgi
<Directory /var/www/WebScraper/WebScraper/>
WSGIProcessGroup WebScraper
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
x 是我的服务器的 IP 地址,并且我已将用户和组替换为我的用户名和组名。
我的 wsgi 看起来像这样;
#!/usr/bin/python3
import sys
sys.path.insert(0,'/var/www/WebScraper/')
from WebScraper import app as application
但每次我在搜索栏中输入我的 IP 地址时,它都会返回这个耗时太长
更新
阅读完文档底部的部分后这里我已将以下内容添加到我的wsgi
文件中
#!/usr/bin/python3
import sys
activate_this = '/var/www/WebScraper/WebScraper/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
sys.path.insert(0,'/var/www/WebScraper/')
from WebScraper import app as application
更新2
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1417/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1446/sshd
tcp6 0 0 :::80 :::* LISTEN 5902/apache2
tcp6 0 0 :::22 :::* LISTEN 1446/sshd
更新 3
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.0.4. Set the 'ServerName' directive globally to suppress this message
[Tue Mar 28 16:26:50.943638 2017] [wsgi:warn] [pid 5902] mod_wsgi: Compiled for Python/3.5.1+.
[Tue Mar 28 16:26:50.943644 2017] [wsgi:warn] [pid 5902] mod_wsgi: Runtime using Python/3.5.2.
[Tue Mar 28 16:26:50.943835 2017] [mpm_prefork:notice] [pid 5902] AH00163: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Tue Mar 28 16:26:50.943844 2017] [core:notice] [pid 5902] AH00094: Command line: '/usr/sbin/apache2'