python - Fail to deploy Django + Apache2 on Fedora 19 -
first this:
cd /var/www/html django-admin.py startproject mysite
then create /var/www/html/mysite/django.wsgi:
import os, sys sys.path.append('/var/www/html/mysite') os.environ['django_settings_module'] = 'mysite.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.wsgihandler()
then append /etc/httpd/conf/httpd.conf by:
<virtualhost 222.200.189.79:80> servername 222.200.189.79:80 documentroot /var/www wsgiscriptalias / /var/www/html/mysite/django.wsgi <directory /var/www/html/mysite> order deny,allow allow </directory> </virtualhost>
finally restart apache:
sudo httpd -k restart
but until can see welcome page of apache when visit:
http://localhost
even more, "not found" error when visit:
http://localhost/admin
though url "^admin/" has been defined in url.py in project.
what' wrong operation?
on apache2/apache2.conf add line hope helps , apply command after saving it. "sudo service apache2 restart" , remember need restart apache if make change on settings.py or on other .py has generated .pyc file
django enable /etc/apache2/apache2.conf
alias /robots.txt /var/www/html/mysite/static/robots.txt alias /favicon.ico /var/www/html/mysite/static/favicon.ico aliasmatch ^/([^/]*\.css) /var/www/html/mysite/static/styles/$1 alias /media/ /var/www/html/mysite/media/ alias /static/ /var/www/html/mysite/static/ <directory /var/www/html/mysite/static> order deny,allow allow </directory> <directory /var/www/html/mysite/media> order deny,allow allow </directory> wsgiscriptalias / /var/www/html/mysite/wsgi.py wsgipythonpath /var/www/html/mysite <directory /var/www/html/mysite> <files wsgi.py> order deny,allow allow </files> </directory>/var/www/html/mysite/
sites enabled file (var/apache2/sites-enabled)
<virtualhost *:80> servername yourdomain.com serveradmin info@yourdomain.com serveralias www.yourdomain.com documentroot /var/www/html/mysite indexignore * </virtualhost>
Comments
Post a Comment