我正在开发一个使用Django的移动Web应用程序。 目前我可以像这样启动Django开发服务器:
python ./manage.py runserver <my-ip>:8000
当我这样做的时候,我会在我的Mac上看到一个popup窗口,
Do you want the application "python" to accept incoming network connections?
如果我点击允许button,然后inputURI“:8000”我可以从我的手机访问网站。
然而,他们是我希望在手机上查看纯HTML页面的时代。 为此,我创build了映射到我的/ www目录的Apache虚拟主机调用“localdev”:
# /etc/apache2/httpd.conf ... DocumentRoot "/www" ... <Directory "/www"> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> ... Include /private/etc/apache2/extra/httpd-vhosts.conf # /etc/apache2/extra/httpd-vhosts.conf NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "/www" ServerName localdev ErrorLog "/private/var/log/apache2/localdev_error_log" CustomLog "/private/var/log/apache2/localdev_access_log" common <Directory "/www"> DirectoryIndex index.html </Directory> </VirtualHost>
如果我在/ www / mysite中有一个网站,我可以使用这个URI在我的Mac上访问它:
http://localdev/mysite/index.html
但是,如果我尝试使用此URI访问手机上的虚拟主机站点:
<my-ip>/mysite/index.html
…我收到这条消息:
Forbidden You don't have permission to access /mysite/index.html on this server
我有两个问题,第一个更重要:
我怎样才能从我的手机访问这个网站? 这似乎是一个很常见的Apache错误消息,可能是由许多事情造成的。 我已经阅读了很多关于它的文章,但一直没能解决这个问题。 我究竟做错了什么? 由于我可以通过电脑浏览器访问网站,但不能通过手机访问,所以我想这可能是OS X防火墙问题。
有什么办法可以configuration我的OS X(小牛)防火墙,以便当我启动Django开发networking服务器时,我的电脑会自动允许传入的连接,我不会得到我上面描述的popup窗口? 我已经进入系统偏好设置>安全和隐私>防火墙选项,并从显示的三个“python”连接中select“允许传入连接”,但我仍然得到popup窗口。
你真的包括你的虚拟主机定义的文件吗? 从你的问题:
Include /private/etc/apache2/extra/httpd-vhosts.conf
VS
# /etc/apaches/extra/httpd-vhosts.conf
文件path是不同的,使得它看起来实际上并不包括你有你的虚拟主机定义的文件。