我在Xubuntu 14.04机器的本地目录中有一个Heroku PHP项目。
我想在本地运行它,以便在部署Heroku之前开发/测试它。
首先,我尝试进入项目目录并运行foreman start web
。
有些错误的包与PHP版本有关,所以我做了以下内容:
1)。从自定义PPA安装最新的PHP版本( ppa:ondrej / php5 ):
php --version
PHP 5.5.18-1+deb.sury.org~trusty+1 (cli) (built: Oct 17 2014 15:20:47)
。
2)。为php5-fpm
二进制文件创建了一个符号链接:
sudo ln -s /usr/sbin/php5-fpm /usr/local/bin/php-fpm
3)。已安装 nginx 。
4)。更改了 Procfile :
web: vendor/bin/heroku-php-nginx /web
接下来,我正在尝试使用:foreman start web
命令启动服务器,我得到以下输出:
02:38:23 web.1 | started with pid 15815
02:38:23 web.1 | Booting on port 5000...
02:38:23 web.1 | DOCUMENT_ROOT changed to '/web/'
02:38:24 web.1 | Starting php-fpm...
02:38:24 web.1 | Starting nginx...
02:38:24 web.1 | [06-Nov-2014 02:38:24] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
02:38:24 web.1 | [06-Nov-2014 02:38:24] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
02:38:26 web.1 | nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
02:38:26 web.1 | 2014/11/06 02:38:26 [warn] 15897#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
02:38:26 web.1 | 2014/11/06 02:38:26 [emerg] 15897#0: open() "/var/log/nginx/access.log" failed (13: Permission denied)
02:38:26 web.1 | Process exited unexpectedly: nginx
02:38:26 web.1 | Going down, terminating child processes...
02:38:26 web.1 | vendor/bin/heroku-php-nginx: line 282: 15891 Terminated tail -qF -n 0 "${logs[@]}"
02:38:26 web.1 | 15892 | strip_fpm_child_said 1>&2
02:38:26 web.1 | exited with code 1
02:38:26 system | sending SIGTERM to all processes
显然,它无法启动,因为它无法访问root用户拥有的日志文件。
接下来,我尝试使用 sudo :sudo foreman start web
启动它并获得以下输出:
02:43:29 web.1 | started with pid 16153
02:43:30 web.1 | Booting on port 5000...
02:43:30 web.1 | DOCUMENT_ROOT changed to '/web/'
02:43:30 web.1 | Starting php-fpm...
02:43:30 web.1 | Starting nginx...
02:43:32 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:32 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:32 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:32 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:33 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:33 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:33 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:33 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:34 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:34 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:34 web.1 | nginx: [emerg] still could not bind()
02:43:34 web.1 | Process exited unexpectedly: nginx
02:43:34 web.1 | Going down, terminating child processes...
02:43:34 web.1 | vendor/bin/heroku-php-nginx: line 282: 16229 Terminated tail -qF -n 0 "${logs[@]}"
02:43:34 web.1 | 16230 | strip_fpm_child_said 1>&2
02:43:34 web.1 | exited with code 1
02:43:34 system | sending SIGTERM to all processes
看起来它不喜欢nginx服务正在运行。那是为什么?
我正在使用:sudo service nginx stop
关闭网络服务器并再次尝试。
这次没有错误消息,看起来服务器正在运行。
但是,当我在浏览器中加载网页时,我收到HTTP的 502 Bad Gateway 错误。
从nginx错误日志中我可以看到nginx无法访问FastCGI套接字文件:
2014/11/06 02:45:44 [crit] 16342#0: *1 connect() to unix:/tmp/heroku.fcgi.5000.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/heroku.fcgi.5000.sock:", host: "localhost:5000"
。
套接字文件由root
拥有,nginx以www-data
运行。
这是什么原因,我该如何解决这个问题?是否可以从我的用户(不是root用户)本地运行Heroku?
答案 0 :(得分:1)
我有同样的问题(在Mac OS上,使用自制软件重新安装nginx)。
我没有编辑vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf.php
(在任何时候更新后都会覆盖它,而且现在它有点不同)。
我刚刚修复了错误日志文件的权限(对其进行了编码),然后正常运行heroku local
如果你以root身份运行heroku local
,这将解决你的错误日志权限错误,但是然后nginx以root身份运行,php-fpm以无人运行(在我的情况下),因此上面说明了权限不匹配。
如果您修复了权限,然后运行heroku local
(没有sudo),那么两个都是无人运行,而且对我有效。
答案 1 :(得分:0)
你的情况和我一模一样。
问题是关于nginx和php5-fpm的进程之间的差异权限。 快速修复:
首先:
编辑文件:vendor / heroku / heroku-buildpack-php / conf / nginx / heroku.conf.php
评论:#server unix:/tmp/heroku.fcgi..sock max_fails = 3 fail_timeout = 3s;
打开评论并更改端口:服务器127.0.0.1:9000 max_fails = 3 fail_timeout = 3s;
第二
编辑文件:vendor / heroku / heroku-buildpack-php / conf / php / php-fpm.conf
评论:listen = /tmp/heroku.fcgi。$ {PORT} .sock
打开评论并更改端口:listen = 127.0.0.1:9000