nginx 中 PHP 调用PEAR.php遇到的问题

简介: 公司有个老项目,写了很多年了,是在apache 上面跑的,无意间,我想让它跑到nginx上,结果遇到了PEAR.php的问题,先安装pear 基本安富有就是 wget http://pear.php.

公司有个老项目,写了很多年了,是在apache 上面跑的,无意间,我想让它跑到nginx上,结果遇到了PEAR.php的问题,先安装pear

基本安富有就是

wget http://pear.php.net/go-pear.phar
php go-pear.phar

我php版本是5.4的,先禁用disable_functions 这个要不然安装不成功

安装上了以后,就调报是报了这个错

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

------------------------------------------------

各种尝试还是报

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"

==============================================================================

最后用了这么一招

 fastcgi_param PHP_VALUE open_basedir="open_basedir=$document_root:/usr/local/php/lib/php/:/tmp/:/home/wwwroot/";

整个世界又清静了.

目录
相关文章
|
7月前
|
开发框架 应用服务中间件 PHP
Mac Nginx 关联 php 详细配置以及常见错误
Mac Nginx 关联 php 详细配置以及常见错误
141 1
|
8月前
|
运维 监控 应用服务中间件
【运维知识进阶篇】zabbix5.0稳定版详解3(监控Nginx+PHP服务状态信息)(二)
【运维知识进阶篇】zabbix5.0稳定版详解3(监控Nginx+PHP服务状态信息)(二)
147 0
|
8月前
|
运维 负载均衡 关系型数据库
【运维知识进阶篇】用Ansible Roles重构LNMP架构(Linux+Nginx+Mariadb+PHP),实现4个项目一键部署
【运维知识进阶篇】用Ansible Roles重构LNMP架构(Linux+Nginx+Mariadb+PHP),实现4个项目一键部署
111 0
|
8月前
|
运维 关系型数据库 MySQL
【运维知识进阶篇】集群架构-Nginx实现基础web架构(Linux+Nginx+PHP+Mysql)(二)
【运维知识进阶篇】集群架构-Nginx实现基础web架构(Linux+Nginx+PHP+Mysql)(二)
201 0
|
8月前
|
消息中间件 NoSQL 关系型数据库
Linux安装 OpenResty、Nginx、PHP、Mysql、Redis、Lua、Node、Golang、MongoDB、Kafka等
Linux安装 OpenResty、Nginx、PHP、Mysql、Redis、Lua、Node、Golang、MongoDB、Kafka等
103 0
|
4月前
|
NoSQL 关系型数据库 应用服务中间件
Linux安装 OpenResty、Nginx、PHP、Mysql、Redis、Lua、Node、Golang、MongoDB、Kafka等
Linux安装 OpenResty、Nginx、PHP、Mysql、Redis、Lua、Node、Golang、MongoDB、Kafka等
88 0
|
4月前
|
应用服务中间件 Linux PHP
百度搜索:蓝易云【在centos中配置nginx+php的环境教程。】
请注意,上述步骤是基本的配置指南,实际操作中可能会有特定的需求和配置。建议参考Nginx和PHP官方文档或其他详细教程以获得更全面和准确的信息。
43 0
|
4月前
|
Ubuntu 网络协议 应用服务中间件
Ubuntu安装PHP和NGINX环境
PHP-FPM 是 PHP FastCGI Process Manager 的缩写,是 FastCGI 进程管理器。 PHP-FPM 是基于 master/worker 的多进程架构模式,与 nginx 的设计风格类似。master 进程主要负责 CGI、PHP 环境初始化,事件监听、子进程状态,worker 进程负责处理 PHP 请求。 FPM 的 master 通过共享内存获取 worker 进程的信息,包括 worker 进程当前状态、已处理请求数等,当 master 进程要杀掉一个 worker 进程时则通过发送信号的方式通知 worker 进程。
53 0
|
8月前
|
运维 监控 PHP
【运维知识进阶篇】zabbix5.0稳定版详解3(监控Nginx+PHP服务状态信息)(三)
【运维知识进阶篇】zabbix5.0稳定版详解3(监控Nginx+PHP服务状态信息)(三)
68 0
|
8月前
|
运维 监控 应用服务中间件
【运维知识进阶篇】zabbix5.0稳定版详解3(监控Nginx+PHP服务状态信息)(一)
【运维知识进阶篇】zabbix5.0稳定版详解3(监控Nginx+PHP服务状态信息)
136 0