Ok, I modified the django.wsgi and instead put in the root of my app. Here are the contents of the file:
import os import sys sys.path.insert(0, '/home/charles/projects/python/firstdjango') os.environ['DJANGO_SETTINGS_MODULE'] = 'firstdjango.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() This does not give me an error. It presents me with the Django welcome page and tells me I haven't configured a database or anything in my settings. Obviously I have configured all of this stuff. I'm not sure whether I'm getting closer or farther away from success. On May 12, 9:13 pm, Graham Dumpleton <[email protected]> wrote: > On 13 May 2011 11:06, Chuck <[email protected]> wrote: > > > This is the content of my wsgi file in my Django project. > > > import os, sys > > > # path to directory of the .wsgi file ('apache/') > > wsgi_dir = os.path.abspath(os.path.dirname(__file__)) > > So the WSGI script file is in directory something like > .../parent/firstdjango/apache directory. > > > # path to project root directory (parent of 'apache/') > > project_dir = os.path.dirname(wsgi_dir) > > This give project_dir as '.../parent/firstdjango'. > > > # add project directory to system's PATH > > sys.path.append(project_dir) > > You are only adding '.../parent/firstdjango' to sys.path. > > > # add the settings.py file to your system's PATH > > project_settings = os.path.join(project_dir,'settings') > > > # explicitly define the DJANGO_SETTINGS_MODULE > > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' > > > import django.core.handlers.wsgi > > application = django.core.handlers.wsgi.WSGIHandler() > > > I only have one settings file,which is named settings.py. > > > Now it's giving me an error about not finding TemplateSyntaxError: > > Caught ImportError while rendering: No module named firstdjango.books > > Which fails, because '.../parent' is not in sys.path. > > You would also need: > > sys.path.append(os.dirname(project_dir)) > > else it can't find 'firstdjango' in sys.path when search for project > package root. > > For additional reading on the sys.path mess that Django has got itself > into read: > > http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html > > Graham > > > I have a project under my main app called books. The project is > > called firstdjango. > > > I'll look at your post about permissions. > > > On May 12, 8:52 pm, Graham Dumpleton <[email protected]> > > wrote: > >> Quickest answer is for me to say go watch: > > >> http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_... > > >> In that presentation I step through sys.path issues as well as > >> permission issues. > > >> Also ensure you have also read: > > >> http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > > >> taking note of what it says about sys.path. > > >> Graham > > >> On 13 May 2011 10:40, Chuck <[email protected]> wrote: > > >> > It looks like the mod_wsgi module is getting loaded. Now the problem > >> > seems to exist in my django.wsgi script within my Django app. When > >> > looking at the Apache error log I am seeing this: > > >> > Exception occurred processing WSGI script > > >> > ImportError: Could not import settings 'firstdjango.settings' (Is it > >> > on sys.path? Does it have syntax errors?): No module named > >> > firstdjango.settings > > >> > On May 12, 8:27 pm, Graham Dumpleton <[email protected]> > >> > wrote: > >> >> On 13 May 2011 10:25, Chuck <[email protected]> wrote: > > >> >> > Doing some research in other posts...I have at least gotten further > >> >> > along. I had to figure out a way to include the mod_wsgi module in > >> >> > the Apache modules. So I did this: > > >> >> > Solution – enable mod_wsgi on SuSE linux > > >> >> > 1. Edit the file /etc/sysconfig/apache2 as root: > >> >> > 1. search for APACHE_MODULES, you should find a line like > >> >> > this > >> >> > APACHE_MODULES="suexec access actions alias auth auth_dbm > >> >> > autoindex cgi dir env expires include log_config mime negotiation > >> >> > setenvif userdir ssl php4" > >> >> > 2. Add wsgi to the content in the list between the “ > >> >> > 3. Save the changes and quit > >> >> > 2. run SuSEconfig to update the apache configuration files > >> >> > 3. run /etc/init.d/apache2 restart to restart the Apache server > > >> >> Thanks for that. I didn't know that SuSE was so weird when it came to > >> >> enabling of the modules. > > >> >> Graham > > >> >> > Verify that the mod_wsgi module is installed correctly > > >> >> > /usr/sbin/httpd2 -M > >> >> > Loaded Modules: > >> >> > core_module (static) > >> >> > mpm_prefork_module (static) > >> >> > http_module (static) > >> >> > so_module (static) > >> >> > actions_module (shared) > >> >> > alias_module (shared) > >> >> > auth_basic_module (shared) > >> >> > authn_file_module (shared) > >> >> > authz_host_module (shared) > >> >> > authz_groupfile_module (shared) > >> >> > authz_default_module (shared) > >> >> > authz_user_module (shared) > >> >> > autoindex_module (shared) > >> >> > cgi_module (shared) > >> >> > dir_module (shared) > >> >> > env_module (shared) > >> >> > expires_module (shared) > >> >> > include_module (shared) > >> >> > log_config_module (shared) > >> >> > mime_module (shared) > >> >> > negotiation_module (shared) > >> >> > setenvif_module (shared) > >> >> > ssl_module (shared) > >> >> > userdir_module (shared) > >> >> > wsgi_module (shared) > >> >> > Syntax OK > > >> >> > When I restart Apache it's not giving me an error anymore. I'll post > >> >> > more info as I go. > > >> >> > On May 12, 8:00 pm, Chuck <[email protected]> wrote: > >> >> >> I'm sorry if this is a pain to answer this question because it > >> >> >> probably is the "stock" newbie whine. > > >> >> >> I'm getting the ubiquitous Invalid command 'WSGIScriptAlias', perhaps > >> >> >> misspelled or defined by a module not included in the server > >> >> >> configuration > > >> >> >> when i try to boot up the Apache server. > > >> >> >> I have already tried some of the recommendations in the installation > >> >> >> help files. > > >> >> >> I'm willing to do what it takes to get this to work... > > >> >> >> Some background info: > > >> >> >> -- Django 1.2.5 (SUSE repo install) > >> >> >> -- Python 2.6 (SUSE repo install) > >> >> >> -- Server version: Apache/2.2.15 (Linux/SUSE) > >> >> >> -- mod_wsgi 3.3.17 (SUSE repo install) installed this in my > >> >> >> /usr/lib64/ > >> >> >> apache2/mod_wsgi.so > > >> >> >> I tried to configure this according to the book Beginning Django E- > >> >> >> commerce. The author suggested you create a virtual host, which I > >> >> >> did. In SUSE you create a virtual host configuration file at/etc/ > >> >> >> apache2/v.hosts.d. It's pointing to where my Django project is > >> >> >> located. Within my Django project I have an apache folder in which I > >> >> >> have placed a django.wsgi file. I've not changed anything in my > >> >> >> httpd.conf. > > >> >> >> /usr/sbin/httpd2 -M > > >> >> >> Loaded Modules: > >> >> >> core_module (static) > >> >> >> mpm_prefork_module (static) > >> >> >> http_module (static) > >> >> >> so_module (static) > >> >> >> actions_module (shared) > >> >> >> alias_module (shared) > >> >> >> auth_basic_module (shared) > >> >> >> authn_file_module (shared) > >> >> >> authz_host_module (shared) > >> >> >> authz_groupfile_module (shared) > >> >> >> authz_default_module (shared) > >> >> >> authz_user_module (shared) > >> >> >> autoindex_module (shared) > >> >> >> cgi_module (shared) > >> >> >> dir_module (shared) > >> >> >> env_module (shared) > >> >> >> expires_module (shared) > >> >> >> include_module (shared) > >> >> >> log_config_module (shared) > >> >> >> mime_module (shared) > >> >> >> negotiation_module (shared) > >> >> >> setenvif_module (shared) > >> >> >> ssl_module (shared) > >> >> >> userdir_module (shared) > > >> >> >> Questions: > >> >> >> 1) should I have created mod_wsgi from source? > >> >> >> 2) should I be fooling around with a virtual host? > > >> >> >> I'm willing to provide any other information needed. > > >> >> > -- > >> >> > You received this message because you are subscribed to the Google > >> >> > Groups "modwsgi" group. > >> >> > To post to this group, send email to [email protected]. > >> >> > To unsubscribe from this group, send email to > >> >> > [email protected]. > >> >> > For more options, visit this group > >> >> > athttp://groups.google.com/group/modwsgi?hl=en. > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups "modwsgi" group. > >> > To post to this group, send email to [email protected]. > >> > To unsubscribe from this group, send email to > >> > [email protected]. > >> > For more options, visit this group > >> > athttp://groups.google.com/group/modwsgi?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "modwsgi" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group > > athttp://groups.google.com/group/modwsgi?hl=en. -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
