Fastcgi sent in stderr primary script unknown php fpm

Nginx ошибка — Primary script unknown ?

Всем привет.
Ставил третий сервер, вроде те же настройки и т.д.
Но вот ошибка впервые появилась.

2014/10/21 03:03:50 [error] 6068#0: *3 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: test.lan, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "test.lan"
server < listen 127.0.0.1:80; server_name test.lan www.test.lan; root var/www/test.lan/public_html; #index app.php index.php app_dev.php access_log /var/www/test.lan/access_log.log; error_log /var/www/test.lan/error_log.log; try_files $uri @rewriteapp; location @rewriteapp < rewrite ^(.*)$ /app.php/$1 last; >location ~ ^/(app|app_dev|config)\.php(/|$) < include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param HTTPS off; >if ($host = 'www.test.lan') < rewrite ^/(.*)$ http://andr.lan/$1 permanent; >>

Не могу понять в чем дело.
www-data:www-data 0755

Ошибка говорит о том, что php-fmp на может найти файл, который вы просите запустить.
Вообще если отследить прохождения запроса по вашему конфигу, то получается примерно следующие:
1. пришел запрос, пусть даже /
2. try_files такой файл не находит и отправляет его в @rewriteapp;
3. @rewriteapp отправляет нас на адрес /app.php//
4. теперь после реврайта мы попадаем в location и тут указываем, что
SCRIPT_FILENAME = var/www/test.lan/public_html/app.php//
вот этот адрес php-fmp и не находит.

Читайте также:  Css fit background images with

p.s. вы уверены, что хотели указать относительный адрес в директиве root?
В php-fmp он тоже приходит как относительный, и я вот так сразу ни скажу, корень у него сейчас текущая директория или какая другая.

Войдите, чтобы написать ответ

SSI + FastCGI + PHP = ошибка, что делать?

Источник

Почему php-fpm не находит файл?

Sleuthhound

Ошибка «FastCGI sent in stderr: «Primary script unknown» while reading response header from upstream» говорит о том, что Nginx не может найти указанный в файле конфигурации скрипт, речь про эту строку:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Рекомендация тут простая — проверьте все пути и убедитесь, что все нужные файлы существуют и лежат на своих местах.

Конкретно в Вашем случае я не вижу определения директивы root за пределами location / или в нем.

Если вы не можете разобраться, в каком каталоге Nginx ищет нужный скрипт, то на узле vh2_fphp7.0 запускаете:

tcpdump port 9000 -A | strings

Вывод покажет всю нужную информацию, в том числе путь к скрипту.

Так же можно включить логирование:

Так же возможно вы неправильно написали регулярку в директиве fastcgi_split_path_info, см. оф. документацию.

Так же проверьте значение cgi.fix_pathinfo = 1 (в некоторых мануалах советуют cgi.fix_pathinfo = 0 что может привести к не правильной обработке переменной PHP_SELF не равной DOCUMENT_URI).

if (!-f $document_root$fastcgi_script_name)

по моему абсолютно излишни, уберите их или используйте try_files.
Я конечно понимаю, что сами разработчики Nginx в этой статье написали так. , но.

Источник

PHP-FPM: How to fix ‘Primary script unknown’ or ‘file not found’

How to fix nginx Primary script unknown or file not found

I encountered this error yesterday after upgraded php-* packages then restart its service. All my websites were stopped working, I got ‘File not found.’ message on the screen and found the ton repeated of error messages in log of nginx Primary script unknown.

TL;DR:

  • Since php-fpm version 7.4.0 php-fpm.service defines ProtectHome=true which restricts access to files located within /home , /root and /run/user , yielding the error message No input file specified .
  • To fix this problem, either set ProtectHome=false in php-fpm.service file or move your document root.

The issue I’m facing after fully upgraded system, reboot my VPS:

  • Browsing to it in browser returns the text “File not found”.
  • nginx error.log contains:

2019/12/17 15:36:09 [error] 1502#1502: *1 FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream, …

The message is telling us that the FastCGI handler doesn’t like whatever it was sent for some reason. The problem is that sometimes we have no idea what the reason is. On my experience of using nginx, the error message Primary script unknown is almost always related to a wrongly set SCRIPT_FILENAME in the nginx fastcgi_param directive or incorrect permissions. It’s seem correctly answer when the php-fpm.service stopped working with error:

ERROR: failed to open configuration file ‘/etc/php/php-fpm.conf’: Permission denied (13)

I tried turns out that the root location had to match the location of the files on the php-fpm as that’s what was being past through via:

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name

But it doesn’t work.
Well, if I remove my SCRIPT_FILENAME then all I get is an empty, white, blank page by nginx. No error messages either. It’s mean fastcgi_param is not cause of this problem.
If the SCRIPT_FILENAME is wrong, it may also be PHP is running as the wrong user/group. I take a look on php-fpm.conf , php-fpm.d/www.conf and double-checked for errors and inconsistencies. Everything is ok , no conflicted.
Just wait, I stored all LEMP’s config files in a folder then created symlinks of them to /etc/nginx/ and /etc/php folders. Everything was working fine before I upgraded php-fpm to version 7.4.0. After that, the PHP service only started when all the symbolic links were replaced by real files. Furthermore, my website has ‘file not found‘ error, it’s meaning the files on server is inaccessible. They were isolated.
So I’m seem to figure out what is causing this. It’s PHP-FPM service. It has ProtectHome set to true since 7.4.0!
This problem was caused by ProtectHome=true in the php-fpm systemd unit file if you are serving files in /home such as in a virtual host environment. You can disable this feature by editing the php-fpm unit file and restarting php-fpm.

