0

I am a developer, not a sys-admin :) I always have been running multiple vhosts in parallel on different ports, but this time something is interfering.

I have one vhost which runs a python-based django web application, which uses wsgi. The other one would be a plain php application. They need to interact and I am testing this. Each config is in a different file (ubuntu based).

The php application:

<VirtualHost *:8778> 
    ServerAdmin webmaster@localhost
    ServerName lochost.localdomain

    DocumentRoot /home/projects/df/htdocs
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /home/projects/df/htdocs>
        Options Indexes FollowSymLinks MultiViews
        #AllowOverride None
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

The python/django app:

WSGIScriptAlias / /home/projects/dfp/wsgi/wsgi.py
WSGIPythonPath /home/projects/dfp/newapp

<VirtualHost *:9988>
    ServerAdmin webmaster@localhost
    ServerName localhost.local


    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} ^TRACE
    RewriteRule .* - [F]

    RewriteCond /home/projects/dfp/etc/httpd/maintenance-mode-on -f
    RewriteCond %{REQUEST_URI} !^/media/.*$
    RewriteRule ^.* /media/maintenance.html [L,PT]

    Alias /media /home/projects/dfp/newapp/media    

    <Directory /home/projects/dfp/newapp/media>
       Allow from all
       AllowOverride All
       Order allow,deny
    </Directory>                                       

    <Location "/media">
       SetHandler None
       #ExpiresActive on
       #ExpiresDefault "access plus 1 week"
       FileETag MTime Size
       EnableSendfile Off
    </Location>

    Alias /adminmedia /home/projects/dfp/administrative/media

    <Directory /home/projects/dfp/administrative/media/>
       Allow from all
       AllowOverride All
       Order allow,deny
    </Directory>

      <Location "/adminmedia">
       SetHandler None
       #ExpiresActive on
       #ExpiresDefault "access plus 1 week"
       FileETag MTime Size
    </Location>    

    <Directory /home/projects/dfp/newapp>
        <Files wsgi.py>
            Order deny,allow
            Allow from all
        </Files>
    </Directory>
</VirtualHost>

As a result of this config, when I go to the python app (localhost:9988) all is fine, but accessing the php app (localhost:8778) I am getting redirected to the other one for the content, although it appears without css, but the address bar still says localhost:8778.

What is wrong? I suspect the WSGIScriptAlias / /home/projects/dfp/wsgi/wsgi.py directive at the top of the python app config is causing the mess. Anyway I could have both apps running in parallel while still using WSGI? Thanks

transient_loop
  • 499
  • 1
  • 4
  • 15
  • whats the output from `httpd -S`? – Marcel Apr 25 '13 at 15:56
  • actually, I guess on ubuntu it's at /usr/sbin/apache2: sudo /usr/sbin/apache2 -S apache2: bad user name ${APACHE_RUN_USER} however, I have this same result when I delete the python app vhost and restart the server (in which case the php app runs fine!) – transient_loop Apr 25 '13 at 16:09
  • I run apache as my own user and the docroots are in my home so that I can easily have access and modify. It's all development, not production so far. – transient_loop Apr 25 '13 at 16:10
  • Do you have any `NameVirtualHost` directive in your config? – Marcel Apr 25 '13 at 17:02
  • First: thanks for helping. No, no NameVirtualHost. Just again, I have had such configurations many time before, and they always worked in parallel. The python app vhost seems to be the problem, when I delete it, all other vhosts work just fine. – transient_loop Apr 25 '13 at 17:12
  • 1
    Is it of any specific need you having the WSGI directives outside of the VirtualHost definition? What happens if you place them inside the proper VirtualHost declaration? – Marcel Apr 25 '13 at 17:14
  • If I place it inside the declaration the server does not start. "WSGIPythonPath cannot occur within section Action 'configtest' failed." – transient_loop Apr 25 '13 at 18:16
  • Heyyyy!!! that was the hint I needed! The error actually says "WSGIPythonPath cannot occur within ". So I moved the WSGIScriptAlias directive into the vhost declaration, but left the WSGIPythonPath at the top, and now it works!!!! Thank you! – transient_loop Apr 25 '13 at 18:32

1 Answers1

2

To formalize the answer, as per comments:

Just place WSGI directives inside the django app VirtualHost definition.

Marcel
  • 1,730
  • 10
  • 15