简体   繁体   中英

Fail to deploy Django + Apache2 on Fedora 19

First I do this:

cd /var/www/html
django-admin.py startproject mysite

Then I 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 I 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 from all 
    </Directory>
</VirtualHost>  

Finally I restart Apache:

sudo httpd -k restart

But until now I can only see the welcome page of Apache when I visit:

http://localhost

Even more, I get an "Not found" error when I visit:

http://localhost/admin

though url "^admin/" has already been defined in url.py in my project.

What' wrong with my operation?

on your apache2/apache2.conf add this line Hope this helps and apply this command after saving it. "sudo service apache2 restart" and remember that you need to restart apache if you make a change on settings.py or on any other .py that has generated a .pyc file

Django Enable for /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 from all
</Directory>

<Directory /var/www/html/mysite/media>
Order deny,allow
Allow from all
</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 from all
</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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM