Apache mod_wsgi error: Forbidden You don't have permission to access / on this server

后端 未结 5 1766
长发绾君心
长发绾君心 2020-12-01 14:35

I\'m using Ubuntu 10.04.
I create a django project under /home/wong2/Code/python/django2/ named atest
and create a wsgi file setting.

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 15:25

    try http://localhost/index.html does that show the apache page?

    If you wsgi is configured on root correctly it wont.

    You get that error message because you might be asking the webserver for the directory listing of www folder

    edit:

    My projects are always in

    /var/pyproj//pysrc/ and server files i put in /var/py_proj//server/

    Here is my go to wsgi script

    import os, sys
    
    import logging
    logger =logging.getLogger("")
    logger.setLevel(logging.DEBUG)
    handler = logging.StreamHandler(sys.stderr)
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(levelname)-8s %(messages)s')
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    
    sys.stdout = sys.stderr
    from os.path import abspath, dirname, join
    import site
    
    PROJECT_ROOT = abspath(join(dirname(__file__), "../pysrc"))
    SETTINGS_LOC = abspath(join(PROJECT_ROOT, ''))
    site.addsitedir(SETTINGS_LOC)
    os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
    
    from django.core.management import setup_environ
    import settings
    setup_environ(settings)
    
    sys.path.insert(0, join(PROJECT_ROOT, "apps"))
    
    from django.core.handlers.wsgi import WSGIHandler
    
    application = WSGIHandler()
    

    and i use a vhost.conf

    WSGIDaemonProcess pinax_demo user=www-data group=www-data threads=10 python-path=/var/.virtualenvs/pinax_demo/lib/python2.6/site-packages
    
    
        Order deny,allow
        Allow from all
    
    
    Alias /pinax_demo /var/py_proj/pinax_demo/server/pinax_demo.wsgi
    
        #WSGIProcessGroup must match the WSGIDaemonProcess
        WSGIProcessGroup pinax_demo
        SetHandler wsgi-script
        Options +ExecCGI
    
    

    which i include in the sites-available folder in a file that looks like this

    
            DocumentRoot /var/www/
    
            
                    Order deny,allow
                    Allow from all
                    Options -Indexes FollowSymLinks
                    DirectoryIndex index.php
                    AllowOverride None
            
    
            ServerAdmin oto@example.com
    
            LogLevel error
            ErrorLog  /var/srv_logs/apache_error.log
            CustomLog  /var/srv_logs/apache_access.log combined
            #insert
            Include /var/py_proj/pinax_demo/server/vhost.conf
            Include /var/py_proj//server/vhost.conf
            Include /var/py_proj//server/vhost.conf
    
    
    

    httpd.conf is empty. Apache is also terrible at sending static files so i have my apache setup on port 8080 and nginx setup on port 80 which forwards to apache. You should be able to just change the port on my sites-avaiable file to run it without nginx but i would not go live that way

提交回复
热议问题