Looking for ProtectHome=true then change it to false or add the following:

Alternatively, move your document root.
If you are not sure about the ProtectHome is existed, here is the command to check it is running:

$ sudo systemctl cat php-fpm.service | grep ProtectHome ProtectHome=true

Before restart php-fpm service, make sure to reload the systemd daemon:

$ sudo systemctl daemon-reload

It’s done. Everything is OK now.

What is ProtectHome?

  • If true, the directories /home , /root , and /run/user are made inaccessible and empty for processes invoked by this unit.
  • If set to “ read-only “, the three directories are made read-only instead.
  • If set to “ tmpfs “, temporary file systems are mounted on the three directories in read-only mode. The value “ tmpfs ” is useful to hide home directories not relevant to the processes invoked by the unit, while still allowing necessary directories to be made visible when listed in BindPaths= or BindReadOnlyPaths= .

Divi 3 is the Ultimate Multi-Purpose and Best Drag Drop WordPress Theme that fit any occasion and it has the tools you need to make your vision a reality …

There are best 10 WordPress plugins which listed here will allow you Improve WooCommerce Product Variations with Swatches, and Photos. …

Do you know? Google is cracking down on mobile-unfriendly sites. If your site isn’t optimized for mobile, you’re losing a whole chunk of users on the go who will quickly look elsewhere if your site does’t load on their device. Here’re 3 fantastic plugins that will automatically optimize your WordPress site for all types of mobile devices. …

There are dozens of WordPress invoice plugins which you can use to turn WordPress into an excellent invoicing and billing system. They help you to generate, edit and send customized and itemized invoices to your clients without having to leave your WordPress site’s control panel. …

About NARGA.NET

NARGA is a blog dedicated to share top quality open source resources for web developer and web designer weekly (then daily asap).
As a web designer or developer, you’ll find some of the best free icons, stock photos, fonts, free WordPress themes, userful WordPress plugins, best jQuery plugins, CSS3 snippets, HTML5 standard and a lot more …

Connect with Us

This site is licensed under Attribution-NonCommercial-ShareAlike 3.0 license. Feel free to change, reuse modify and extend it. Some authors will retain their copyright on certain articles.
NARGA.NET utilizes affiliate links and may receive a comission if you click an affiliate link and make a purchase. No worries though, you’ll still pay the standard amount so there’s no cost on your part.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastCGI sent in stderr: «Primary script unknown» while reading response header from upstream #167

FastCGI sent in stderr: «Primary script unknown» while reading response header from upstream #167

Comments

Am I the only one struggling using drupal:8.8.1-fpm-alpine with Nginx? Either I missed an obvious part about how FPM works or there is some ENV VARs to be tuned with this image:

upstream drupal_user_container < server user_asmodius_drupal:9000; > server < listen 80; server_name user.eu; root /var/www/html/user; location = /favicon.ico < log_not_found off; access_log off; > location = /robots.txt < allow all; log_not_found off; access_log off; > location ~ ^/sites/.*/private/ < return 403; > location / < try_files $uri /index.php?$query_string; > location @rewrite < rewrite ^/(.*)$ /index.php?q=$1; > location ~ /vendor/.*\.php$ < deny all; return 404; > location ~ '\.php$|^/update.php' < fastcgi_split_path_info ^(.+?\.php)(|/.*)$; include fastcgi_params; fastcgi_param HTTP_PROXY ""; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; # HERE IS PROBABLY THE ISSUE fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_intercept_errors on; fastcgi_pass drupal_user_container; > location ~ ^/sites/.*/files/styles/ < # For Drupal >= 7 try_files $uri @rewrite; > # Handle private files through Drupal. location ~ ^/system/files/ < # For Drupal >= 7 try_files $uri /index.php?$query_string; > # prevent hotlinking location ~ ^/sites/.*/files/ < if ($invalid_referer) < return 403; > > location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ < if ($invalid_referer) < return 403; > expires max; log_not_found off; >

Nothing quite fancy with this docker compose, I just mount /var/www/html so that Nginx could serve static files

nginx: container_name: $_nginx restart: always networks: - monitoring - web image: nginx:1.17.5-alpine entrypoint: /entrypoint.sh ports: - 80:80 - 443:443 volumes: - user_www:/var/www/html/user:ro drupal: restart: always container_name: "user_$_drupal" image: drupal:8.8.1-fpm-alpine networks: - web - backend volumes: - user_www:/var/www/html
 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.128.1, server: user.eu, request: "GET / HTTP/1.1", upstream: "fastcgi://192.168.144.4:9000", host: "user.eu" 

The text was updated successfully, but these errors were encountered:

Источник

Оцените статью