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:
Code:
+-/
+-home/
+-someuser/
+-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 standard /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:
Code:
<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>
<Directory /home/someuser/web/webapplication/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
# 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
</Directory>
# Configure Logging
ErrorLog /home/someuser/web/webapplication/logs/error.log
LogLevel warn
CustomLog /home/someuser/web/webapplication/logs/access.log combined
</VirtualHost>
And this is my WSGI file:
Code:
import sys
sys.path.insert(0, '/home/someuser/web/webapplication/app')
from DataSubmissionServer import app as application
where DataSubmissionServer.py 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?