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

  • 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!) – Fabio 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. – Fabio Apr 25 '13 at 16:10
  • Do you have any NameVirtualHost directive in your config? – Marcel Apr 25 '13 at 17:02
  • 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
2

To formalize the answer, as per comments:

Just place WSGI directives inside the django app VirtualHost definition.

  • 2
    to be correct not all of them, only the WSGIScriptAlias, not WSGIPythonPath ;) – Fabio Apr 25 '13 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.