Skip to content Skip to sidebar Skip to footer

Error While Uploading Django Project To A Apache Server Via Mod_wsgi

I created a droplet(cloud server) on DigitalOcean and with no-ip.com I gave it the hostname - project.ddns.net.By ssh(ing) into the droplet I installed pip and virtualenv. Inside /

Solution 1:

add this line to you wsgi.py file : sys.path.append('/var/www/project_revamped/project') before os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings.dev' and check if it works.

Solution 2:

You may have a look at my VirtualHost configuration for Apache with mod_wsgi. This template can be automatically filled during project-creation, but you may be able to fill/replace variables and strip it down to your needs:

<VirtualHost *:80>
    # This is name based virtual hosting. So place an appropriate server name#   here. Example: django.devsrv.local
    ServerName  [[SERVER_NAME]]
    ServerAdmin webmaster@localhost

    # This alias makes serving static files possible.#   Please note, that this is geared to our settings/common.py#   In production environment, you will propably adjust this!
    Alias /static/  {{ project_directory }}/run/static/

    # This alias makes serving media files possible.#   Please note, that this is geared to our settings/common.py#   In production environment, you will propably adjust this!
    Alias /media/  {{ project_directory }}/run/media/

    # Insert the full path to the wsgi.py-file here
    WSGIScriptAlias /   {{ project_directory }}/{{ project_name }}/wsgi.py

    # PROCESS_NAME specifies a distinct name of this process#   see: https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess# PATH/TO/PROJECT_ROOT is the full path to your project's root directory, #   containing your project files# PATH/TO/VIRTUALENV/ROOT: If you are using a virtualenv specify the full#   path to its directory.#   Generally you must specify the path to Python's site-packages.
    WSGIDaemonProcess   {{ project_name }}  python-path={{ project_directory }}:{{ project_directory }}/../lib/python2.7/site-packages

    # PROCESS_GROUP specifies a distinct name for the process group#   see: https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIProcessGroup
    WSGIProcessGroup    {{ project_name }}

    # Serving static files from this directory#   Please note, that this is geared to our settings/common.py#   In production environment, you will propably adjust this!
    <Directory {{ project_directory }}/run/static>
        Options -Indexes
        Order deny,allow
        Allow from all
    </Directory>

    # Serving media files from this directory#   Please note, that this is geared to our settings/common.py#   In production environment, you will propably adjust this!
    <Directory {{ project_directory }}/run/media>
        Options -Indexes
        Order deny,allow
        Allow from all
    </Directory>

    LogLevel warn

    # PROJECT_NAME is used to seperate the log files of this application
    ErrorLog    ${APACHE_LOG_DIR}/{{ project_name }}_error.log
    CustomLog   ${APACHE_LOG_DIR}/{{ project_name }}_access.log combined
</VirtualHost>

You may see my project-skeleton on GitHub and here is the documentation of the Apache2-conf on RTD.org

Post a Comment for "Error While Uploading Django Project To A Apache Server Via Mod_wsgi"