为Django应用程序提供服务的Apache配置不起作用



我已经在服务器上安装了我的Django项目,它在本地运行,没有问题。我可以进行迁移,运行服务器不会出错。

我遵循本教程是为了使用ApacheUbuntu上为项目服务,但我遇到了问题。第一个是启动Django的开发服务器并允许远程连接(./manage.py runserver 0.0.0.0:8000(。当我从远程浏览器连接时,我会收到以下错误:

Esta página no funciona
189.172.218.174 envió una respuesta no válida.
ERR_INVALID_HTTP_RESPONSE

我也做了一些配置,用Apache为应用程序提供服务,但当尝试从浏览器连接到服务器时,我只会得到一个空白页面。没有任何错误。

这是我的000-default.conf文件:

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Alias /static /home/linuxmidtc/Code/TCDigitalProject/tcdigital/TCDigitalBackend/TCDigital/static
<Directory /home/linuxmidtc/Code/TCDigitalProject/tcdigital/TCDigitalBackend/TCDigital/static>
Require all granted
</Directory>
<Directory /home/linuxmidtc/Code/TCdigitalProject/tcdigital/TCDigitalBackend/TCDigital/TCDigital>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess TCDigital python-home=/home/linuxmidtc/Code/TCDigitalProject/tcdigital/TCDigitalBackend/TCDigitalVenv python-path=/home/linuxmidtc/Code/TCDigitalProjec/tcdigital/TCdigitalBackend/TCDigital
WSGIProcessGroup TCDigital
WSGIScriptAlias / /home/linuxmidtc/Code/TCDigitalProject/tcdigital/TCDigitalBackend/TCDigital/TCDigital/wsgi.py
</VirtualHost>

编辑我试过@mohamedabdelawel的答案,但结果相同。这是我当前的ufw状态:

linuxmidtc@servermidtc:~$ sudo ufw status numbered
Status: active
To                         Action      From
--                         ------      ----
[ 1] Apache Full                ALLOW IN    Anywhere                  
[ 2] 22/tcp                     ALLOW IN    Anywhere                  
[ 3] 80                         ALLOW IN    Anywhere                  
[ 4] 80/tcp                     ALLOW IN    Anywhere                  
[ 5] Apache Full (v6)           ALLOW IN    Anywhere (v6)             
[ 6] 22/tcp (v6)                ALLOW IN    Anywhere (v6)             
[ 7] 80 (v6)                    ALLOW IN    Anywhere (v6)             
[ 8] 80/tcp (v6)                ALLOW IN    Anywhere (v6)

我认为你的问题在于不允许http的ufw,请尝试遵循本教程这将帮助您在ubuntu 上配置ufw

最新更新