Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have been assigned a web server to administer, and I have to deploy a web application I wrote on it. This application is mostly a single page in JS + HTML, but it has a little form to accept submissions from users, and there is some simple server side code to handle them, written with Python and the Flask web framework.

The web server is Linux Ubuntu 12, I am using Apache 2.2, and Python, Flask and mod_wsgi are already installed. Let's imagine that the web server's URL is www.company.com; my web application should be served at www.company.com/webapplication. The URL my web page uses to post user submissions to the server should be www.company.com/webapplication/submit.

The web application is in /home/someuser/web/webapplication. Here's the directory structure:

      +-web/                -> All web apps on this server go here
        +-webapplication/    -> Location for www.company.com/webapplication
          +-html/            -> HTML and JS files
          +-app/             -> Python code 
          +-logs/            -> Well, logs, obviously
          +-wsgi/            -> The WSGI file for this web application

Complication: there will be other, different web applications I'll have to write and deploy later on on that same server, at other subdirectories, for example www.company.com/webapp2, www.company.com/anotherwebapp and so on, that will use different frameworks, such as Django or Tornado.

I left the /etc/apache2/apache2.conf untouched and put this file in /etc/apache2/sites-available, starting from some examples I found online. Here it is, changing bits here and there for security:

<VirtualHost *:80>
    # Configure virtualhost defaults
    ServerName www.company.com
    ServerAdmin me@company.com
    DocumentRoot /home/someuser/web/webapplication/html
    <Directory /webapplication>
        Options FollowSymLinks
        AllowOverride None

    <Directory /home/someuser/web/webapplication/html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all

    # Configure WSGI Listener
    WSGIDaemonProcess webapplication user=someuser group=users threads=5
    WSGIScriptAlias /webapplication /home/someuser/web/webapplication/wsgi/webapplication.wsgi
    WSGIScriptReloading On

    <Directory /home/someuser/web/webapplication/app>
        WSGIProcessGroup webapplication
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all

    # Configure Logging
    ErrorLog /home/someuser/web/webapplication/logs/error.log
    LogLevel warn
    CustomLog /home/someuser/web/webapplication/logs/access.log combined


And this is my WSGI file:

import sys
sys.path.insert(0, '/home/someuser/web/webapplication/app')
from DataSubmissionServer import app as application

where DataSubmissionServer is a Python file in /home/someuser/web/webapplication/app.

What happens with this configuration is this: my web page is displayed at www.company.com, taking over the home page on this server. Using the form to submit data gives me a 500 INTERNAL SERVER ERROR.

How can I fix this configuration?

share|improve this question
I do agree that my original question was probably too broad, but it would have been nice to have some hint on what to add to make it more focused, so that my edits are not blind. Hope this version is better. –  Btz Mar 19 at 10:46
I think I am struggling with two separate problems here, configuring Apache and configuring the WSGI module. It might be better if I try to solve the Apache one first and then the Python issue. I'll probably post separate questions some time soon. –  Btz Mar 24 at 15:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.