【发布时间】:2016-03-30 21:14:09
【问题描述】:
我正在尝试使用 Ubuntu 在 Apache2 服务器上设置 Django 应用程序。
我使用了以下教程来做要领。
https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04
我也使用了以下解决方案,但它对我不起作用。
Django (wsgi) and Wordpress coexisting in Apache virtualhost
其他参考:
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/
我的 apache2 配置文件如下。
<VirtualHost *:80>
Alias /static /home/ubuntu/test_pfi_app/static
#Alias /media /home/ubuntu/test_pfi_app/media
#DocumentRoot /var/www/html
<Directory /home/ubuntu/test_pfi_app/static>
Require all granted
</Directory>
WSGIDaemonProcess myproject python-path=/home/ubuntu/test_pfi_app:/usr/local/lib/python2.7/site-packages
WSGIProcessGroup myproject
WSGIScriptAlias /django /home/ubuntu/test_pfi_app/myproject/wsgi.py process-group=myproject
#WSGIScriptAliasMatch /django /home/ubuntu/test_pfi_app/myproject/wsgi.py
<Directory /home/ubuntu/test_pfi_app/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName app1.example.co.in
DocumentRoot /var/www/html/ocdemo
</VirtualHost>
<VirtualHost *:80>
ServerName app2.example.co.in
DocumentRoot /var/www/html/echosuat
</VirtualHost>
<VirtualHost *:80>
ServerName task.example.co.in
DocumentRoot /var/www/html/tasks
</VirtualHost>
我可以使用 IP/django 访问 django 应用程序,但访问服务器的根目录会重定向到 /var/www url,如下图所示。
所有其他应用程序都可以从IP/html/app_name 访问,而它们应该可以从IP/app_name 访问
我无法在配置文件中进行正确的配置。
另外,我无法在访问IP/django 时看到“欢迎使用 django”页面。而是给出一个“Page not found (404)”
【问题讨论】:
-
您有任何可以共享的 Apache 日志文件吗?
-
我会在明天之前添加它们。我查看了日志,发现它们没有多大用处。
标签: python django apache2 django-wsgi django-deployment