当我试图通过apache服务器访问局域网ip地址上的django时,我得到了apache2的默认页面。我还在运行djangopython manage.py runsever
命令,并尝试使用192.168.10.11
访问。但它仍然显示apache的默认页面。
如何使用apache访问django
<VirtualHost *:80>
ServerName localhost
DocumentRoot /home/five/NewsDesk/server
WSGIScriptAlias / /home/five/NewsDesk/server/server/wsgi.py
# adjust the following line to match your Python path
WSGIDaemonProcess 192.168.10.11 processes=2 threads=15 display-name=%{GROUP} python-home=/home/five/NewsDesk/env/lib/python3.8
WSGIProcessGroup 192.168.10.11
<directory /home/five/NewsDesk/server>
<Files wsgi.py>
Allow from all
Require all granted
</Files>
AllowOverride all
Require all granted
Options FollowSymlinks
</directory>
Alias /static/ /home/five/NewsDesk/server/staticfiles/
<Directory /home/five/NewsDesk/server/staticfiles>
Require all granted
</Directory>
</VirtualHost>
apache2ctl -S
$apache2ctl -S
VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhost (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost localhost (/etc/apache2/sites-enabled/newsdesk.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
我想,您的
django
项目应该具有以下结构:要使用
apache
服务器在本地提供/公开django
项目,您需要在以下服务器上进行一些更改:vhost配置
/etc/主持人
(取决于
linux
发行版以及apache
的安装和配置方式)设置.py
现在,要在本地公开应用程序,请使用下面的命令
但就你而言,应该是:
让我知道这对你是否有用
相关问题 更多 >
编程相关推荐