2014-11-05 2 views
0

Xubuntu 14.04 시스템의 로컬 디렉토리에 Heroku PHP 프로젝트가 있습니다.우분투에서 Foreman과 함께 Heroku PHP 프로젝트를 로컬에서 실행할 때 권한이 올바르지 않습니다.

Heroku에서 배포하기 전에 개발/테스트하기 위해 로컬로 실행하고 싶습니다.

우선 프로젝트 디렉토리에 cd를 시도하고 foreman start web을 실행했습니다.

일부 누락 된 패키지와 PHP 버전에 관련된 오류가 있었다 그래서 나는 한 다음

1). 사용자 정의 PPA에서 설치된 최신 PHP 버전 (PPA : 드레이/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).

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 

Procfile 변경 루트 사용자가 소유 한 로그 파일에 액세스 할 수 없기 때문에 시작하지 마십시오.

다음으로, sudo는 사용하여 시작하려고 해요 : sudo foreman start web를 다음과 같은 출력을 얻기 : 그것은 그 Nginx에 서비스가 실행되지 같이하는 것처럼

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 

보인다. 왜 그런가요?

sudo service nginx stop을 사용하여 웹 서버를 끈 다음 다시 시도하십시오.

이번에는 오류 메시지가없고 서버가 실행중인 것 같습니다.

그러나 브라우저에서 웹 페이지를로드 할 때 HTTP가 수신되고 있습니다. 502 불량 게이트웨이 오류.

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" : 그의 nginx는 FastCGI를 소켓 파일을 액세스 할 수 없습니다 볼 수의 nginx 오류 로그에서

.

소켓 파일은 root이고, nginx는 www-data입니다.

이유는 무엇입니까?이 문제를 해결하려면 어떻게해야합니까? 루트가 아닌 내 사용자로부터 Heroku를 로컬로 실행할 수 있습니까?

답변

0

나와 비슷한 상황.

문제는 nginx 및 php5-fpm에 대한 프로세스 간의 사용 권한 차이입니다. 빠른 수정 :

첫째 :

편집 파일 : 공급 업체/Heroku가/Heroku가-buildpack-PHP/conf의 /의 nginx/heroku.conf.php

코멘트 : 유닉스 #server :/tmp를/Heroku가 .fcgi..sock max_fails = 3 fail_timeout = 3s;

열린 메모 및 변경 포트 : 서버 127.0.0.1:9000 max_fails = 3 fail_timeout = 3s;

둘째 :

편집 파일 : 공급 업체/Heroku가/Heroku가-buildpack-PHP/conf의/PHP/PHP-fpm.conf

코멘트 : 경청 = /tmp/heroku.fcgi.${PORT 듣기 = 127.0.0.1:9000

1

저도 같은 문제 했어 (맥 OS에를, 신선한 사제와의 nginx의 설치)}

개방 코멘트를 .sock와 포트를 변경합니다.

vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf.php을 수정하지 않았습니다 (빌드 백이 업데이트 될 때 오버라이드되며 요즘에는 약간 다릅니다).

난 그냥 nginx를 다음 오류 로그 권한 오류를 해결합니다 오류 로그 파일 (을 chmoded) 당신이 루트로 heroku local를 실행하면 다음 정상

heroku local을 실행에 대한 권한을 고정하지만, 한 root로 실행되고 php-fpm은 아무런 권한도 가지지 않으므로 (위에서 언급 한 권한 불일치)

권한을 수정 한 다음 heroku local (sudo가 없음)을 실행하면 둘 다 nobody로 실행되고 저에게 효과적입니다.

+0

해당 로그 파일에 대해 어떤 사용 권한을 설정 했습니까? –

+0

chmod 666이 트릭을하는 것처럼 보였습니다. –

+0

다른 사람들이 이것을 보게되면 https://berezovskyi.me/2015/02/deploying-sample-silex-app-to-heroku/의 끝에 수정 사항이 있습니다 : 다른 터미널을 병렬로 열고'sudo chmod 0667/tmp/heroku.fcgi.5000.sock' –

관련 문제