CakePHP Connection Refused in Browser

泄露秘密 提交于 2019-12-11 14:02:40

问题


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

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>

Any help is greatly appreciated!


回答1:


develop on an ubuntu machine and work on the code remotely

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.

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`

Note that if you're using the development server - apache config is irrelevant as apache is playing no role in serving requests.



来源:https://stackoverflow.com/questions/38406105/cakephp-connection-refused-in-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!