如何在apache上设置django

时间:2018-01-07 06:34:33

标签: python django apache python-3.6

我一直在尝试在apache上运行django,但我继续获取504 Gateway Timeout。这是网站conf。我把它放在/ etc / apache2 / sites-available /目录中。

<VirtualHost *:80> 
 ServerName orounds.localhost 
 DocumentRoot /var/www/html/orounds_pro
 WSGIScriptAlias / /var/www/html/orounds_pro/orounds_pro/wsgi.py 

 WSGIDaemonProcess orounds processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/html/orounds_pro/venv/bin/python3 
 WSGIProcessGroup orounds 

 <directory /var/www/html/orounds_pro> 
   AllowOverride all 
   Require all granted 
   Options FollowSymlinks 
 </directory> 

 Alias /static/ /var/www/html/orounds_pro/static/ 

 <Directory /var/www/html/orounds_pro/static> 
  Require all granted 
 </Directory> 
</VirtualHost>

我正在使用python3.6和apache 2.4.29。我为mod_wsgi的apache安装了sudo apt-get install libapache2-mod-wsgi-py3。有什么我做错了或者还有什么我应该做的吗?

问候。

1 个答案:

答案 0 :(得分:0)

<VirtualHost *:80>
. . .

Alias /static /home/user/myproject/static
<Directory /home/user/myproject/static>
    Require all granted
</Directory>

<Directory /home/user/myproject/myproject>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess myproject python-path=/home/user/myproject python-home=/home/user/myproject/myprojectenv
WSGIProcessGroup myproject
WSGIScriptAlias / /home/user/myproject/myproject/wsgi.py

尝试上述配置也为该目录提供完全权限。