Yes, this worked: 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 * —url-alias /media /home/syt_admin/projects/vishwaas/www-https/media*
The generated httpd.conf now contains the /media directive, and I've tested that the user-uploaded file is served on the website. It's a bit counter-intuitive because all the other options are in the form --option=value whereas this one is separated by spaces. Probably needs to be added to the documentation? Regards, Tanuka On Wed, Mar 9, 2016 at 3:20 PM, Graham Dumpleton <[email protected] > wrote: > It is --url-alias, not --url_alias. > > > On 9 Mar 2016, at 8:49 PM, Tanuka Dutta <[email protected]> wrote: > > I get this error: > > Usage: manage.py runmodwsgi [options] > > Starts Apache/mod_wsgi web server. > > manage.py: error: no such option: --url_alias > > Regards, > Tanuka > > On Wed, Mar 9, 2016 at 3:05 PM, Graham Dumpleton < > [email protected]> wrote: > >> Have you tried adding at the end of your runmodwsgi command: >> >> —url-alias /media /home/syt_admin/projects/vishwaas/www-https/media >> >> That should be all that is required. >> >> If Django has a first class concept of a media directory now and will >> when running the development server automatically serve up files based on >> MEDIA_ROOT and MEDIA_URL, then the Django integration for mod_wsgi-express >> probably should be updated to handle it automatically. >> >> Graham >> >> On 9 Mar 2016, at 7:09 PM, Tanuka Dutta <[email protected]> wrote: >> >> 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. >> >> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "modwsgi" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/modwsgi/XhvKm3jVV38/unsubscribe. >> To unsubscribe from this group and all its topics, 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. >> > > > -- > 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. > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "modwsgi" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/modwsgi/XhvKm3jVV38/unsubscribe. > To unsubscribe from this group and all its topics, 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. > -- 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.
