3

UPDATE: My original question is below, but the code I posted with the question has been edited to the final working solution.

I am trying to run multiple sites on my MAMP development server. Some of the sites are wordpress sites that live in the htdocs in MAMP and some of the sites are django apps that live in a folder titled djangoprojects.

I have been trying to implement the solutions from these stack questions:

multiple django sites with apache & mod_wsgi

How do I run Django and PHP together on one Apache server?

but I have not been successful. I was able to run the django site on apache with the code you see in the first VirtualHost brackets (from the daemon process line onward) but then none of the php sites could be visited.

Help is greatly appreciated. I am new with this and I can't work out the errors.

Here is the code from my httpd.conf:

UPDATE: The code below works. Both the Django App and the PHP applications exist on the localhost server. The PHP related VirtualHost stuff was copied from further up in the MAMP httpd.conf file.

<VirtualHost *:80>
    ServerName localhost:80
    UseCanonicalName Off
    DocumentRoot "/Applications/MAMP/htdocs" 
    <Directory />
        Options Indexes FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory "/Applications/MAMP/htdocs">
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    WSGIDaemonProcess site1 display-name=%{GROUP}
    WSGIProcessGroup site1
    Alias /media/ /Users/sequoia/djangoprojects/dynamics/media/
    <Directory /Users/sequoia/djangoprojects/dynamics/media>
        Options ExecCGI
            Order deny,allow
        Allow from all
    </Directory>
    WSGIScriptAlias /dynamics /Users/sequoia/djangoprojects/dynamics/apache/django.wsgi
    <Directory /Users/sequoia/djangoprojects/dynamics/apache>
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>
Community
  • 1
  • 1
sequoia
  • 3,025
  • 8
  • 33
  • 41
  • Here's another similar question for reference: http://serverfault.com/questions/226449/how-can-django-wsgi-and-php-share-on-apache – Mark Snidovich Jun 26 '11 at 00:16
  • @mark - thanks for the link, I used the first link in answer to work out a solution, but both the answer to that question and the linked documentation presume a bit more knowledge than I have. So I am not sure my solution matches what they proposed. – sequoia Jun 26 '11 at 03:40
  • You still shouldn't have ':80' in ServerName string. – Graham Dumpleton Jul 24 '11 at 23:44
  • Thanks Graham. I removed the ':80'. I revisited this post because I am trying to implement this solution for a larger site. This question helped me to solve the problem for django trial site, but now when it comes to the production site I am once again having problems, but of a different sort. I am getting error messages that read like Ancient Aramaic and I have no clue how to begin to diagnose the problem. Do you mind taking a look? [Link](http://stackoverflow.com/questions/6810742/how-can-i-diagonse-the-problem-from-this-error-message-django-mod-wsgi-apache-e) Thanks. – sequoia Jul 25 '11 at 00:41

1 Answers1

1

A couple of problems to start with:

  1. ServerName is mean to specify the host name not a URL path.
  2. You should never set DocumentRoot to be where your Django site source code is.
Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • thanks for the pointers. I switched the host to localhost, replaced an unintentional Aliasmatch with Alias and switched the port of the virtualhost to get a working virtualhost for the django site. Then I removed the virtualhost for the php sites because MAMP is set up to handle those. **NEW QUESTION** I guess I don't understand DocumentRoot, what should I set that to? - Also do you have suggestion on how to achieve this result without calling on a different port? Perhaps something like http://dev2.localhost? Thanks. – sequoia Jun 26 '11 at 03:45
  • Just move what you have, from WSGIDaemonProcess directive onwards, into existing VirtualHost for port 80. Those directives will see stuff mounted at sub URL and shouldn't interfere with a PHP appliction running there already. – Graham Dumpleton Jun 26 '11 at 04:08
  • Hmmm. I think I am missing something... Are you suggesting that I should have other Virtual Hosts? That is the only virtualhost I have defined. If I have another VirtualHost for the PHP applications and I move the WSGI directive in there, does that mean my django project needs to be moved to the same directory as the php applications? I thought I read that you should not put your django project directory in the public_html folder? Maybe? Having two virtualhosts with different DocumentRoots means that only the first one defined will work. – sequoia Jun 26 '11 at 07:30
  • Ha. Never mind that last question. I am slow on the uptake. "move from WSGIDaemonProcess directive onwards"... I deleted the second DocumentRoot statement and both the php applications and the django site work. Thanks for your help. I will edit my code above to reflect the corrections. – sequoia Jun 26 '11 at 07:34