加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

Heroku PHP“Getting Started”不在OSX上本地运行

发布时间:2020-12-13 17:50:01 所属栏目:PHP教程 来源:网络整理
导读:我试图让这个存储库在OSX 10.11.1上本地运行(Capitan) https://github.com/heroku/php-getting-started.git 使用以下命令 $sudo heroku local web 但我到目前为止 [OKAY] Loaded ENV .env File as KEY=VALUE Format[OKAY] Trimming display Output to 151 Co
我试图让这个存储库在OSX 10.11.1上本地运行(Capitan)

https://github.com/heroku/php-getting-started.git

使用以下命令

$sudo heroku local web

但我到目前为止

[OKAY] Loaded ENV .env File as KEY=VALUE Format
[OKAY] Trimming display Output to 151 Columns
17:30:30 web.1 |  DOCUMENT_ROOT changed to 'web/'
17:30:30 web.1 |  4 processes at 128MB memory limit.
17:30:30 web.1 |  Starting php-fpm...
17:30:32 web.1 |  Starting httpd...
17:30:32 web.1 |  Application ready for connections on port 8080.
17:30:32 web.1 |  (13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
17:30:32 web.1 |  (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
17:30:32 web.1 |  no listening sockets available,shutting down
17:30:32 web.1 |  AH00015: Unable to open logs
17:30:32 web.1 |  Process exited unexpectedly: httpd
17:30:32 web.1 |  Going down,terminating child processes...
[DONE] Killing all processes with signal  null
17:30:32 web.1 Exited Abnormally

任何可能导致权限的想法都会在设置时拒绝错误:80即使我sudo?或者为什么heroku本地尝试使用80端口?

部署到heroku时一切正常.

这是完整的教程:
https://devcenter.heroku.com/articles/getting-started-with-php

编辑

当我尝试手动设置端口时

$heroku local web -p 5000

它只是将默认的8080更改为5000 …

[OKAY] Loaded ENV .env File as KEY=VALUE Format
[OKAY] Trimming display Output to 151 Columns
08:06:33 web.1 |  DOCUMENT_ROOT changed to 'web/'
08:06:33 web.1 |  4 processes at 128MB memory limit.
08:06:33 web.1 |  Starting php-fpm...
08:06:35 web.1 |  Starting httpd...
08:06:35 web.1 |  Application ready for connections on port 5000.
08:06:35 web.1 |  (13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
08:06:35 web.1 |  (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
08:06:35 web.1 |  no listening sockets available,shutting down
08:06:35 web.1 |  AH00015: Unable to open logs
08:06:35 web.1 |  Process exited unexpectedly: httpd
08:06:35 web.1 |  Going down,terminating child processes...
[DONE] Killing all processes with signal  null
08:06:35 web.1 Exited Abnormally

解决方法

因为“heroku local”依赖于可预测的环境,所以PHP应用程序不支持它.与Ruby,Python,Node,Java等不同,侦听流量的Web服务器是用这些相应的语言编写的,PHP应用程序与Apache或Nginx一起启动PHP-FPM(已经排除了例如Windows).

在开始时动态注入一个配置,所以你需要一个非常标准的PHP和Nginx(Debian等不会工作,例如,因为它甚至没有工作“nginx”或“httpd”二进制文件可以开始).只有Nginx 1.8兼容; Apache需要启用一些模块(主要是mod_proxy_fcgi),并且不能绑定到本地端口.

这意味着Heroku必须提供大量不同的客户特定本地设置,所以最好的答案是“只为你的应用设置一个vhost就像你一直做的那样,并使用例如https://packagist.org/packages/josegonzalez/dotenv为你的环境瓦尔”.也就是说,不幸的是,目前PHP中的Web服务器设置状态.

在你的特定情况下,Apache正在启动,然后加载它的/etc/apache2/httpd.conf配置,它绑定到端口80.这不是heroku-php-apache2启动脚本可以阻止的,因为它会有发送与您的特定环境匹配的配置,这是不可能的,因为它无法知道本地系统配置的所有方面,例如要加载什么模块,或者它们甚至在哪里 – 它们是驻留在/usr/libexec / apache2 /,还是/usr/local/apache2 / modules /,还是其他地方? (Apache支持多种目录布局).

你仍然可以尝试让它工作;实际上它在Mac OS上相当容易.我总是使用https://github.com/Homebrew/homebrew-apache的Apache(brew install homebrew / apache / httpd24 –with-mpm-event).在全局配置中(在/usr/local/etc / apache2 /中),启用mod_proxy和mod_proxy_fcgi,并注释掉Listen指令.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读