Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在山狮上运行Python_Python_Macos_Apache_Permissions_Localhost - Fatal编程技术网

在山狮上运行Python

在山狮上运行Python,python,macos,apache,permissions,localhost,Python,Macos,Apache,Permissions,Localhost,我已将本地环境设置为运行MySQL和PHP。我开始转向其他语言,试图让Java、Python和Ruby在我的本地web服务器上运行。所有语言都已正确安装,但apache无法识别它们,也没有给我权限问题 我从Python开始,在让apache识别.mod出现了许多问题之后,当我转到该页面时,我现在遇到了一个403错误 我不确定下一步要做什么才能让它正常工作 403禁止 禁止的 您没有访问/访问此服务器的权限 <VirtualHost *:80> DocumentRo

我已将本地环境设置为运行MySQL和PHP。我开始转向其他语言,试图让Java、Python和Ruby在我的本地web服务器上运行。所有语言都已正确安装,但apache无法识别它们,也没有给我权限问题

我从Python开始,在让apache识别.mod出现了许多问题之后,当我转到该页面时,我现在遇到了一个403错误

我不确定下一步要做什么才能让它正常工作

403禁止

禁止的

您没有访问/访问此服务器的权限

<VirtualHost *:80>
          DocumentRoot "/Library/Webserver/Documents/python-mn"
          ServerName python.local
          ServerAlias www.python.local
          WSGIScriptAlias / /Library/WebServer/Documents/python-mn/wsgi.py
          <Directory /Library/Webserver/Documents/python-mn>
                #Options Indexes FollowSymLinks MultiViews
                Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
                allow from all
          </Directory> 
</VirtualHost>
保护当地环境:

