Pages

Wednesday 1 May 2013

Mod-wsgi: Installation on Apache2



sudo apt-get install libapache2-mod-wsgi
This should install the module. Now to activate it:

        sudo a2enmod mod-wsgi

Now to restart Apache2:
        sudo /etc/init.d/apache2 restart


Okay, we have the module installed and ready to go, but now we need to associate the module with the ".wsgi" extension on your server. This will make files with a .wsgi extension use the wsgi module for processing.

 Open up /etc/apache2/sites-available/default:

     sudo gedit /etc/apache2/sites-available/default

Around line 10, you should have something like this:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>

Chang it to match this:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews ExecCGI

AddHandler cgi-script .cgi
AddHandler wsgi-script .wsgi

AllowOverride None
Order allow,deny
allow from all
</Directory>

That's it. Restart Apache:

      sudo /etc/init.d/apache2 restart

You're done!

If you want to make "index.wsgi" act as an index for your directory (much like index.htm, index.html, index.php), open up /etc/apache2/mods-enabled/dir.conf:
        sudo gedit /etc/apache2/mods-enabled/dir.conf

And change line 3 (the line that has the DirectoryIndex) to:
          DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm index.wsgi

Okay, that's it. Please reply to the thread if you see any problems or possible improvements. I didn't spend a whole lot of time on this... so I hope everything works. PHP and wsgi files should run next to each other perfectly.


No comments:

Post a Comment