1

我目前在cinepass.com.ec有一个 Django 站点,我想在mobile.cinepass.com.ec的同一服务器上部署一个额外的 PHP 站点

我当前的httpd.conf(来自DjangoFoo):

<Directory "/home/ec2-user/cinepass/media">
   Order deny,allow
   Allow from all
</Directory>

<Directory "/home/ec2-user/cinepass/cinepass">
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

Alias /media/ /home/ec2-user/cinepass/media/
ServerAdmin smansfield@palapa.com.ec
ErrorLog "logs/cinepass.com-error_log"
CustomLog "logs/cinepass.com-access_log" common

# mod_wsgi configuration is here
# we are running as user/group 'deamon', if you don't have those you need to change or create.
WSGIDaemonProcess cinepass python-path=/home/ec2-user/cinepass:/home/ec2-user/cinepass/venv/lib/python2.6/site-packages user=daemon group=daemon processes=2 threads=25
WSGIProcessGroup cinepass
# this is our WSGI file.
WSGIScriptAlias / /home/ec2-user/cinepass/cinepass/wsgi.py

我当前的wsgi.py

import os, sys
sys.path.append('/home/')
sys.path.append('/home/ec2-user/cinepass/')

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cinepass.settings_production.py")
os.environ['PYTHON_EGG_CACHE'] = '/tmp'

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

我将如何编辑我的 Apache 配置,以便我还可以在mobile.cinepass.com.ec上运行一个 php 站点?

4

1 回答 1

3

使用apache 的virtualhosts,在这里我在我的服务器中放置了一个类似的示例,其中我在主域中有一个 djangp 应用程序,在子域中有一个 joomla。这两个文件都位于/etc/apache2/sites-enabled

Joomla 的 apache 配置文件(命名为 /etc/apache2/sites-enabled/manual.domain.com):

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin dsanabria@domain.com
    ServerName manual.domain.com

    DocumentRoot "/home/ubuntu/manual/"

    <Directory /home/ubuntu/manual/>
        Order deny,allow
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/manual.domain-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog /var/log/apache2/manual.domain-access.log combined

</VirtualHost>

还有 django 应用程序(名为 /etc/apache2/sites-enabled/www.domain.co):

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin diego@diegue.us
    ServerName domain.co
    ServerAlias machete.anotherdomain.com
    Alias /admin/media/ /home/ubuntu/webapps/machete/lib/python2.7/site-packages/grappelli/media/
    Alias /media/ /home/ubuntu/webapps/machete/machete/media/
    Alias /static/ /home/ubuntu/webapps/machete/machete/collected/

    <Directory /home/ubuntu/webapps/machete/lib/python2.7/site-packages/grappelli/media/>
        Order deny,allow
        Allow from all
    </Directory>

    <Directory /home/ubuntu/webapps/machete/lib/python2.7/site-packages/django/contrib/admin/media/ >
        Order deny,allow
        Allow from all
    </Directory>

    <Directory /home/ubuntu/webapps/machete/machete/media/>
        Order deny,allow
        Allow from all
    </Directory>

    <Directory /home/ubuntu/webapps/machete/machete/collected/>
        Order deny,allow
        Allow from all
    </Directory>

    WSGIScriptReloading On
    WSGIDaemonProcess machete python-path=/home/ubuntu/webapps/machete/lib/python2.7/site-packages
    WSGIProcessGroup machete
    WSGIApplicationGroup machete
    WSGIPassAuthorization On

    WSGIScriptAlias / /home/ubuntu/webapps/machete/machete/machete/wsgi.py
    ErrorLog /var/log/apache2/machete-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog /var/log/apache2/machete-access.log combined

</VirtualHost>

首先,告诉 apache,如果用户访问 manual.domain.com,只需使用 php 应用程序 (joomla) 进行响应。第二个文件对 apache 说,如果用户使用 python wsgy (django) 调用带有 www.domain.com 响应的服务器。

这是在 ubuntu 服务器中,redhat/centos/fedora 将文件夹 sites-enabled 定位在另一个我不记得的位置,但无论如何你可以使用虚拟主机。

通常,我避免弄乱 httpd.conf 文件并更喜欢使用虚拟主机。

于 2013-01-17T23:07:40.890 回答