PHP-FPM sending empty response with Nginx on macOS PHP-FPM sending empty response with Nginx on macOS nginx nginx

PHP-FPM sending empty response with Nginx on macOS


It's hard to help without the ability to read all the configuration files.

You just posted one, not the included ones nor php-fpm.conf. This is not a disapproval (a wall of configuration files is not quite appropriate in a question) but it's just to point out that the configuration file we "don't see" may differ depending on installation.

Anyway I see some differences from the configuration file I have on a server for a wordpress site.

Here are some hints considering that as you don't get any errors php-fpm is running and nginx can "communicate" to it via the socket (otherwise you would get a bad gateway error).


At the beginning...

server {    listen       80;    server_name  wordpress.bob;    root /Users/mark/Sites/wordpress;         index index.php; # <-- ADD THIS

Make sure in the included wordpress.conf you have

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

The last part...

location ~ \.php$ {    fastcgi_split_path_info ^(.+\.php)(/.+)$;    fastcgi_buffer_size 128k;    fastcgi_buffers 256 16k;    fastcgi_busy_buffers_size 256k;    fastcgi_temp_file_write_size 512k;    fastcgi_intercept_errors on;    fastcgi_max_temp_file_size 0;    fastcgi_connect_timeout 3s;    fastcgi_send_timeout 5s;    fastcgi_read_timeout 5s;    include fastcgi.conf; # <--- fastcgi.conf, NOT fastcgi_params    fastcgi_pass /usr/local/var/run/php-www.sock;}

The difference between fastcgi.conf and fastcgi_params (on my installation) is just one line:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

If this line is missing php code is not able to read $_SERVER['SCRIPT_FILENAME'] and (I think) this may break wordpress code resulting in empty output.


Finally make sure php-fpm worker processes have privileges to access /usr/local/var/run/php-www.sock

Usually the socket has the same owner:group of the workers.

The workers user and group is set in php-fpm.conf:

; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user's group;       will be used.user = ......group = ......


To install NGINX with Homebrew :

$ brew install nginx

Run NGINX :

$ sudo nginx

Test the localhost nginx :

http://localhost:8080

NGINX configuration file should be in :

$ /usr/local/etc/nginx/nginx.conf

If you want to change the default port :

$ sudo nginx -s stop$ vim /usr/local/etc/nginx/nginx.conf

Change the : listen 8080;To : listen 80;

To save and Conf and start NGINX run :

$ sudo nginx

Then, according to your problem, you might simply be pointing to a an empty PHP file. Try to print a phpinfo() then look for "DOCUMENT_ROOT" to see where it goes.