Friday, February 7, 2014

Re: Django deployment - problems with static files

You need to change the permissions of the static files that the webserver user could access those.




2014-02-07 18:29 GMT+01:00 <bhudspeth60@gmail.com>:
Hello,

I am trying to deploy a new Django website where I am trying to point to many css, js, image, pdf files, etc. Everything works well in the development setup.

Basically, I am using a mod-wsgi setup in Apache, and Django version 1.5 on Ubuntu linux 12.10. The application is served with the template and page content visible. It is clear, however, that my application cannot "see" the css, js, and images that support the pages.

I am trying to emulate a previous website that is successfully served, but am having these problems.

My setup is as follows:

Application location examples:

/home/eps_admin/epsWeb/epsWeb/settings.py
/home/eps_admin/epsWeb/epsWeb/urls.py
/home/eps_admin/epsWeb/epsWeb/site-media/images #all images
/home/eps_admin/epsWeb/epsWeb/site-media/css   #css files
/home/eps_admin/epsWeb/epsWeb/site-media/js   #js files
...etc....

In my Django pages... I try to load files with hard coded links like this...

/site-media/images/image.png
/site-media/css/styles.css
/site/media/js/javascript.js

My httpd.conf:

WSGIScriptAlias / /home/eps_admin/epsWeb/epsWeb/wsgi.py
WSGIPythonPath /home/eps_admin/epsWeb/


<VirtualHost 129.24.36.34:80>

        Alias /site-media/ /home/eps_admin/epsWeb/epsWeb/site-media/
        Alias /images/ /home/eps_admin/epsWeb/epsWeb/site-media/images/
        AliasMatch ^/([^/]*\.css) /home/eps_admin/epsWeb/epsWeb/site-media/css/


        ServerName epswww1.unm.edu
        ServerAlias epswww1.unm.edu
        ServerAdmin epswww1.unm.edu
        ErrorLog ${APACHE_LOG_DIR}/epswww1_errors.log

        DocumentRoot /home/eps_admin/epsWeb/      

        <Directory /home/eps_admin/epsWeb/epsWeb>

        <Files wsgi.py>
        Order allow,deny
#       Order deny,allow
#       Require all granted
        Allow from all
        </Files>
        </Directory>

</VirtualHost>


Relevant settings in settings.py
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
MEDIA_URL = "/media/"
STATIC_ROOT = os.path.join(PROJECT_PATH, "static")
STATIC_URL = '/static/'

This setup has worked well on another site I have running in production, but doesn't seem to work here. I would appreciate any help on what I am doing wrong.

Thanks much,  Wilbur

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2aa7d632-caab-464c-b15f-93d02b7ccee5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPDLAU5Qg7R6Lw-oVZtXNRz69-VrnBwUoNKfs2jG9KZuHWGO6w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment