LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-19-2014, 08:01 AM   #1
Basilios
Member
 
Registered: Oct 2004
Distribution: Slackware
Posts: 33

Rep: Reputation: 0
Configuring Apache 2.2 to serve web app from subdirectory of domain


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?
 
Old 03-20-2014, 07:22 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
What happens with this configuration is this: my web page is displayed at www.company.com, taking over the home page on this server.
This is normal, as you've define DocumentRoot to be /home/someuser/web/webapplication/html. Change it to /home/someuser/web, so you call your webapp with http://www.company.com/webapplication/html and can add later other webpapps too.

Quote:
Using the form to submit data gives me a 500 INTERNAL SERVER ERROR.
Check the apache error_log to find what the 500 error is about?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Re-configuring from a domain name to IP based reference in a Apache server j0sh-linux Linux - Server 1 11-08-2012 06:03 AM
[SOLVED] uanble to open my web app through apache mlnm Linux - Newbie 5 06-19-2012 05:13 PM
configuring apache to server both http and https for a domain name nkoplm Linux - Server 1 05-06-2012 10:40 PM
Configuring Apache web root kvnband Linux - Networking 1 02-04-2007 04:35 PM
Configuring my web server with APACHE pkrishna10 Linux - Newbie 2 12-11-2004 06:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration