CakePHP连接在浏览器中被拒绝 [英] CakePHP Connection Refused in Browser
问题描述
我正在首次设置/学习CakePHP,我正在努力弄清为什么无法通过默认端口8765访问服务器.我喜欢在ubuntu机器上开发并远程处理代码. . 服务器托管在本地计算机上的vm上,但我将其称为远程计算机.服务器和我的远程计算机都位于同一10.0.1.x子网中.我可以通过端口80到达服务器.但是,当我尝试到达hxxp://10.0.1.44:8765/时,我收到以下消息
I'm working on setting up/learning CakePHP for the first time and I am struggling to figure out why I cannot reach my server over the default port 8765. I like to develop on an ubuntu machine and work on the code remotely. The server is hosted on a vm on my local machine, but i am referring to it as the remote machine. Both the server and my remote machine are on the same 10.0.1.x subnet. I can reach the server over port 80 fine. However, when I attempt to reach hxxp://10.0.1.44:8765/ I get the following message
Failed to connect to 10.0.1.44 port 8765: Connection refused
我尝试通过执行sudo uff disable
在Ubuntu 16服务器上禁用防火墙,但没有成功.我还尝试过编辑Apache2.conf文件并覆盖目录权限.这些是我当前的全局权限:
I've tried disabling my firewall on the Ubuntu 16 server by doing sudo uff disable
and that didn't work. I've also tried editing my Apache2.conf file and overriding the directory permissions. These are my current global permissions:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
任何帮助将不胜感激!
推荐答案
在ubuntu机器上开发并远程处理代码
develop on an ubuntu machine and work on the code remotely
您可能遇到的问题是 php的内置Web服务器( CakePHP的服务器外壳使用)不会绑定到所有IP地址-它仅绑定到您在其上启动的IP和主机名.
The problem you likely have is that php's built-in web server (which CakePHP's server shell uses) does not bind to all ip addresses - it only binds to the ip and host name you start it on.
要让服务器监听所有ip地址并响应访问的IP地址,请使用"0.0.0.0"作为主机名:
To have the server listen to all ip addresses and respond however it's accessed, use '0.0.0.0' as the hostname:
-> bin/cake server -H 0.0.0.0
Welcome to CakePHP v3.1.3 Console
---------------------------------------------------------------
App : src
Path: /var/www/cakephp.dev/src/
DocumentRoot: /var/www/cakephp.dev/webroot
---------------------------------------------------------------
built-in server is running in http://0.0.0.0:8765/
You can exit with `CTRL-C`
请注意,如果您使用的是开发服务器-apache配置是不相关的,因为apache在服务请求中不起作用.
Note that if you're using the development server - apache config is irrelevant as apache is playing no role in serving requests.
这篇关于CakePHP连接在浏览器中被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!