thinkphp5开发的网站出现”No input file specified”(php版本5.6.27)

thinkphp5开发的网站出现”No input file specified”(php版本5.6.27)

一、总结

一句话总结:搜索引擎一定要用google,比百度节约时间一万倍,google啊,google搜索出来直接有视频,还有其他很多好处

google

1、出现的问题是什么?

No input file specified

访问php页面跳出来一句 ”No input file specified”

这句错误提示的意思是不能识别访问的路径

2、出现问题的原因是什么?

fast_cgi

原因在于使用的PHP5.6是fast_cgi模式,而在某些情况下,不能正确识别path_info所造成的错误。

3、如何解决?

.php?
Rewrite模块
允许 .htaccess

ab两个步骤一般不需要我们操作,核心就是c步骤

注意:thinkphp的.htaccess规则实在public目录下

这里才是网站的根目录

c、将.htaccess规则里面的匹配.php改成匹配.php?(核心操作)

默认的.htaccess里面的规则:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
“No input file specified.”,是没有得到有效的文件路径造成的。

修改伪静态规则,如下:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
有没有发现不同?

其实就是在正则结果“/$1”前面多加了一个“?”号,问题也就随之解决了。

a、加载Rewrite模块(默认不需要操作)

在apache的conf目录下httpd.conf(apache的配置文件)中找到

LoadModule rewrite_module modules/mod_rewrite.so

这句,去掉前边的注释符号“#”,或添加这句。

b、允许使用“.htaccess”文件(默认不需要操作)

在apache配置域名的时候允许使用“.htaccess”文件

例如:

<VirtualHost *:80>
    DocumentRoot "C:phpStudyPHPTutorialWWWm_Orchestrate-masterm_Orchestratepublic"
    ServerName mo.eduhk.hk
    <Directory "C:phpStudyPHPTutorialWWWm_Orchestrate-masterm_Orchestratepublic">
        Options -Indexes -FollowSymLinks +ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

允许在任何目录中使用“.htaccess”文件,将“AllowOverride”改成“All”(默认为“None”):

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#

AllowOverride All

在Windows系统下不能直接建立“.htaccess”文件,可以在命令行下使用“echo a> .htaccess”建立,然后使用记事本编辑。

4、thinkphp的根目录public中的.htaccess修改好后的样子?

IfModule
<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

5、正则里面的“?”是什么意思?

零次或一次 非贪婪

“?:”非获取匹配,匹配冒号后的内容但不获取匹配结果,不进行存储供以后使用。

单独的“?”:匹配前面的子表达式零次或一次。

当“?”紧跟在任何一个其他限制符(*,+,?,{n},{n,},{n,m})后面时,匹配模式是非贪婪的。非贪婪模式尽可能少地匹配所搜索的字符串,而默认的贪婪模式则尽可能多地匹配所搜索的字符串。

6、.htaccess文件是做什么的?

分布式配置文件 目录 配置

.htaccess文件(或者"分布式配置文件"),全称是Hypertext Access(超文本入口)。提供了针对目录改变配置的方法, 即,在一个特定的文档目录中放置一个包含一个或多个指令的文件, 以作用于此目录及其所有子目录。作为用户,所能使用的命令受到限制。管理员可以通过Apache的AllowOverride指令来设置。

7、.htaccess文件中如何配置系统允许上传的文件的大小及数目?

IfModule php_value

apache中的都配置都是IfModule这样一块一块的

<IfModule mod_php5.c>
    php_value upload_max_filesize 100M
    php_value post_max_size 100M
</IfModule>

二、内容在总结中

 
原文地址:https://www.cnblogs.com/Renyi-Fan/p/10178784.html