2016-09-12 77 views
1

我試圖讓php-fpm設置在Docker鏡像上。php-fpm連接重置由對端

下面是我的泊塢窗,compose.yml服務:

wordpress-service: 
    build: 
    context: . 
    dockerfile: Dockerfile-wordpress 
    image: riffsy-web-wordpress:latest 
    restart: always 
    links: 
    - wordpress-mysql 
    depends_on: 
    - wordpress-mysql 
    expose: 
    - "8000" 
    environment: 
    - DB_NAME=wordpress 
    - DB_USER=wordpress 
    - DB_PASSWORD=password123 
    - DB_HOST=wordpress-mysql 
    - DB_PORT=3306 
    ports: 
    - "8000:8000" 

泊塢窗圖像使用這個命令:

CMD php-fpm7.0 --fpm-config /etc/php-fpm.conf 

這裏是我的PHP-FPM的conf:

[global] 

error_log = /dev/stderr 
log_level = debug 
daemonize = no 

[www] 
listen = 8000 
listen.allowed_clients = 127.0.0.1 
user = www-data 
group = www-data 
pm = dynamic 
pm.max_children = 6 
pm.start_servers = 2 
pm.min_spare_servers = 1 
pm.max_spare_servers = 4 
pm.max_requests = 500 
request_terminate_timeout = 120s 
catch_workers_output = yes 

我設置listen.allowed_clients = 127.0.0.1因爲否則我有連接被拒絕的消息;最終我需要php-fpm接受來自任何IP的連接,因爲我不知道我的Nginx映像將具有什麼IP,並且這並不重要,因爲我的php-fpm映像不會公開連接到Internet 。

我跑docker exec登錄到運行圖像就跑wget來測試服務器:

[email protected]:/srv# wget 127.0.0.1:8000       
--2016-09-12 07:55:13-- http://127.0.0.1:8000/ 
Connecting to 127.0.0.1:8000... connected. 
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers. 
Retrying. 

--2016-09-12 07:55:14-- (try: 2) http://127.0.0.1:8000/ 
Connecting to 127.0.0.1:8000... connected. 
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers. 
Retrying. 

--2016-09-12 07:55:16-- (try: 3) http://127.0.0.1:8000/ 
Connecting to 127.0.0.1:8000... connected. 
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers. 
Retrying. 

^C 

控制檯顯示並不比其他輸出:

wordpress-service_1 | [12-Sep-2016 08:01:09.757039] DEBUG: pid 5, fpm_pctl_perform_idle_server_maintenance(), line 379: [pool www] currently 0 active children, 2 spare children, 2 running children. Spawning rate 1 
+0

問題是,'listen.allowed_clients = 127.0.0.1'需要設置爲允許任何IP連接到它。該文件說,如果它的空白,那麼它會接受所有的連接。這在碼頭環境中似乎不是這種情況。我試過評論這條線,並且設置「listen.allowed_clients =」既不適合我。它只會接受您指定的IP的連接。只有在容器運行後纔會知道。 – b01

回答

1

的問題是,PHP的fpm不使用http協議,它使用fastcgi。連接它的唯一方法是通過設置Nginx來使用fastcgi。

相關問題