php artisan storage:link issue when using Laravel and Docker - php

This seems to be a common issue when people setup a Docker Container to serve a Laravel App using the container.
My setup is mostly this (I removed some of the other services because I do no think they apply here)
#docker-compose up --build
version: "2"
services:
nginx:
image: nginx
depends_on: [pacs-1,mysql_db]
restart: unless-stopped
ports: ["443:443"]
volumes:
- ./nginx-home:/nginx-home
- ./tls:/etc/nginx/tls
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
php-fpm:
build: php-fpm
volumes:
- ./nginx-home:/nginx-home
The default.conf for nginx for Laravel project is:
server {
# implement the TLS
listen 443 ssl;
server_name dockerlaravel.medical.ky;
root /nginx-home/PortalRads/public;
access_log /nginx-home/logs/PortalRads-access.log;
error_log /nginx-home/logs/PortalRads-error.log info;
index index.php index.html index.htm;
client_max_body_size 4000M;
client_body_buffer_size 4000M;
# skip favicon.ico
#
#location = /favicon.ico {
#access_log off;
return 444;
#
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
error_page 404 /error_pages/404.php;
error_page 403 /error_pages/403.php;
error_page 401 /error_pages/401.php;
error_page 500 502 503 504 /errors/50x.html;
}
}
Everything actually seems to work OK once I get it all setup. Composer is installed globally on the host, and I use composer update on the host side to update the package. It does not seem like it is necessary to install composer on Docker with the setup that I have since the php container has php and the artisan binary is at the root of my Laravel app.
The problem that I am having is that the symlink from public/storage to the storage folder does not seem to be working. I have tried various methods to create the link. I actually have separate containers for nginx and php, so artisan will not run in the nginx container.
Since I am using nginx as a webserver, wondering if it might just be possible to have another location block or server block that will basically create that connection on the server side so that I do not have to fiddle around the the symlink created by artisan ?
location /storage/ {
root . . .
. . .
}
I can get into those containers from the CLI using:
sudo docker exec -it orthanc-docker-dev_ris_php-fpm_1 /bin/bash
sudo docker exec -it orthanc-docker-dev_ris_nginx_1 /bin/bash
and I've tried created the symlink from within the container(s) and that does not seem to work either.
As an example, I am using JetStream with Livewire in Laravel and the profile photos there map to:
https://dockerlaravel.medical.ky/storage/profile-photos/image.png
But that gives a 404 error because the symlink must not be setup correctly.
There are quite a few posts about that issue. Just wondering what the "best" solution is, preferably one that can be automated during the build of the containers so the user does not have to worry about that.
Thanks.

Related

Docker - NGINX - PHP-FPM - WordPress - The Page Isn’t Redirecting Properly

