خرید بک لینک

Yesterday I received my Raspbarri PI 3, which I ordered to experiment around. It's up and ruing with Ubuntu MATE, and coected to the network. Now I've got a few little Django projects (1.9) which I want to serve over the network for testing.

The problem is that when I attempt to access http: //nrzonline/ on my guest machine, it does show the files and folders of the on the server of the /home/www/nrzonline/ directory. But the files are plain text, and do not get executed as expected.

Currently I'll use the website 'nrzonline' as example:

taken steps

  • forwarded port 80 for http on router
  • forwarded port 22 for ssh on router

  • pyton 2.7 is installed
  • apache 2.4 is installed
  • libapache2-mod-wsgi is installed
  • apache2-mpm-prefork apache2-utils libexpat1 ssl-cert are installed
  • virtualenv is installed

  • The project source is located in /home/www/nrzonline/
  • The virualenv with requirements in ~/.virtualenvs/
  • Added nrzonline.conf to /etc/apache2/sites-available/ (snippet below)
  • a2dismod mpm_event and a2enmod mpm_prefork cgi
  • a2ensite nrzonline without errors
  • Restarted apache2

  • Python settings.py allowed hosts ['*'] (all)
  • wsgi.py adds the site packages from virtualenv (wsgi.py snippet below)
  • Updated hosts files on the server and guest machine (snippet below)

Snipptes

/etc/apache2/sites-available/nrzonline.conf

<VirtualHost *:80>
        ServerAdmin admin@server.com
        ServerName nrzonline.nl
        ServerAlias nrzonline

        DocumentRoot /home/www/nrzonline/
        WSGIScriptAlias /nrzonline/ /home/www/nrzonlne/nrzonline/wsgi.py
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/www/nronline/>
                Options Indexes MultiViews
                Options +ExecCGI
                DirectoryIndex nrzonline/wsgi.py
                AllowOverride All
                Require all granted
        </Directory>
        AddHandler cgi-script .py

        Alias /static/ /home/www/nrzonline/static/
        <Location "/static/">
            Options -Indexes
        </Location>
</VirtualHost>

/home/www/nrzonline/nrzonline/wsgi.py

import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/.virtualenvs/nrzonline/lib/python2.7/site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('/home/www/nrzonline')
sys.path.append('/home/www/nrzonline/nrzonline')

os.environ['DJANGO_SETTINGS_MODULE'] = 'nrzonline.settings'

# Activate your virtual env
activate_env=os.path.expanduser("~/.virtualenvs/nrzonline/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

ease let me know if you need more details about the current setup, so I can add it to the question. Thank yo

Server host file + Guest host file

127.0.0.1       localhost
[..cut..]
192.168.2.254   router
192.168.2.5     server nrzonline

# The following lines are desirable for IPv6 capable hosts
[..cut..]


Personally I think I'm on the wrong direction with enabling wsgi on apache2 , and invoking it within my available-sites/nrzonline.conf I Hope somebody can push me in the right direction where to take another good look at. Please let me know if you need more details about the current setup, so I can add it to the question.

Thank you.

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 27 اسفند 1394 ساعت: 1:11

صفحه بندی