I server up my django apps on nginx using the following config file

server {
        listen 80;
        server_name domain.com;

        root /location/of/application

        access_log  /location/to/logs/application.access.log;
        error_log  /location/to/logs/application.error.log;

        # serve static files directly
        location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
                root /location/of/application/root;
        access_log      off;
        expires         30d;
        break;
    }

        location / {
                fastcgi_pass 127.0.0.1:8200;
                include fastcgi_params.django;
        }
}

On Dec 27, 12:33 pm, Footee <footee.p...@gmail.com> wrote:
> in these days, i try to build the django on my host, But 
> thehttp://xxx.xxx.xxx.xxx/admincan't get the default css.
>
> the nginx catch these errors:
>
> 2010/12/27 04:45:26 [error] 24442#0: *76 open() "/home/peng/jiangyo/
> site_media/admin/css/base.css" failed (13: Permission denied), client:
> 124.42.77.160, server: jiangyo.info, request: "GET /site_media/admin/
> css/base.css HTTP/1.1", host: "184.82.232.225", referrer: "http://
> xxx.xxx.xxx.xxx/admin/"
> 2010/12/27 04:45:26 [error] 24442#0: *73 open() "/home/peng/jiangyo/
> site_media/admin/css/dashboard.css" failed (13: Permission denied),
> client: 124.42.77.160, server: jiangyo.info, request: "GET /site_media/
> admin/css/dashboard.css HTTP/1.1", host: "xxx.xxx.xxx.xxx", referrer:
> "http://xxx.xxx.xxx.xxx/admin/";
>
> but i already set all the media file to 777, and the path is correct.
>
> (site-env)[r...@201940 css]# ls -l
> total 56
> -rwxrwxrwx 1 peng root 12247 Dec 26 22:45 base.css
> -rwxrwxrwx 1 peng root  5059 Dec 26 22:45 changelists.css
> -rwxrwxrwx 1 peng root   329 Dec 26 22:45 dashboard.css
> -rwxrwxrwx 1 peng root  5721 Dec 26 22:45 forms.css
> -rwxrwxrwx 1 peng root   963 Dec 26 22:45 ie.css
> -rwxrwxrwx 1 peng root   780 Dec 26 22:45 login.css
> -rwxrwxrwx 1 peng root  3306 Dec 26 22:45 rtl.css
> -rwxrwxrwx 1 peng root  9009 Dec 26 22:45 widgets.css
>
> i put the django admin folder into the site_media:
>
> So the project tree is like:
>     apps
>     logs
>     site_media
>              media
>              static
>              admin
>      templates
>      settings.py
>      manage.py
>      urls.py
>
> (site-env)[r...@201940 css]# pwd
> /home/peng/jiangyo/site_media/admin/css
>
> the following is my configure about Nginx & django settings.py
>
> settings.py:
>
> # URL prefix for admin media -- CSS, JavaScript and images. Make sure
> to use a
> # trailing slash.
> # Examples: "http://foo.com/media/";, "/media/".
> ADMIN_MEDIA_PREFIX = "/site_media/admin/"
>
> ngins.conf
>
>   server
>   {
>     listen      xxx.xxx.xxx.xxx;
>
>     location /
>     {
>       #fastcgi_pass  unix:/tmp/php-cgi.sock;
>       fastcgi_pass  127.0.0.1:8080;
>       include fastcgi_django.conf;
>     }
>
>     location ^~ /site_media/admin/ {
>         alias /home/peng/jiangyo/site_media/admin/;
>     }
>
>     log_format  wwwlogs  '$remote_addr - $remote_user [$time_local]
> "$request" '
>                '$status $body_bytes_sent "$http_referer" '
>                '"$http_user_agent" $http_x_forwarded_for';
>     access_log  /home/peng/jiangyo/logs/access_info.log  wwwlogs;
>     error_log  /home/peng/jiangyo/logs/error_info.log;
>   }
>
> the following are the html source from the firebug,
>
> <link href="/site_media/admin/css/base.css" type="text/css"
> rel="stylesheet">
>     1<html>
>     2<head><title>403 Forbidden</title></head>
>     3<body bgcolor="white">
>     4<center><h1>403 Forbidden</h1></center>
>     5<hr><center>nginx/0.7.68</center>
>     6</body>
>     7</html>
>
> Can anyone help me for resolve this problem. I really want the admin
> function be OK.
>
> Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to