簡體   English   中英

如何設置Nginx和PHP-FPM套接字

[英]How to setup Nginx and PHP-FPM socket

我已經接管了公司的Web托管,這是一台運行Amazon自己的Linux和Nginx版本的AWS服務器。

我對Nginx沒有太多經驗,但是我需要創建一個運行站點開發版本的子域。 已經存在一個現有的“暫存”虛擬主機,但是將其鏈接到主要站點數據庫變得毫無用處。

我已將分段conf文件從/etc/nginx/conf.d/staging.conf復制到/etc/nginx/conf.d/dev.conf ,並將文件中所有“分段”的實例更改為“ dev”。

該文件如下所示:

upstream php-dev-backend {
    server unix:/tmp/php-fpm-dev.sock weight=1;
}

server {
    server_name dev.groundlevel.co.uk;
    listen 80;

    root /var/www/vhosts/dev.groundlevel.co.uk/web-root;

    index index.html index.htm index.php;
    access_log /var/log/nginx/dev.groundlevel.co.uk_access_log;
    error_log /var/log/nginx/dev.groundlevel.co.uk_error_log;
    location @handler {
        rewrite / /index.php;
    }
location / {
        index index.php index.html;
        try_files $uri $uri/ @handler;
        expires 30d;
    }

include magento_security;

include fastcgi_params;
location ~ \.php$ {
        if (!-e $request_filename) {
             rewrite / /index.php last;
        }
        include fastcgi_params;
        fastcgi_pass php-dev-backend;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
}

但這會導致502錯誤,因為/tmp/php-fpm-dev.sock不存在,我也不知道如何創建它。 或者,如果我可以將conf文件更改為不需要套接字。

有人可以解釋一下如何使套接字運行嗎? 謝謝!

每當啟動PHP-FPM服務時,就應該創建/tmp/php-fpm-dev.sock套接字-如果已將其配置為偵聽此套接字。

如果php-fpm已經在此服務器上用於“登台”站點,則有可能您可以重新使用該套接字。 FPM作為單個實例運行,因此除非您需要在'dev'和'staging'之間進行其他配置,否則實際上不需要運行單獨的套接字。

“分期”網站是否正常運行? 如果是這樣,它在/etc/nginx/conf.d/staging.conf中連接到哪個fpm套接字?

您可能還想從PHP-FPM配置中發布相關的套接字配置。 它應該在/ etc / php中的某個地方??? 具體來說,您要尋找的是FPM啟動時打開的套接字:

 [DOMAINNAME]

 listen = /var/run/php5-fpm/DOMAINNAME.socket <-- socket being opened
 listen.backlog = -1
 listen.owner = nginx
 listen.group = www-data
 listen.mode=0660

暫無
暫無

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

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