I had two WordPress websites on a Synology NAS at home running on NGINX with PHP-FPM 7.4 with virtual hosts.
I am moving these websites on a Debian VM also at home, and run the services in rootless Docker:
MariaDB official Docker container
NGINX official Docker container
PHP-FPM official Docker container
These websites are exposed through a Traefik Docker container and my DNS and Let's Encrypt certificates are managed with the Cloudflare API.
When I try to access to www.wordpress1.com, I get "The Page Isn’t Redirecting Properly" error.
I tried to add a phpinfo.php files in my WordPress websites, and I can access these files from WAN without any problem.
I tried to add a static website, and I can access it without any problem from WAN.
I have checked the logs for the two websites, and I get a lot of these errors:
GET / HTTP/1.1" 301 5
Here are my configuration files.
NGINX compose.yaml:
version: '3'
services:
nginx:
image: nginx:latest
container_name: nginx
restart: always
security_opt:
- no-new-privileges:true
networks:
- backend
- traefik
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./conf/servers.conf:/etc/nginx/conf.d/default.conf
- ./log:/var/log/nginx
- nginx_data:/var/www/html
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx.entrypoints=http"
- "traefik.http.routers.nginx.rule=Host(`static.com`,`www.wordpress1.com`,`www.wordpress2.com`)"
- "traefik.http.middlewares.nginx-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.nginx.middlewares=nginx-https-redirect"
- "traefik.http.routers.nginx-secure.entrypoints=https"
- "traefik.http.routers.nginx-secure.rule=Host(`static.com`,`www.wordpress1.com`,`www.wordpress2.com`)"
- "traefik.http.routers.nginx-secure.tls=true"
- "traefik.http.routers.nginx-secure.service=nginx"
- "traefik.http.services.nginx.loadbalancer.server.port=80"
- "traefik.docker.network=traefik"
volumes:
nginx_data:
external: true
networks:
backend:
external: true
traefik:
external: true
NGINX servers.conf:
server {
listen 80;
server_name static.com;
root /var/www/html/static;
index index.html;
error_log /var/log/nginx/static_error.log;
access_log /var/log/nginx/static_access.log;
}
server {
listen 80;
server_name www.wordpress1.com;
root /var/www/html/wordpress1;
index index.php index.html;
error_log /var/log/nginx/wordpress1_error.log;
access_log /var/log/nginx/wordpress1_access.log;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
}
server {
listen 80;
server_name www.wordpress2.com;
root /var/www/html/wordpress2;
index index.php index.html;
error_log /var/log/nginx/wordpress2_error.log;
access_log /var/log/nginx/wordpress2_access.log;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
}
PHP compose.yaml:
version: '3'
services:
php:
build:
context: .
dockerfile: ./Dockerfile
image: custom/php:7.4-fpm
container_name: php
restart: always
security_opt:
- no-new-privileges:true
networks:
- backend
user: 1234:1234
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- nginx_data:/var/www/html
volumes:
nginx_data:
external: true
networks:
backend:
external: true
PHP Dockerfile:
FROM php:7.4-fpm
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && install-php-extensions mysqli exif imagick zip
In the nginx_data volume, my permissions are 1234:1234, which are my docker user UID and GID on my rootless Docker install.
My database is on a mariadb docker container and the connection works (modified in the wp-config.php).
I don't understand why I can access the static website, why the phpinfo in the WordPress websites works, and why the WordPress websites doesn't work.
I though it was a problem of permission, but I used the "user" parameter in my PHP Docker container to specify it.
Thanks for your help.
[Edit] It seems the second WordPress website is displayed. So only the first one has this redirection error problem.
I tried with PHP v7.4 and PHP v8.1, same result.
I would suggest you to delete the previous SSL if you copied it, also delete the .httacess file if you copied it from the old one, if the problem persists you should check if any php extension is not installed.

RaspberryPi webserver with nginx and docker only displays Welcome to nginx