ping python.local
PING python.local (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.041 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.054 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.153 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.159 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.130 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.134 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.054 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.073 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.135 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.111 ms
64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.130 ms
64 bytes from 127.0.0.1: icmp_seq=11 ttl=64 time=0.131 ms
64 bytes from 127.0.0.1: icmp_seq=12 ttl=64 time=0.133 ms
64 bytes from 127.0.0.1: icmp_seq=13 ttl=64 time=0.136 ms
64 bytes from 127.0.0.1: icmp_seq=14 ttl=64 time=0.132 ms
64 bytes from 127.0.0.1: icmp_seq=15 ttl=64 time=0.140 ms
64 bytes from 127.0.0.1: icmp_seq=16 ttl=64 time=0.136 ms
64 bytes from 127.0.0.1: icmp_seq=17 ttl=64 time=0.105 ms
64 bytes from 127.0.0.1: icmp_seq=18 ttl=64 time=0.052 ms
64 bytes from 127.0.0.1: icmp_seq=19 ttl=64 time=0.074 ms
MacBookPro(视网膜,15英寸,2013年初),OS X山狮(10.8.4)

---编辑---

wsgi.py文件:

import bottle
import os

def application(environ, start_response):
    data = "Hello World!"
    start_response("200 OK", [
            ("Content-Type", "text/plain"),
            ("Content-Length", str(len(data)))
            ])
    return iter([data])
---编辑时间:9/9/13上午11:46---

现在出现新错误:

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求

请与服务器管理员联系,you@example.com并告知他们错误发生的时间,以及您可能采取的任何可能导致错误的措施

有关此错误的详细信息,请参阅服务器错误日志

apache错误日志

[Mon Sep 09 11:43:08 2013] [notice] caught SIGTERM, shutting down
[Mon Sep 09 11:43:08 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
httpd: Could not reliably determine the server's fully qualified domain name, using Micheles-MacBook.local for ServerName
[Mon Sep 09 11:43:08 2013] [warn] mod_wsgi: Compiled for Python/2.6.1.
[Mon Sep 09 11:43:08 2013] [warn] mod_wsgi: Runtime using Python/2.6.7.
[Mon Sep 09 11:43:08 2013] [notice] Digest: generating secret for digest authentication ...
[Mon Sep 09 11:43:08 2013] [notice] Digest: done
[Mon Sep 09 11:43:08 2013] [notice] Apache/2.2.22 (Unix) mod_wsgi/3.3 Python/2.6.7 PHP/5.5.3 mod_ssl/2.2.22 OpenSSL/0.9.8x DAV/2 configured -- resuming normal operations
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1] mod_wsgi (pid=7888): Target WSGI script '/Library/WebServer/Documents/python-mn/wsgi.py' cannot be loaded as Python module.
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1] mod_wsgi (pid=7888): Exception occurred processing WSGI script '/Library/WebServer/Documents/python-mn/wsgi.py'.
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1]   File "/Library/WebServer/Documents/python-mn/wsgi.py", line 1, in <module>
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1]     import bottle
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1] ImportError: No module named bottle
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1] mod_wsgi (pid=7888): Target WSGI script '/Library/WebServer/Documents/python-mn/wsgi.py' cannot be loaded as Python module.
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1] mod_wsgi (pid=7888): Exception occurred processing WSGI script '/Library/WebServer/Documents/python-mn/wsgi.py'.
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1]   File "/Library/WebServer/Documents/python-mn/wsgi.py", line 1, in <module>
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1]     import bottle
[Mon Sep 09 11:43:18 2013] [error] [client 127.0.0.1] ImportError: No module named bottle
试试这个(或者可能将WebServer切换到WebServer)(我更改的是将路径名全部设置为WebServer;您有一些WebServer(小写S)和一些WebServer

<VirtualHost *:80>
          DocumentRoot "/Library/WebServer/Documents/python-mn"
          ServerName python.local
          ServerAlias www.python.local
          WSGIScriptAlias / /Library/WebServer/Documents/python-mn/wsgi.py
          <Directory /Library/WebServer/Documents/python-mn>
                #Options Indexes FollowSymLinks MultiViews
                Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
                allow from all
          </Directory> 
</VirtualHost>

DocumentRoot“/库/WebServer/Documents/python-mn”
ServerName python.local
ServerAlias www.python.local
WSGIScriptAlias//Library/WebServer/Documents/python mn/wsgi.py
#选项索引跟随符号链接多视图
选项索引如下SYMLINKS包括ExecCGI
允许超越所有
命令允许,拒绝
通融

根据,您的错误消息是由于苹果公司试图保护您免受有人利用HFS的case-instive来访问一些应该通过使用有趣的名称大小写版本来保护的内容。

我知道您已经解决了这个问题,但供将来参考

看起来
瓶子
不是Python系统路径的一部分。要将其添加到路径中,有两个选项:

  • 通过在此处下载,将
    瓶子
    手动添加到系统Python路径:

    下载后,运行:

    tar xvf bottle-0.11.6.tar.gz
    cd bottle-0.11.6/
    sudo python setup.py install 
    
  • 使用软件包管理器为您拉取。您可以从以下位置安装pip(也可以使用easy_install、brew或macports):

    然后,在安装后(与上面类似),运行:


  • 你能包括你的wsgi.py文件吗?我特别好奇你的顶部是否没有一个#!@Foon这是一个“Hello World”脚本。它在我的AppFog帐户上工作。编辑了上面的文章以将其包括在最后。我的错误…我错误地认为你需要shebang行(例如#!/usr/bin/python)对于您的modwsgi文件,您的错误是与其他解释器(例如bash)进行了一些奇怪的交互正在执行意外操作。看起来它找不到
    瓶子
    。请确保它位于系统Python路径上。@我进行了安装,并将瓶子添加到了本地。显然,我的AppFog服务器已经在本地安装了瓶子。我不确定如何将其添加到系统Python路径。我在上面的安装中添加了终端输出。我正在获取一个新的现在出现错误消息。我在上面粘贴了消息和错误日志。似乎找不到“瓶子”。我很困惑,因为这在我的AppFog应用程序上运行良好。我完成了您的步骤,所有内容似乎都已正确安装。我还必须安装pip(我遵循了这些说明)。我仍然收到500内部服务器错误。我也尝试重新启动apache,但仍然没有成功。我现在收到一条brew doctor警告消息。但不确定这是否与此有关:“警告:”配置"脚本存在于您的系统或自制目录之外。
    /configure
    脚本通常会查找*-config脚本,以确定是否安装了软件包,以及在编译和链接时使用哪些附加标志。如果配置脚本覆盖,则在路径中使用附加脚本可能会混淆通过自制安装的软件系统或自制程序提供的同名脚本。我们发现了以下“配置”脚本:/Users/michele/.rbenv/shimmes/passenger-config“是的,你可能应该做一个或另一个,而不是两个。你从Apache得到的错误仍然是一样的吗?仍然缺少瓶子?嗯,很有趣。如果你在系统终端中运行
    python-c'import-battle'
    ,它会抛出任何错误吗?终端或Apache错误日志中的该命令没有任何错误。
    <VirtualHost *:80>
              DocumentRoot "/Library/WebServer/Documents/python-mn"
              ServerName python.local
              ServerAlias www.python.local
              WSGIScriptAlias / /Library/WebServer/Documents/python-mn/wsgi.py
              <Directory /Library/WebServer/Documents/python-mn>
                    #Options Indexes FollowSymLinks MultiViews
                    Options Indexes FollowSymLinks Includes ExecCGI
                    AllowOverride All
                    Order allow,deny
                    allow from all
              </Directory> 
    </VirtualHost>
    
    tar xvf bottle-0.11.6.tar.gz
    cd bottle-0.11.6/
    sudo python setup.py install 
    
    pip install bottle