[Apache] Install Apache2 and mod_wsgi module

Install Apache Web Server
sudo apt-get install apache2 apache2-threaded-dev apache2-doc apache2-utils

  • Edit the main Apache configuration file to adjust the resource use settings.
    • /etc/apache2/apache2.conf


Install Support for Scripting ( Python )
sudo apt-get install libapache2-mod-python

  • An easy way to see which modules are installed is to run a list command on the directory:
    • ls -al /etc/apache2/mods-available/


  • To enable an installed module, run the following command:
    • a2enmod [module-name]


Install Apache Modules
sudo apt-get install libapache2-mod-wsgi

or to follow this intruction to compile and install from the source code:
https://code.google.com/p/modwsgi/wiki/QuickInstallationGuide

Operate Apache Web Server
  • sudo apachectl restart
  • sudo apachectl stop
  • sudo apachectl start

Give a try with WSGI 

  • Add the following setting to /etc/apache2/sites-available/default

WSGIScriptAlias /myapp /home/liudanny/django_proj/myapp.py

<Directory /home/liudanny/django_proj>
    Order allow,deny
    Allow from all
</Directory>


  • Add a wsgi file: /home/liudanny/django_proj/myapp.py

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                    ('Content-Length', str(len(output)))]
    start_response(status, response_headers)
    return [output]


Ref:
https://www.linode.com/docs/websites/apache/apache-2-web-server-on-debian-7-wheezy
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/

Comments

Popular posts from this blog

[Open vSwitch] How to get port statistics from interface in OVS

[Quagga] How to compile and install Quagga on Ubuntu 12.04

[JSON] How to use jansson lib to generate JSON data in C