Hello,

I've been trying to upload and then serve user-uploaded files on my website 
built using Django 1.8.8 and running on Apache 2.2.15, with mod_wsgi 
version 4.4.23.

Per this blog
http://blog.dscpl.com.au/2015/04/using-modwsgi-express-with-django.html

the media files are also supposed to be also located/served from the same 
locations as specified by STATIC_ROOT and STATIC_URL in Django settings.

But latest versions of Django disallow that, and I get this error if they 
are the same.

 File 
"/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py",
 
line 56, in check_settings
    raise ImproperlyConfigured("The MEDIA_URL and STATIC_URL "
ImproperlyConfigured: The MEDIA_URL and STATIC_URL settings must have 
different values

I used the following options to generate the httpd.conf

(vishwaas_env)[syt_admin@VM1 vishwaas_django]$ python manage.py runmodwsgi 
--setup-only  --https-port=443 --port=80 --server-name=www.xyz.in 
--user=apache --group=apache 
--server-root=/home/syt_admin/projects/vishwaas/www-https 
--ssl-certificate-file=/home/syt_admin/projects/vishwaas/www-https/startssl-certs/2_www.xyz.in.crt
 
--ssl-certificate-key-file=/home/syt_admin/projects/vishwaas/www-https/startssl-certs/server.key
 
--ssl-certificate-chain-file=/home/syt_admin/projects/vishwaas/www-https/startssl-certs/1_root_bundle.crt

Since I am using runmodwsgi, I did not specify the --url-alias. The static 
directive is automatically generated in my httpd.conf as follows:

*Alias '/static' 
'/home/syt_admin/projects/vishwaas/vishwaas_django/collected_static'*

*<Directory 
'/home/syt_admin/projects/vishwaas/vishwaas_django/collected_static'>*
*    Order allow,deny*
*    Allow from all*
*</Directory>*

But there is no directive corresponding to /media.

I then manually edited httpd.conf and added the following lines:

*Alias '/media' '/home/syt_admin/projects/vishwaas/www-https/media'*

*<Directory '/home/syt_admin/projects/vishwaas/www-https/media'>*
*    Order allow,deny*
*    Allow from all*
*</Directory>*

Now I am able to serve the user-uploaded files on the website.

My question is - how should I tell mod_wsgi-express to generate these 
directives automatically?

I guess I could use the --url-alias option but it takes two pieces of info 
(URL-PATH and DIRECTORY-PATH), so how do I specify it using 'python 
manage.py runmodwsgi'?
What is the syntax?

Please advise what is the best practice here.

Regards,
Tanuka

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to