Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

No input file specified solution appears in nginx+php

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

A No input file specified error suddenly appeared in my local development environment today. I repeatedly checked to return my configuration file, configuration path and permissions. After repeated investigation, the problem was finally discovered. Now, the problem and solution are shared as follows:

Cause Analysis

Downloaded an open source tp5 project on GitHub, and my local website ran without problems before. However, after installing this open source project, I found that other local websites could not be accessed. No input file specified error. I also found a solution on the Internet, but it was not. It seems that this mistake is a bit strange.

Later repeated attempts, restart the computer after the problem was solved, but again after running the downloaded tp5 open source project, other sites have such errors No input file specified and only this one site runs without problems.

The error is therefore trapped in the nginx configuration file of the open source project. Take a look at this profile:

server { listen 80; server_name local.test.com; access_log /data/wwwlogs/local.test.com.log combined; error_log /data/wwwlogs/local.test.com_error.log error; index index.html index.htm index.php; root /data/php/test; add_header X-Powered-Host $hostname; fastcgi_hide_header X-Powered-By; if (!- e $request_filename) { rewrite ^/(.+?\. php)/? (.*)$ /$1/$2 last; rewrite ^/(.*)$ /index.php/$1 last; } location ~ \.php($|/){ fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; set $real_script_name $fastcgi_script_name; if ($real_script_name ~ "^(.+?\. php)(/.+)$ ") { set $real_script_name $1; } fastcgi_split_path_info ^(.+?\. php)(/.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param PHP_VALUE open_basedir=$document_root:/tmp/:/proc/; } location ~ .*\. (gif|jpg|jpeg|png|bmp|swf)$ { access_log off; error_log off; expires 30d; } location ~ .*\. (js|css)?$ { access_log off; error_log off; expires 12h; }

The rest of the above configuration is conventional. Because I use CGI. There is a line in the fastcgi parameter that you may have noticed.

fastcgi_param PHP_VALUE open_basedir=$document_root:/tmp/:/proc/;

That's it. The main purpose of this sentence is to set fastcgi's operational directory to prevent cross-site, limiting open_basedir to the directory of the project and/tmp/and/proc/.

problem solving

Just said is in the configuration of fastcgi configuration more than a sentence to prevent cross-site statement. So this sentence actually affects the entire fastcgi parameter, so because the path of my other sites is/data/php/xxx/directory, and not in the open source project directory/data/php/test/so fastcgi can not be found.

So add #comment before this sentence or delete this sentence to restart the system or restart nginx.

Recommendations for online deployment

Do you want to use this sentence or not? Of course, it is possible in an online environment. It is best not to use variables like $document_root in open_basedir for online project deployments. If there are multiple items online on the server, then all items can be placed in a unified directory. For example, my line is wwwroot directory to place other websites. For example/wwwroot/test1 /wwwroot/test2 then I can configure as

fastcgi_param PHP_VALUE open_basedir=/wwwroot/:/tmp/:/proc/;

The above is all the content of this article, I hope to help everyone's study, but also hope that everyone a lot of support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report