dsdf64562672 2013-10-26 09:03 采纳率: 0%
浏览 35
已采纳

Django和PHP一起在服务器上只有单个ip和端口

I am able to run django and php on two different ports like this http://pastebin.com/2eextGad

But I want something like

54.22.22.22/app/ to django project

and anything other than that url to PHP Document root /var/www/

I tried running like Listen 8081

<VirtualHost *:8081>
        WSGIScriptAlias /app/ /var/www/abc/index.wsgi

        Alias /static/ /var/www/abc/static/
        <Location "/static/">
            Options -Indexes
        </Location>
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined

Other than ip/app to php
Alias /var/www/
        DocumentRoot /var/www
        </VirtualHost>

How to accomplish this

  • 写回答

1条回答 默认 最新

  • dousou1878 2013-10-26 11:29
    关注

    I think this should just work:

    <VirtualHost *:8081>
            WSGIScriptAlias /app/ /var/www/abc/index.wsgi
    
            Alias /static/ /var/www/abc/static/
            <Location "/static/">
                Options -Indexes
            </Location>
            LogLevel warn
            CustomLog /var/log/apache2/access.log combined
    
            DocumentRoot /var/www
    </VirtualHost>
    

    That makes addresses starting with /app/ to be served from a wsgi handler, addresses staring with /static/ from /var/www/abc/static/ directory, and everything else is served form /var/www.

    There is however a huge security issue with your setup. You should not keep your Django project in a folder that is inside a DocumentRoot folder. You are making all your source code and settings (including database passwords and cookie signing secret keys!) accessible to anyone. Move the Django project away from /var/www immediately.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题