Monday, May 11, 2015

[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:

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/

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

  • Add a wsgi file: /home/liudanny/django_proj/

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]


No comments: