Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a flask website in a subdirectory with apache

I'm using apache on my personal server, and I'm trying to run a 'main' website made with Silex on www.mydomain.com/ and another one made using Flask on www.mydomain.com/something

To run the Flask website I'm using mod_wsgi as explained on their official website (http://flask.pocoo.org/docs/deploying/mod_wsgi/).

It works just fine, I can reach my website at www.mydomain.com/something, but when I go back to www.mydomain.com/ I get a Flask 404 error message.

I've tried checking the apache doc about virtual hosts but I can't make sense of it, here is my current 'sites-enabled/defaults' configuration file :

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

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

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        WSGIDaemonProcess bc user=bc group=bc threads=5
        WSGIScriptAlias / /var/www/bc/bc.wsgi
        <Directory /var/www/bc>
                   WSGIProcessGroup bc
                   WSGIApplicationGroup %{GLOBAL}
                   Order deny,allow
                   Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

my /var/www directory looks like this :

./index.php

./bc/

./bc/index.py

How can I get the python website to only work in www.mydomain.com/something and let the PHP one run on www.mydomain.com/ ?

like image 881
Damien T Avatar asked Jan 06 '13 10:01

Damien T


1 Answers

The first parameter to WSGIScriptAlias is the url path, by specifying WSGIScriptAlias / <foo> you're telling apache to send all requests to the WSGI app. Try WSGIScriptAlias /something <foo>

like image 180
DazWorrall Avatar answered Sep 22 '22 21:09

DazWorrall