簡體   English   中英

使用Apache和mod_wsgi在同一服務器上部署Django站點和PHP站點

[英]Deploy a Django site and a PHP site on the same server with Apache and mod_wsgi

我目前在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站點?

使用apache的虛擬主機 ,這里我在我的服務器中放了一個類似的例子,其中我在主域中有一個djangp應用程序,在子域中有一個joomla。 這兩個文件都位於/etc/apache2/sites-enabled

Joomla的apache conf文件(名為/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在另一個我記不起的位置找到了啟用了文件夾的文件夾,但無論如何你都可以使用虛擬主機。

通常,我避免弄亂httpd.conf文件,而更喜歡使用虛擬主機。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM