python - deploy flask application on ubuntu/apache2: virtual host configuration -
i'm trying deploy python/flask application on apache2 installation on ubuntu (14.04), following instructions @ link
the application seems work , if point browser http://mywebsite.com/
correctly see message returned flask application.
my problem is, if want install second site different virtual host on same machine (say non-python application)? virtual host mapped url http://mywebsite.com/flaskapp
, while having possibility define virtual host @ http://mywebsite.com/myotherwebapp
this flaskapp.conf file per instructions on mentioned article:
<virtualhost *:80> servername mywebsite.com serveradmin admin@mywebsite.com wsgiscriptalias / /var/www/flaskapp/flaskapp.wsgi <directory /var/www/flaskapp/flaskapp/> order allow,deny allow </directory> alias /static /var/www/flaskapp/flaskapp/static <directory /var/www/flaskapp/flaskapp/static/> order allow,deny allow </directory> errorlog ${apache_log_dir}/error.log loglevel warn customlog ${apache_log_dir}/access.log combined </virtualhost>
and here how /var/www
folder structured after installed python app
/var/www +-- flaskapp ¦ +-- flaskapp ¦ ¦ +-- flaskenv ¦ ¦ +-- __init__.py ¦ ¦ +-- __init__.pyc ¦ ¦ +-- static ¦ ¦ +-- templates ¦ +-- flaskapp.wsgi ¦ +-- myotherwebapp +-- ...
some notes more details:
- i don't have possibility use different domain names or diffent ports different virtualhost
- i found this thread suggesting use directive
serveralias
shown below solve similar problem, if , gohttp://mywebsite.com/
see directory listing of flaskapp folder instead of results of flask service invocation, in screenshot below:
here changed flaskapp.conf:
<virtualhost *:80> servername mywebsite.com/flaskapp serveralias mywebsite.com/flaskapp . . .
screenshot:
i think missed url in controller. perhaps can add index.html in flaskapp folder redirect correct url (or other way around, if leave servername mywebsite.com/flaskapp, put index file redirect flaskapp). if index.html "hack" doesn't suit needs, may add virtualserver redirect / /flaskapp/
Comments
Post a Comment