簡體   English   中英

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

[英]Heroku PHP “Getting Started” doesn’t run locally on OSX

我試圖讓這個存儲庫在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為你的env vars“。 也就是說,不幸的是,目前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_proxymod_proxy_fcgi ,並注釋掉Listen指令。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM