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 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题