我已经设置了本地环境来运行MySQL和PHP。我开始分支到其他语言,并试图让Java,Python和Ruby在我的本地Web服务器上运行。所有语言都安装正确,但apache无法识别它们或给我许可问题。
我已经开始使用Python了,经过许多问题得到apache来识别.mod后,当我转到该页面时,我现在收到403错误。
我不确定下一步是为了让它正常工作。
403 Forbidden
禁止
您无权访问此服务器上的/。
<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 am ---
现在出现新错误:
内部服务器错误
服务器遇到内部错误或配置错误,无法完成您的请求。
请联系服务器管理员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
这是我期望得到的,它与我的AppFog安装相同的文件结构和代码:http://python-mn.aws.af.cm/
---编辑9/9/13 1:03 pm ---
我做了一个终端命令安装瓶子...不知道如何确保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
答案 0 :(得分: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>
Per Apple's mod_hfs_guide,您的错误消息是由于Apple试图保护您免受HFS不区分大小写的人访问应该使用有趣的套件版本保护的内容。
答案 1 :(得分:0)
我看到你想出来了,但是为了将来参考...
看起来bottle
不是Python系统路径的一部分。要将其添加到路径中,您有两种选择:
通过在此处下载来手动将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
使用包管理器为您提取。你可以从这里安装pip(你也可以使用easy_install,brew或macports):
https://pypi.python.org/pypi/pip/1.4.1
然后,一旦安装(类似于上面),运行:
pip install bottle