2013-01-17 75 views
1

在同一台服务器上的PHP网站我现在有一个Django站点工作cinepass.com.ec,我想一个额外的PHP站点部署到同一台服务器mobile.cinepass.com.ec部署Django的网站,并与Apache和mod_wsgi的

我现在的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 [email protected] 
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的网站?

+0

这个问题可能会在这里确定,但会在服务器上更好 – JeffS

+0

Gotcha @JeffS,感谢提示,如果我没有得到回应我会在那里发布 – edu222

回答

3

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

Joomla's的Apache的conf文件(名为/etc/apache2/sites-enabled/manual.domain.com):

NameVirtualHost *:80 
<VirtualHost *:80> 
    ServerAdmin [email protected] 
    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// www.domain.co的Apache2 /启用的站点 - ):

NameVirtualHost *:80 
<VirtualHost *:80> 
    ServerAdmin [email protected] 
    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说,如果用户用www.domain.com响应python wsgy(django)调用服务器。

这是在一个Ubuntu服务器上,redhat/centos/fedora在另一个位置找到启用文件夹的站点,但我无法记住,但无论如何可以使用虚拟主机。

一般来说,我避免搞乱httpd.conf文件,更喜欢使用虚拟主机。

+0

非常感谢@ diegueus9,这指出我正确的方向。我正在部署到亚马逊ec2上的Linux服务器。我在etc/httpd/conf.d中添加了虚拟主机配置conf.d的文件。当我重新启动Apache时,我收到警告'[警告] NameVirtualHost *:80没有VirtualHosts'。关于我失踪的任何想法? – edu222

+0

实际上,这是因为我重复了NameVirtualHost *:80行,我只需要包含它一次。 – edu222

+1

格拉西亚斯hermano! estuvo perfecto。 Con esta info yalogréconfigurar。 – edu222

相关问题