Apache PHP-FPM 在 Centos 下出现 AH01071 错误

huangapple go评论62阅读模式
英文:

Apache PHP-FPM Centos AH01071

问题

我有一个CentOS服务器,正在尝试配置apache和php-fpm。我在一个配置文件中有一个虚拟主机。在检查http和php-fpm的状态时一切正常,但在浏览器中尝试访问网站时,出现了与配置文件中FilesMatch部分相关的错误:

<FilesMatch \.php$>
    SetHandler "proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/path/to/docroot"
</FilesMatch>

=> [proxy_fcgi:error] AH01071: Got error 'Primary script unknown'
在浏览器中:找不到文件

<FilesMatch \.php$>
    SetHandler "proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/"
</FilesMatch>

=> [proxy_fcgi:error] AH01071: Got error 'Unable to open primary script: 
/path/to/docroot/index.php (No such file or directory)'
在浏览器中:未指定输入文件

/path/to/docroot也具有apache权限,可能的问题是什么?感谢任何帮助。

<details>
<summary>英文:</summary>

I have a CentOS server and I am trying to configure apache with php-fpm. I have a virtualhost in a conf file. When checking the status of http and php-fpm all is fine but when trying to access the website in the browser,
 I have errors based on the filesmatch part of my conf file : 

     &lt;FilesMatch \.php$&gt;
            SetHandler &quot;proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/path/to/docroot&quot;
     &lt;/FilesMatch&gt;
    
     =&gt; [proxy_fcgi:error]  AH01071: Got error &#39;Primary script unknown&#39;
     In the browser : File not found


     &lt;FilesMatch \.php$&gt;
            SetHandler &quot;proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/&quot;
     &lt;/FilesMatch&gt;
    
    
             =&gt; [proxy_fcgi:error] AH01071: Got error &#39;Unable to open primary script: 
    //path/to/docroot/index.php (No such file or directory)&#39;
             In the browser: No input file specified

The /path/to/docroot also has apache permission, what could be the issue? any help is appreciated.
Thanks

</details>


# 答案1
**得分**: 0

问题出在php.ini中的open_basedir和docroot设置上。我修改了php-fpm.d文件夹中的www.conf文件,添加了这两个设置:

```php
php_admin_value['open_basedir'] = /path/to/base_dir 
php_admin_value['doc_root'] = /path/to/doc_root

然后一切都正常了。

谢谢!

英文:

The problem was the open_basedir and docroot settings in the php.ini. I modified the www.conf file inside php-fpm.d folder to add the two settings :

php_admin_value[&#39;open_basedir&#39;] = /path/to/base_dir 
php_admin_value[&#39;doc_root&#39;] = /path/to/doc_root

and then everything worked.

Thanks!

huangapple
  • 本文由 发表于 2023年2月9日 00:41:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75388969.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定