英文:
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 :
<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'
In the browser : File not found
<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)'
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['open_basedir'] = /path/to/base_dir
php_admin_value['doc_root'] = /path/to/doc_root
and then everything worked.
Thanks!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论