0

I'm simply trying to run php on nginx on my OSX.

setup

my php-fpm.conf file
my www.conf file
in my nginx.conf file I got this:

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

error

everytime I hit my server I get this error:

2017/12/31 01:45:25 [crit] 1102#0: *2 connect() to unix:/var/run/php-fpm.sock failed (38: Socket operation on non-socket) while connecting to upstream, client: ::1, server: default, request: "POST /api/users/login HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "localhost:8000"

what do I do to fix this?

update

I realized that inside my php-fpm.d/www.conf I got this line

listen = 127.0.0.1:9000

so I updated my nginx conf file:

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000; 
        fastcgi_index index.php;
        include fastcgi_params;
    }

but now I'm getting this error:

2017/12/31 02:07:24 [error] 1429#0: *2 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ::1, server: default, request: "POST /api/users/login HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8000"

update 3

from this answer I added this to nginx conf:

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000; 
        fastcgi_index index.php;
        include fastcgi.conf;
    }

fastcgi.conf has this:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
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  REQUEST_SCHEME     $scheme;
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;

but still same error message

1 Answer 1

0

the solution was simple.. nginx was looking for my index.php.. I supplied the root of my laravel project when in fact I should have put the public diretory in laravel like so:

http {
    server {
        listen 8000 default_server;
        listen [::]:8000 default_server;
        server_name default;
        root /path/to/my/laravel/project/public/index.php; 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.