Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用apache访问django?apache在django上显示默认页面_Python_Django_Apache - Fatal编程技术网

Python 如何使用apache访问django?apache在django上显示默认页面

Python 如何使用apache访问django?apache在django上显示默认页面,python,django,apache,Python,Django,Apache,当我试图通过apache服务器访问局域网ip地址上的django时,我得到了apache2的默认页面。我还在运行djangopython manage.py runsever命令,并尝试使用192.168.10.11进行访问。但它仍然显示apache的默认页面。 如何使用apache访问django <VirtualHost *:80> ServerName localhost DocumentRoot /home/five/NewsDesk/server WSGIScript

当我试图通过apache服务器访问局域网ip地址上的django时,我得到了apache2的默认页面。我还在运行django
python 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>

我想,您的
django
项目应该具有以下结构:

. home
  .. five
     .. NewsDesk
        .. server #  Your Django project root folder
           .. server
              .. settings.py
              .. wsgi.py

           ..

           .. staticfiles #  Your public folder to collect assets (js, css, img ..)
                          #  and served using apache

           .. manage.py
要使用
apache
服务器提供/公开您的
django
项目本地,您需要在以下服务器上进行一些更改:

vhost配置 设置.py 现在,要在本地公开应用程序,请使用下面的命令

python manage.py runserver YOUR_IP_ADDRESS:PORT
但就你而言,应该是:

python manage.py runserver 192.168.10.11

让我知道这是否对您有用

您的
WSGIScriptAlias
/NewsDesk
-如果您希望它成为站点的根目录,请尝试将其更改为仅
/
?我也尝试使用
WSGIScriptAlias//home/five/NewsDesk/server/server/wsgi.py
此代码,但我得到的问题与apache默认页面呈现相同。。。。
127.0.0.1  myapp.local
ALLOWED_HOSTS = [
  '127.0.0.1', 'localhost',
  '192.168.10.11', 'myapp.local',
]
python manage.py runserver YOUR_IP_ADDRESS:PORT
python manage.py runserver 192.168.10.11