2

我设置了本地环境来运行 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>

检查 Apache 错误日志:

tail -f /var/log/apache2/error_log
[Fri Sep 06 15:30:51 2013] [error] [client 127.0.0.1] mod_hfs_apple: Mis-cased URI or unacceptable Unicode in URI: /Library/WebServer/Documents/python-mn/wsgi.py, wants: /Library/Webserver/Documents/python-mn/

ping 本地环境:

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

MacBook Pro(Retina,15 英寸,2013 年初)、OS X Mountain Lion (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 并告知他们错误发生的时间,以及您所做的任何可能导致错误的事情。

服务器错误日志中可能提供有关此错误的更多信息。

阿帕奇错误日志

[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

这是我期望得到的,它的文件结构和代码与我的 AppFog 安装相同:http: //python-mn.aws.af.cm/

---编辑 9/9/13 下午 1:03---

我做了一个终端命令来安装瓶子......不知道如何确保 wsgi.py 或 vhosts 知道它的位置。显然,AppFog 服务器本身就有这个功能,这就是为什么我不需要任何额外的东西来让它运行。

easy_install -U bottle
Searching for bottle
Reading https://pypi.python.org/simple/bottle/
Best match: bottle 0.11.6
Downloading https://pypi.python.org/packages/source/b/bottle/bottle-            0.11.6.tar.gz#md5=0bafdc4e13ea2b1a3bddf36b5af108c4
Processing bottle-0.11.6.tar.gz
Writing /var/folders/hc/dtnjvkvn1dd931bkkxty_05w0000gn/T/easy_install-QS4GZM/bottle-0.11.6/setup.cfg
Running bottle-0.11.6/setup.py -q bdist_egg --dist-dir /var/folders/hc/dtnjvkvn1dd931bkkxty_05w0000gn/T/easy_install-QS4GZM/bottle-0.11.6/egg-dist-    tmp-pQrFpa
zip_safe flag not set; analyzing archive contents...
bottle: module references __file__
bottle: module references __path__
Adding bottle 0.11.6 to easy-install.pth file
Installing bottle.py script to /usr/local/bin

Installed /usr/local/lib/python2.7/site-packages/bottle-0.11.6-py2.7.egg
Processing dependencies for bottle
Finished processing dependencies for bottle
4

2 回答 2

0

我看到你想通了,但供将来参考......

它看起来bottle不是您的 Python 系统路径的一部分。要将其添加到您的路径中,您有两种选择:

  1. 通过在此处下载手动添加bottle到您的系统 Python 路径:

    https://pypi.python.org/pypi/bottle/0.11.6

    下载后,运行:

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

    https://pypi.python.org/pypi/pip/1.4.1

    然后,一旦安装(类似于上面),运行:

    pip install bottle
    
于 2013-09-09T22:05:28.530 回答
0

试试这个(或者可能将 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>

根据Apple 的 mod_hfs_guide,您的错误消息是由于 Apple 试图保护您免受有人利用 HFS 不区分大小写来访问应该通过使用有趣的大小写版本名称来保护的内容。

于 2013-09-09T16:14:22.010 回答