[英]Incorrect permissions when running Heroku PHP project locally with Foreman in Ubuntu
我在Xubuntu 14.04機器的本地目錄中有一個Heroku PHP項目。
我想在本地運行它,以便在部署到Heroku之前進行開發/測試。
首先,我嘗試將CD插入項目目錄並運行了foreman start web
。
由於與某些缺少的軟件包和PHP版本有關的錯誤,因此我執行了以下操作:
1)。 從自定義PPA( ppa:ondrej / php5 )安裝了最新的PHP版本:
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
關閉Web服務器: 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
運行。
這是什么原因,如何解決此問題? 是否可以從我的用戶(而不是根用戶)本地運行Heroku?
我遇到過同樣的問題(在Mac OS上,使用自制軟件重新安裝nginx)。
我沒有編輯vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf.php
(只要更新vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf.php
,它就會被覆蓋,並且如今無論如何它都略有不同)。
我已經修復了錯誤日志文件的權限(將其更改),然后像往常一樣運行heroku local
如果您以root身份運行heroku local
,則可以解決錯誤日志權限錯誤,但是nginx將以root身份運行,而php-fpm則以無人身份運行(在我的情況下),因此上述權限不匹配。
如果您修復了權限,然后在heroku local
運行heroku local
(無sudo),則兩者都將以無人運行,並且對我有用。
你的情況和我一樣。
問題是關於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
評論:監聽= /tmp/heroku.fcgi.${PORT}.sock
打開注釋並更改端口:listen = 127.0.0.1:9000
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.