I have a PHP laravel app which i want to deploy to Cloud Run.
However the the command
gcloud run deploy --source . Does create the container image successfully and deploy it to cloud run as well but when i access the URL i get the error
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 169.*.*.*, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/layers/google.php.webconfig/webconfig/app.sock:", host: "something.region.run.app", referrer: "https://something.region.run.app/"
I tried adding Nginx config in the environment variable
GOOGLE_CUSTOM_NGINX_CONFIG="nginx-custom.conf"
That did not work as well.
Do i need to pass php-fpm.conf. If so how?
I am assuming this will be implicitly handled by buildpack itself.
Hi @SandeepDeb,
The "Primary script unknown" error is usually caused by a misconfigured SCRIPT_FILENAME
in the Nginx fastcgi_param
directive. This happens when $fastcgi_script_name
doesn’t correctly map to Laravel’s index.php
. Make sure your Nginx config properly sets SCRIPT_FILENAME
to /workspace$fastcgi_script_name
and that your root
is /workspace/public
.
Double-check that you followed the steps in Quickstart: Build and deploy a PHP web app to Cloud Run. If the issue persists, you may contact Google Cloud support or you can also refer to these Stack Overflow posts:
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.