使用bottlepy和PHP在同一台计算机 [英] Use bottlepy and php in the same computer

查看:207
本文介绍了使用bottlepy和PHP在同一台计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ubuntu 12.04安装的Apache2和mod_wsgi的。 我想用bottlepy和PHP在我的本地计算机
我知道这样的问题已经被其他人作为<一个问href=\"http://stackoverflow.com/questions/7322336/apache-mod-wsgi-and-php-in-the-same-domain/7323874\">Apache mod_wsgi的和PHP在同一个域中。
但有人建议我做一个新的问题,因为我的问题可能会有所不同。

I use ubuntu 12.04 with apache2 and mod_wsgi installed. I want to use bottlepy and php in my local computer. I know such an issue is already asked by someone else as in Apache mod_wsgi and php in the same domain. But someone suggest me to make a new question since my problem could be different.

我已经改变的/ etc / apache2的/网站的可用/默认这个:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

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

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

<VirtualHost *>
    DocumentRoot /home/gofrendi/workspace/kokoropy
    ServerName oraiso
    WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5
    WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
    <Directory /home/gofrendi/workspace/kokoropy>
        WSGIProcessGroup kokoropy
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

第一虚拟主机是PHP,而第二个是用于bottlepy。
我把 /家庭/ gofrendi /工作区/ kokoropy 我bottlepy应用。我有 kokoro.wsgi 中包含该脚本相同的目录:

The first virtual host is for PHP, and the second one is for bottlepy. I put my bottlepy application in /home/gofrendi/workspace/kokoropy. And I have kokoro.wsgi in the same directory which contains this script:

import os
sys.path = [os.path.dirname(__file__)] + sys.path

from kokoropy import kokoro_init
PWD = os.path.dirname(os.path.abspath(__file__))
APP_DIRECTORY = 'applications'
APPLICATION_PATH = os.path.join(PWD, APP_DIRECTORY)    
application = kokoro_init(application_path = APPLICATION_PATH, run = False)

我做的使用使配置

I've do enable the configuration by using

sudo a2ensite default
sudo service apache2 restart

果然我的PHP脚本仍然工作。但是,每当我不知道如何访问我的bottlepy脚本。

My PHP scripts are still work as expected. But, whenever I don't know how to access my bottlepy script.

我也尝试删除的PHP的一部分的/ etc / apache2的/网站的可用/默认,以便它只包含

I've also try to remove the PHP part of /etc/apache2/sites-available/default, so that it only consists of

<VirtualHost *>
    DocumentRoot /home/gofrendi/workspace/kokoropy
    ServerName oraiso
    WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5
    WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
    <Directory /home/gofrendi/workspace/kokoropy>
        WSGIProcessGroup kokoropy
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

但我仍然不能得到bottlepy工作。它只是简单地显示404未找​​到。

But I still can't get bottlepy work. It just simply show 404 not found.

不要任何人有同样的经历?如何使工作?
谢谢你。

Do anybody has the same experience? How to make it work? Thanks.

推荐答案

该问题已经解决。
首先,我改变httpd.conf中设置(或在我的情况的/ etc / apache2的/网站的可用/默认)n要这样的:

The problem has been solved. First I change httpd.conf setting (or in my case /etc/apache2/sites-available/default) nto this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

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

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>


    # THIS IS WHERE I START TO EDIT IT:
    # It tells apache about wsgi existance
    WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5   
    WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
    <Directory /home/gofrendi/workspace/kokoropy>
        WSGIProcessGroup kokoropy
        WSGIApplicationGroup %{GLOBAL}
        Options ExecCGI
        Order deny,allow
        Allow from all
    </Directory>

</VirtualHost>

这个配置说本地主机/ kokoropy 应该由WSGI处理。

This configuration say that localhost/kokoropy should be handled by the wsgi.

我的WSGI脚本位于 /home/gofrendi/workspace/kokoropy/kokoro.wsgi
kokoro.wsgi内容如下:

My wsgi script is located at /home/gofrendi/workspace/kokoropy/kokoro.wsgi. kokoro.wsgi content is as follow:

import os, sys
os.chdir(os.path.dirname(__file__))
sys.path = [os.path.dirname(__file__)] + sys.path

from bottle import default_app
@route('/')
def index():
   return 'run with apache'
application = default_app()

如果您访问bottlepy的时候,却在访问时,PHP没有发现错误发现内部中断错误,这可能是一些错误在你WSGI。只要打开了Apache日志(在我的情况下,它是在这里: /var/log/apache2/error.log

If you found internal sever error, when accessing bottlepy, but find no error when accessing php, that is probably some mistake in you wsgi. Just open up the apache log (in my case it is here: /var/log/apache2/error.log)

这篇关于使用bottlepy和PHP在同一台计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