我的flask应用程序在通过IP(http://194.233.174.220/)访问时可以正常工作,但在使用dns(http://friendhub.social/)时,它只显示默认的apache 2页面。如果我尝试将自己的页面移到/var/www/html,它只显示目录树
/etc/apache 2/sites-可用的/社会化的.conf文件:
<VirtualHost *:80>
ServerName 194.233.174.220
ServerAdmin email@mywebsite.com
WSGIScriptAlias / /var/www/social/social.wsgi
<Directory /var/www/social/social/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Alias /static /var/www/social/social/static
<Directory /var/www/social/social/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- apache 2版本:嵌入式系统(Ubuntu)
- flask :2.2.2
- Python:3.10.4
- 操作系统:Ubuntu 22.04.1 LTS
- 在Linode上部署
1条答案
按热度按时间eqfvzcg81#
您需要将ServerName设置为DNS中的主机名,而不是IP地址。
这是因为许多不同的主机名可能与一个IP地址相关联,例如在共享主机平台上。
Apachehttpd就是这样知道如何路由请求的。