Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We are trying to get out wsgi application working on mod_wsgi. We have run it before using wsgiref.simple_server, as a debugging environment. Now, we want to move it over to using Apache httpd to integrate with loading static files under the same port, and to provide an environment more suitable for production.

The httpd.conf file we have set up looks like this:

<VirtualHost *:80>

    DocumentRoot /var/www/

    ErrorLog /var/www/log/error_log

    LogLevel debug

    WSGIScriptAlias /app /var/www/python/resource/rest.py

    <Directory /var/www/python/>
            Order allow,deny
            Allow from all
    </Directory>

    <Directory />
            Order allow,deny
            Allow from all

            RewriteEngine On
            # Some rewrites go here

    </Directory>

</VirtualHost>

With this setup, we can access the main application file, rest.py (under http://myhost/app), but any imports to modules (like from module1 import function where module1 is under the same directory as rest.py) are failing with an ImportError.

I suspect this has to do with having to set some sort of environment variable, but I have added /var/www/python to sys.path on the main application method and it doesn't work. Any help or pointers with this would be really appreciated.

Thanks!

share|improve this question
    
In which directory is 'module1' located? Do all the code files have permissions such that user that Apache runs as can read them? –  Graham Dumpleton Nov 6 '12 at 1:29
    
Module 1 is located under the same directory as rest.py. Yes, I actually set the permissions to 777 to avoid any problem like that. –  Juan Carlos Coto Nov 6 '12 at 15:11
add comment

closed as off-topic by Jenny D, Michael Hampton Feb 28 at 22:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Michael Hampton
If this question can be reworded to fit the rules in the help center, please edit the question.