FastCGI sent in stderr : PHP message : PHP Fatal error – PHP 7 / Nginx 1.10.3 / 10.1.23-MariaDB / Ubuntu 16.04 / LetsEncrypt 4096 certs

I have an issue that I’ve been struggling with for a couple of weeks now. Some of the plugins on my WP install are not functioning properly. I doubt it’s related to the plugins itself, but the way the requests are passed via PHP and Nginx.

When I for instance try to upload a profile image inside one of the plugins, I get this:

2017/05/19 12:52:13 [error] 8296#0: *2 FastCGI sent in stderr: “PHP
message: PHP Fatal error: Cannot redeclare ihc_suspend_account_bttn()
(previously declared in
on line 882” while reading response header from upstream, client:
[my-ip-address], server:, request: “POST
HTTP/2.0”, upstream: “fastcgi://unix:/run/php/php7.0-fpm.sock:”, host:
“”, referrer: “

I have tried and tested 1000 different options and configurations. I’ve now even built a complete new server from the ground up, but this issue persists.

I have checked my site permissions, this is what I apply:

sudo find /var/www/ -exec chown -R www-data:www-data {} + && sudo find /var/www/ -type d -exec chmod -R 775 {} + && sudo find /var/www/ -type f -exec chmod -R 664 {} + && sudo chgrp www-data /var/www/ && sudo chmod 660 /var/www/ && sudo service nginx restart

My host config:

fastcgi_cache_path /var/run/nginx-cache/site levels=1:2 keys_zone=SITE:100m inactive=60m;

map $http_host $blogid {

    default       -999;
    include /var/www/;


server {
        listen 80;
        listen [::]:80;
        return 301 https://$server_name$request_uri;

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;

        ssl_certificate /etc/letsencrypt/live/;
        ssl_certificate_key /etc/letsencrypt/live/;

        include snippets/ssl.conf;

        client_max_body_size 256M;
        root /var/www/;
        index index.php index.html;


        location ~ /.well-known {
                allow all;

        set $skip_cache 0;

        if ($request_method = POST) {
                set $skip_cache 1;

        if ($query_string != "") {
                set $skip_cache 1;

        if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
                set $skip_cache 1;

        if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
                set $skip_cache 1;

        autoindex off;

        location ~ /purge(/.*) {
                fastcgi_cache_purge SITE "$scheme$request_method$host$1";

        location ~* ^.+.(flv|pdf|avi|mov|mp3|wmv|m4v|webm|aac|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                expires max;
                log_not_found off;
                access_log off;

        location / {
                try_files $uri $uri/ /index.php?$args;

        location ~ .php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_cache_bypass $skip_cache;
                fastcgi_no_cache $skip_cache;
                fastcgi_cache SITE;
                fastcgi_cache_valid 60m;
                include fastcgi_params;

        location ~* ^/wp-includes/.*(?<!(js/tinymce/wp-tinymce)).php$ {

        location = /favicon.ico {
                log_not_found off;
                access_log off;

        location = /robots.txt {
                access_log off;
                log_not_found off;

        location = /wp-config.php {
                deny all;

        location ~* /(?:uploads|files)/.*.php$ {
                deny all;

        location ~* ^/wp-content/.*.(txt|md|exe|sh|bak|inc|php|pot|po|mo|log|sql)$ {
                deny all;

        location ~ /.(ht|svn)? {
                deny all;

        location ~ ^/files/(.*)$ {
                try_files /wp-content/upload/sites/$blogid/$uri /wp-includes/ms-files.php?file=$1;
                access_log off; log_not_found off;

        location ^~ /sites {
                alias /var/www/;
                access_log off; log_not_found off;

        location ~* /(?:uploads|files)/.*.php$ {
                deny all;

My Nginx Config:

user www-data;
worker_processes auto;
worker_rlimit_nofile 100000;
pid /run/;

events {
    worker_connections 4096;
    multi_accept on;

http {

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 30;
    types_hash_max_size 2048;

    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;

    server_tokens off;
    reset_timedout_connection on;
    add_header rt-Fastcgi-Cache $upstream_cache_status;

    limit_req_status 403;
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

    fastcgi_read_timeout 300;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    fastcgi_cache_use_stale error timeout invalid_header http_500;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    client_max_body_size 256m;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    log_format rt_cache '$remote_addr $upstream_response_time $upstream_cache_status [$time_local] '
    '$http_host "$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent"';

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

My SSL Config:

server_tokens off;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver valid=300s;
resolver_timeout 30s;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
# add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
ssl_dhparam /etc/ssl/certs/dhparam.pem;

My Fast CGI PHP Config:

# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+.php)(/.+)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# try_files $uri =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see:
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;

My Fast CGI Params:

#fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_FILENAME $request_filename;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

If anyone can help, I would really appreciate it 🙁 – 🙂

Read more here: FastCGI sent in stderr : PHP message : PHP Fatal error – PHP 7 / Nginx 1.10.3 / 10.1.23-MariaDB / Ubuntu 16.04 / LetsEncrypt 4096 certs

Leave a Reply

Your email address will not be published. Required fields are marked *