php pear.php 问题
小弟机器上面调了Pear.php但是访问的时候提示没有权限,这个文件/usr/local/php/lib/php/PEAR.php 是存在的,我用的是nginx +php-fpm 的环境,网上有说在php.ini 中设置
open_basedir ="./:/usr/local/php/lib/php/"
这个,还是不行
PHP Version 5.4.41
下面是报错,
2015/08/12 16:05:14 [error] 4786#0: *5 FastCGI sent in stderr: "PHP message: PHP Warning: require_once(): open_basedir restriction in effect. File(/usr/local/php/lib/php/PEAR.php) is not within the allowed path(s): (/home/wwwroot/editor.com:/tmp/:/proc/) in /home/wwwroot/editor.com/Mail.php on line 46
PHP message: PHP Warning: require_once(/usr/local/php/lib/php/PEAR.php): failed to open stream: Operation not permitted in /home/wwwroot/editor.com/Mail.php on line 46
PHP message: PHP Fatal error: require_once(): Failed opening required 'PEAR.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/editor.com/Mail.php on line 46" while reading response header from upstream, client: 1
回复讨论(解决方案)
你看看 open_basedir 的值
当 open_basedir 非空的情况下,php 只能访问 open_basedir 指定的目录
phpinfo() 查看到是这个文件
Loaded Configuration File /usr/local/php/etc/php.ini
查看php.ini的值是
-------------------------------------------------------------------------------
; open_basedir, if set, limits all file operations to the defined directory
; and below. This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/open-basedi
open_basedir ="./:/usr/local/php/lib/php/"#这个是我自己设置的
---------------------------------------------------------------------------------------------
[root@localhost ~]# ll /usr/local/php/lib/php/
total 84
drwxr-xr-x 2 root root 20 Aug 12 14:41 Archive
drwxr-xr-x 2 root root 4096 Jun 12 16:22 build
drwxr-xr-x 2 root root 23 Aug 12 14:41 Console
drwxr-xr-x 5 root root 60 Aug 12 15:16 data
drwxr-xr-x 9 root root 124 Aug 12 15:16 doc
drwxr-xr-x 3 root root 38 Jun 12 16:29 extensions
drwxr-xr-x 2 root root 6 Aug 12 14:34 htdocs
drwxr-xr-x 3 root root 40 Aug 12 15:16 HTTP
drwxr-xr-x 2 root root 21 Aug 12 15:16 Net
drwxr-xr-x 2 root root 22 Aug 12 14:41 OS
drwxr-xr-x 11 root root 4096 Aug 12 14:41 PEAR
-rw-r--r-- 1 root root 15188 Aug 12 14:41 pearcmd.php
-rw-r--r-- 1 root root 34864 Aug 12 14:41 PEAR.php
-rw-r--r-- 1 root root 1033 Aug 12 14:41 peclcmd.php
drwxr-xr-x 3 root root 38 Aug 12 15:16 Services
drwxr-xr-x 3 root root 34 Aug 12 14:41 Structures
-rw-r--r-- 1 root root 20292 Aug 12 14:41 System.php
drwxr-xr-x 9 root root 139 Aug 12 15:16 test
drwxr-xr-x 3 root root 48 Aug 12 15:16 Text
drwxr-xr-x 2 root root 21 Aug 12 14:41 XML
---------------------------------------------------------------------------------------
目录下面是有这个PEAR.php这个文件的
-----------------------------------------------------------------------------------
但是Nginx 报错了以下的错
--------------------------------------------------------------------------------------
2015/08/13 09:51:38 [error] 635#0: *17 FastCGI sent in stderr: "PHP message: PHP Warning: require_once(): open_basedir restriction in effect. File(/usr/local/php/lib/php/PEAR.php) is not within the allowed path(s): (/home/wwwroot/editor.com:/tmp/:/proc/) in /home/wwwroot/editor.com/Mail.php on line 46
PHP message: PHP Warning: require_once(/usr/local/php/lib/php/PEAR.php): failed to open stream: Operation not permitted in /home/wwwroot/editor.com/Mail.php on line 46
PHP message: PHP Fatal error: require_once(): Failed opening required 'PEAR.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/editor.com/Mail.php on line 46" while reading response header from upstream, client: 127.0.0.1,
-------------------------------------------------------------------------------------------------------------------------------
版本主你看看这个是什么问题?
不要设置 open_basedir
;open_basedir ="./:/usr/local/php/lib/php/"#这个是我自己设置的
pear 的路径要加在 include_path 中
按照版主的指示
---------------------------
; UNIX: "/path1:/path2"
include_path = ".:/php/includes:/usr/local/php/lib/php/"
;open_basedir ="./:/usr/local/php/lib/php/" #我试了一下开启也不行
------------------------------------
重启了php-fpm 和nginx
结果还是报了这个错
-----------------------------------------------
2015/08/13 10:18:20 [error] 4110#0: *1 FastCGI sent in stderr: "PHP message: PHP Warning: require_once(): open_basedir restriction in effect. File(/usr/local/php/lib/php/PEAR.php) is not within the allowed path(s): (/home/wwwroot/editor.com:/tmp/:/proc/) in /home/wwwroot/editor.com/Mail.php on line 46
PHP message: PHP Warning: require_once(/usr/local/php/lib/php/PEAR.php): failed to open stream: Operation not permitted in /home/wwwroot/editor.com/Mail.php on line 46
PHP message: PHP Fatal error: require_once(): Failed opening required 'PEAR.php' (include_path='.:/php/includes:/usr/local/php/lib/php/') in /home/wwwroot/editor.com/Mail.php on line 46" while reading response header from upstream, client: 127.0.0.1, server: editor.com, request: "POST /appBaseInfoSaver.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "editor.com", referrer: "http://editor.com/appBaseInfo.php?t=new&tplt=capricorn"
版本主你好,我这边 把问题解决了
最终是在nginx 里面加一加这个
fastcgi_param PHP_VALUE open_basedir="open_basedir=$document_root:/usr/local/php/lib/php/:/tmp/:/home/wwwroot/";

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Alipay PHP...
