简体   繁体   English

Django / mod_wsgi和PHP作为使用MAMP的同一Apache服务器上的虚拟主机

[英]Django/mod_wsgi and PHP as Virtual Hosts on same Apache Server using MAMP

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. 我想在我的MAMP开发服务器上运行多个站点。 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. 一些网站是生活在MAMP中的htdocs的wordpress网站,其中一些网站是django应用程序,它们位于名为djangoprojects的文件夹中。

I have been trying to implement the solutions from these stack questions: 我一直在尝试从这些堆栈问题中实现解决方案:

multiple django sites with apache & mod_wsgi 使用apache和mod_wsgi的多个django站点

How do I run Django and PHP together on one Apache server? 如何在一台Apache服务器上一起运行Django和PHP?

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. 我能够使用您在第一个VirtualHost括号中看到的代码(从守护程序进程行开始)在apache上运行django站点,但之后无法访问任何php站点。

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: 这是我的httpd.conf中的代码:

UPDATE: The code below works. 更新:以下代码有效。 Both the Django App and the PHP applications exist on the localhost server. Django App和PHP应用程序都存在于localhost服务器上。 The PHP related VirtualHost stuff was copied from further up in the MAMP httpd.conf file. 与PHP相关的VirtualHost内容在MAMP httpd.conf文件中进一步复制。

<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>

A couple of problems to start with: 一些问题开始:

  1. ServerName is mean to specify the host name not a URL path. ServerName意味着指定主机名而不是URL路径。
  2. You should never set DocumentRoot to be where your Django site source code is. 您永远不应将DocumentRoot设置为Django站点源代码的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM