I'm in a university and I'm provided with a public_html folder where I can put my CGI scripts. For eg. when I put PHP scripts and visit them from my browser, it works correctly and the PHP is properly interpreted.
I wish to run Django apps in this environment and I know that the university runs an apache server and had mod_php and mod_python installed, although I think I'm not allowed to modify the httpd.conf etc.
All the tutorials that I've read about Django on mod_python ask me to modify the httpd.conf, is there any way I can get my Django site running by making non-sudo changes only?
You can try to put your directives in a .htaccess file in your directory. Dependent on the server config, it might work.
Related
I'm new to Django and Apache, so apologies if my terminology is a bit off.
I have a Django app that I'm serving with Apache using mod_wsgi. I used this guide, and just switched to Apache from the Django dev server. In my 000-default.conf file I have this line
WSGIScriptAlias / /home/ubuntu/Projects/myapp/wsgi.py
Everything works fine and the homepage of my app is example.com. However, I find now that there are images (a few tilesets) that I was previously accessing at example.com/tiles which are now not accessible, because they are actually stored at /var/www/html/tiles.
I understand why the paths aren't working, but I'm wondering if there's a way I can keep running the django site from example.com while also serving the tiles from a different directory.
I think if you add a preceding configuration directive:
Alias /tiles /var/www/html/tiles
... it should fix it.
Please note that order of Apache configuration directives may matter. More information about Apache and Alias.
I finished my project in the development server and now I worked it using Apache in the localhost. The project worked good. Now, I got an apache sever. can you please clarify some of my doubts;
1. Need to upload the Django installation files, mod_wsgi and any other files to the server?
2. Can I maintain the same folder directory as I did with the local host Apache?
3. what is httpd.conf, and where can I find it in my server?
I am using Linux ubuntu OS, Python 2.7, Django 1.6 and my server got its first level of directories like:
.cpanel, .htpasswords, cpmove.psql, etc, logs, mail, public_ftp, ssl, tmp, www, access-logs and some more .conf and other type files.
Among above directories, I can't open the www folder.
Please suggest any tutorial or some other way to resolve things. It will be very helpful for me and my team.
Thanks in advance
I have a Django app set up with Apache and mod_wsgi and it's working fine. I have a Zinnia blog under the same app functioning at the /blog/ subdirectory. So, the blog is www.mysite.com/blog/. What I wanna do is have blog.mysite.com/ point to the /blog/ subdirectory. I'm stumped because I don't know if I should do this through Django or Apache. So, any ideas?
This has to be done with Apache config.
I think you have to setup a Reverse Proxy, which will listen to blog.mysite.com domain and proxy requests to www.mysite.com/blog/.
Unfortunately I'm not an Apache pro, so can't help you with configuration.
Completely from memory and can't test it right now, but in the VirtualHost for blog.mysite.com mount it as:
WSGIScriptAlias / /some/path/wsgi.py/blog
In other words, you still mount it with mod_wsgi, but add '/blog' to the end of the target WSGI script path. This should from memory cause Apache and mod_wsgi to remap things so that '/blog' automatically gets added as part of the URL seen by the Django application. Thus it should map to the blog mapped at that location in the URL namespace in the Django urls.py.
Do note that because you are doing it with a distinct WSGIScriptAlias, it will actually load up a second copy of your Django site in memory in a different sub interpreter than the first one. If that is undesirable, you can use WSGIApplicationGroup directive to override which application group they are both running in and set them to be the same. Preferably use mod_wsgi daemon mode if you aren't already and have them run distinct from the Apache child worker processes as well, as that is generally better than using embedded mode.
I am very new to apache and django, so execuse me if this question is simple. I am trying to deploy an existing site to an apache server. For the time being, the site is still in development so I am only deploying it as a virtualhost on my local machine.
I am using Django's WSGI module in the deployment. In my site's config file, I have the following aliases:
Alias /media/ /home/tester/Desktop/siteRootDir/media
Alias /content/ /home/tester/Desktop/siteRootDir/content
WSGIScriptAlias /c /home/tester/Desktop/siteRootDir/deploy/site.wsgi
When I run apache and go to localhost/c I was getting the (13)PermissionDenied error in the apache log. To get around that error, I (admitedly stupidly) ran
chmod -R 777 /home/tester/Desktop/siteRootDir
I know that is not the way to deal with the issue, but I just wanted the site to work so I can continue its development.
So my question is, what are the correct permission settings to the siteRootDir directory and its sub-directories such that the site will run and I do not expose unnecessary files in the directory.
Also, I realize that this is not an ideal set up and I will likely run into problems when I deploy the site in production. Can anyone please suggest a better organizational approach to this?
Thanks!
The tightest permissions possible would be 0600 for files and 0700 for dir's and as a owner the user owning the apache processes. This user differs per OS and flavor (e.g. for OSX it's www, for Debian/Ubuntu it's www-data).
This would probably too tight for a development server. At least would you like to be able to modify all your files through your IDE of text editor, so either you should add ACLs for yourself (i.e. the user that edits the Django files, templates and static files).
Also, in a production server you want the apache user to be able to write to directories that hold web uploaded content. That would be somewhere in your static files section (or on a different dedicated static files server).
I've got a ubuntu vps and apache mod wsgi installed and serving my django sites.
however i have to restart all of apache rather than the site i have amended and its going to be a bit shonky if i tell clients that i have restarted their site cos i updated another site.
is there a tutorial somewhere to teach me how to configure this? i couldnt find one in googles keywords soup.
I'm already using virtualenvs if it helps.
Assuming you use mod_wsgi in daemon mode on UNIX/Apache 2.X system to run Django and have shell access to your machine all you need to do is touch the wsgi configuration for your project.
touch your_project.wsgi
See mod_wsgi documentation on Reloading Source Code and Django - mod_wsgi wiki for more references.