I try to create a small webserver on my raspberry pi with docker.
This is my docker-compose file:
version: "3.6"
services:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- /home/pi/testData/code:/var/www/html
- /home/pi/testData/site.conf:/etc/nginx/conf.d/site.conf
depends_on:
- php
php:
image: php:7.4-fpm
volumes:
- /home/pi/testData/code:/var/www/html
And this my site.conf
server {
index index.html index.php;
listen 80;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
Inside of the folder /home/pi/testData/code is a file named index.php which just echos a Hello World.
So this file will be mapped into the Docker Container into the path /var/www/html/ and inside of the site.conf is the root mentioned also to /var/www/html.
I also checked if the files are really available inside of the nginx container - both are.
So as I understand it: If I put an index-file inside of the /var/www/html folder of my nginx docker container, then this file should be displayed if I call the IP of my Raspberry pi on Port 8080.
But unfortunately I only receive the Welcome to Nginx Page.
Did I miss something or did I something wrong?
Nginx will load configuration files found in /etc/nginx/conf.d/ and their names ends with .conf as suffix in alphabetical order.
Your configuration does have conflicting server name with the default configuration file of nginx. /etc/nginx/conf.d/default.conf
you can check that by exec into nginx container and run nginx -t command to check the configuration for warnings and errors.
you should see something like:
[warn] 502#502: conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
you should rename the default file to a something like default.conf.old or you can simply overwrite its contents with your configuration.

How to configure an nginx.conf with a dockerised drupal website?

this is my first time working with nginx and I'm using it to access my dockerised drupal appliction from a production subdomain.
So before everything, I'm currently using docker-compose to create my sql, app, and webservice containers, here is my docker-compose file :
version: '3'
services:
app:
image: osiolabs/drupaldevwithdocker-php:7.4
volumes:
- ./docroot:/var/www/html:cached
depends_on:
- db
restart: always
container_name: intranet
db:
image: mysql:5.5
volumes:
- ./mysql:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=linux1354web
- MYSQL_USER=root
- MYSQL_PASSWORD=linux1354web
- MYSQL_DATABASE=intranet
container_name: intranet-db
web:
build: ./web
ports:
- 88:80
depends_on:
- app
volumes:
- ./docroot:/var/www/html:cached
restart: always
container_name: webIntranet
I don't think the containers are the problem, as when I go to the drupal containers the site works, but my main problem is the link with the nginx container. Here is my nginx.conf :
# stuff for http block
client_max_body_size 1g;
# fix error: upstream sent too big header while reading response header from upstream
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
server {
listen 80;
listen [::]:80 default_server;
server_name _;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
#RENVOYER LA PAGE DE GARDE DE APACHE2
location / {
# try to serve file directly, fallback to app.php
try_files $uri /index.php?$query_string; # For Drupal >= 7
}
location /intranet {
# try to serve file directly, fallback to app.php
try_files $uri $uri/;
}
#RENVOYER LE FICHIER ROBOTS.TXT
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~ \.php(/|$) {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:80;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
}
}
And this is my DockerFile to build nginx image:
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
When I go to localhost:88/ I currently have a apache2 hub page, but the moment I'm trying for another page I always get a 502 bad gateway error and the logs are saying :
webIntranet | 2021/03/11 08:44:55 [error] 30#30: *1 upstream sent unsupported FastCGI protocol version: 72 while reading response header from upstream, client: 172.26.0.1, server: _, request: "GET /index HTTP/1.1", upstream: "fastcgi://172.26.0.3:80", host: "localhost:88"
To go more into details, my docker folder looks like that, docroot containes the drupal website.
I have tried sovling the problem by changing the ports as some solution mentionned it but it did nothing, I don't understand what could be wrong, I've tried many things with the conf but none of them works, and I still even can't have a single page of the drupal site showing up.
The drupaldevwithdocker-php project isn't using php-fpm, hence the response is unsupported as it's from apache rather than php-fpm. I'd imagine you'd need something more like this?
proxy_pass http://app:80;
See https://gist.github.com/BretFisher/468bca2900b90a4dddb7fe9a52143fc6

Nginx Docker Container - forwarding php-file requests to php-fpm container

I already asked the same question on superuser (https://superuser.com/questions/1298776/nginx-execute-php-files-in-different-docker-container) but it was not possible to get an answer, maybe this problem is too specific for SU.
I am using an automated docker-image for php-fpm and nginx (https://hub.docker.com/r/tobi312/rpi-php/ and https://hub.docker.com/r/tobi312/rpi-nginx/ ) running on a raspberry pi with with libreelec on top.
The php container successfully starts with port 9000 open by running the following command:
docker run --name php -v /var/www/restTools:/var/www/html -d 3dd6ff8c0d58
After that I started the nginx-container like this:
docker run --name nginx -d -p 8081:80 --link php:9000 -v /var/www/restTools:/var/www/html 0d90cc6eb00f
Both containers are running but the nginx is not executing php files, it's just offering them for download.
After a while I tried to commit the connections details to the php-container trough a default.conf by adding -v /var/www/.config/nginx:/etc/nginx/conf.d:ro to the command.
Excerpt from default.conf:
root /var/www/html;
location / {
root /var/www/html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /var/www/html;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
}
What am I missing?
You are trying to use the (deprecated!!) "link" option of docker, this is not a problem itself, but you have to respect the syntax
--link <name or id>:alias
so, you have to substitute your
--link php:9000
with the correct
--link php
you do not need an alias because you named the fpm container the same as you referred it in default.conf.
The other important thing is to mount the php files folder in the fpm container but you already did this right.

File Not Found when running PHP with Nginx

Recently I installed the latest version of Nginx and looks like I'm having hard time running PHP with it.
Here is the configuration file I'm using for the domain:
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
Here is the error I'm getting on the error log file:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
Try another *fastcgi_param* something like
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
I had the "file not found" problem, so I moved the "root" definition up into the "server" bracket to provide a default value for all the locations. You can always override this by giving any location it's own root.
server {
root /usr/share/nginx/www;
location / {
#root /usr/share/nginx/www;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
Alternatively, I could have defined root in both my locations.
Probably it's too late to answer but a couple things since this is a really annoying error. Following solution worked on Mac OS X Yosemite.
It's the best if you have
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
The include with fast cgi params should go above that line.
All your directories down to the PHP file you're executing (including that file too) should have a+x permissions, e.g.
sudo chmod a+x /Users/
sudo chmod a+x /Users/oleg/
sudo chmod a+x /Users/oleg/www/
sudo chmod a+x /Users/oleg/www/a.php
I had been having the same issues,
And during my tests, I have faced both problems:
1º: "File not found"
and
2º: 404 Error page
And I found out that, in my case:
I had to mount volumes for my public folders both on the Nginx volumes and the PHP volumes.
If it's mounted in Nginx and is not mounted in PHP, it will give: "File not found"
Examples (Will show "File not found error"):
services:
php-fpm:
build:
context: ./docker/php-fpm
nginx:
build:
context: ./docker/nginx
volumes:
#Nginx Global Configurations
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/conf.d/:/etc/nginx/conf.d
#Nginx Configurations for you Sites:
# - Nginx Server block
- ./sites/example.com/site.conf:/etc/nginx/sites-available/example.com.conf
# - Copy Public Folder:
- ./sites/example.com/root/public/:/var/www/example.com/public
ports:
- "80:80"
- "443:443"
depends_on:
- php-fpm
restart: always
If it's mounted in PHP and is not mounted in Nginx, it will give a 404 Page Not Found error.
Example (Will throw 404 Page Not Found Error):
version: '3'
services:
php-fpm:
build:
context: ./docker/php-fpm
volumes:
- ./sites/example.com/root/public/:/var/www/example.com/public
nginx:
build:
context: ./docker/nginx
volumes:
#Nginx Global Configurations
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/conf.d/:/etc/nginx/conf.d
#Nginx Configurations for you Sites:
# - Nginx Server block
- ./sites/example.com/site.conf:/etc/nginx/sites-available/example.com.conf
ports:
- "80:80"
- "443:443"
depends_on:
- php-fpm
restart: always
And this would work just fine (mounting on both sides) (Assuming everything else is well configured and you're facing the same problem as me):
version: '3'
services:
php-fpm:
build:
context: ./docker/php-fpm
volumes:
# Mount PHP for Public Folder
- ./sites/example.com/root/public/:/var/www/example.com/public
nginx:
build:
context: ./docker/nginx
volumes:
#Nginx Global Configurations
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/conf.d/:/etc/nginx/conf.d
#Nginx Configurations for you Sites:
# - Nginx Server block
- ./sites/example.com/site.conf:/etc/nginx/sites-available/example.com.conf
# - Copy Public Folder:
- ./sites/example.com/root/public/:/var/www/example.com/public
ports:
- "80:80"
- "443:443"
depends_on:
- php-fpm
restart: always
Also here's a Full working example project using Nginx/Php, for serving multiple sites:
https://github.com/Pablo-Camara/simple-multi-site-docker-compose-nginx-alpine-php-fpm-alpine-https-ssl-certificates
I hope this helps someone,
And if anyone knows more about this please let me know,
Thanks!
I just spent like 40 minutes trying to debug a non-working /status with:
$ SCRIPT_NAME=/status SCRIPT_FILENAME=/status QUERY_STRING= REQUEST_METHOD=GET cgi-fcgi -bind -connect /var/run/php5-fpm.sock
It just produced "File not found" error, while the actual scripts (that are found on the filesystem) worked just fine.
Turned out, I had a couple of orphaned processes of php5-fpm. After I killed everything and restarted php5-fpm cleanly, it just went back to normal.
Hope this helps.
The error message “Primary script unknown or in your case is file not found.” is almost always related to a wrongly set in line SCRIPT_FILENAME in the Nginx fastcgi_param directive (Quote from https://serverfault.com/a/517327/560171).
In my case, I use Nginx 1.17.10 and my configuration is:
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 600;
}
You just change $document_root to $realpath_root, so whatever your root location, like /var/www/html/project/, you don't need write fastcgi_param SCRIPT_FILENAME /var/www/html/project$fastcgi_script_name; each time your root is changes. This configuration is more flexible. May this helps.
=================================================================================
For more information, if you got unix:/run/php/php7.2-fpm.sock failed (13: Permission denied) while connecting to upstream, just change in /etc/nginx/nginx.conf, from user nginx; to user www-data;.
Because the default user and group of PHP-FPM process is www-data as can be seen in /etc/php/7.2/fpm/pool.d/www.conf file (Qoute from https://www.linuxbabe.com/ubuntu/install-nginx-latest-version-ubuntu-18-04):
user = www-data
group = www-data
May this information gives a big help
In my case the PHP-script itself returned 404 code. Had nothing to do with nginx.
In my case, it was because the permissions on the root web directory were not set correctly. To do this, you need to be in the parent folder when you run this in terminal:
sudo chmod -R 755 htmlfoldername
This will chmod all files in your html folder, which is not recommended for production for security reasons, but should let you see the files in that folder, to be sure that isn't the issue while troubleshooting.
I had this error as well. In my case it was because there was another virtual host that was pointing to the same root directory.
After upgrading to PHP72, we had an issue where the php-fpm.d/www.conf lost the settings for user/group which was causing this error. Be sure to double check those if your setup involves php-fpm.
The website will show "File Not Found" error.
You should check this configure file: /etc/nginx/nginx.conf (error_log) to get the nginx webservice log location.
Then check nginx log: /var/log/nginx/error.log to get the root cause:
Keyword: FastCGI sent in stderr: "Primary script unknown"
Root cause: php-fpm service's account: apache doesn't have access permission to open webapps directory
Step 0. Find your root directory:
open /etc/nginx/nginx.conf file and find root keyword
Root directory: /var/lib/nginx/webapps/
Step 1. Make sure apache account can access the ROOT directory.
sudo -u apache ls -l /var/lib/nginx/webapps/
Step 2. chmod a+x permission for all ROOT folder
sudo chmod a+x /var/
sudo chmod a+x /var/lib/
sudo chmod a+x /var/lib/nginx/
sudo chmod a+x /var/lib/nginx/webapps/
For me, problem was Typo in location path.
Maybe first thing to check out for this kind of problem
Is path to project.
When getting "File not found", my problem was that there was no symlink in the folder where was pointing this line in ngix config:
root /var/www/claims/web;
in case it helps someone, my issue seems to be just because I was using a subfolder under my home directory, even though permissions seem correct and I don't have SELinux or anything like that.
changing it to be under /var/www/something/something made it work.
(if I ever found the real cause, and remember this answer, I'll update it)
try this command
sudo chmod 755 -R htdocs/
my case: I used relative dir
location ~* \.(css|js)\.php$ {
root ../dolibarr/htdocs;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
this line did not work too : fastcgi_param SCRIPT_FILENAME /vagrant/www/p1/../p2/htdocs/core/js/lib_head.js.php;
So I discovered fastcgi_param does not support relative path.
This works
fastcgi_param SCRIPT_FILENAME /vagrant/www/p2/htdocs/core/js/lib_head.js.php;
I have solved this issue in nginx version: nginx/1.21.3 PHP 7.4.23 macOS Catalina version 10.15.7
nano /usr/local/etc/nginx/nginx.conf
location ~ \.php$ {
root html;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#Comment bellow Line
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#Add This line
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
For me, this File not found problem was because i started php-fpm as sudo. First, stop it as sudo and then start without sudo.

Categories