search
Homephp教程php手册关于NGINX下开启PHP

关于NGINX下开启PHP

Jun 06, 2016 pm 07:46 PM
lnmpnginxphpaboutturn onbuildlocal

最近在本地搭建的LNMP的开发环境。为了开发的时候不影响前端的正常开发就屏蔽的PHP里面php.ini中的一些错误提示。但是这样一来,就影响到了后端开发的一些问题比如不能及时调试开发中的一些问题。 nginx与apache不一样,在apache中可以直接指定php的错误日志

最近在本地搭建的LNMP的开发环境。为了开发的时候不影响前端的正常开发就屏蔽的PHP里面php.ini中的一些错误提示。但是这样一来,就影响到了后端开发的一些问题比如不能及时调试开发中的一些问题。

nginx与apache不一样,在apache中可以直接指定php的错误日志,那样在php执行中的错误信息就直接输入到php的错误日志中,可以方便查询。

在nginx中事情就变成了这样:nginx只对页面的访问做access记录日志。不会有php的error log 信息。nginx把对php的请求发给php-fpm fastcgi进程来处理,默认的php-fpm只会输出php-fpm的错误信息,在php-fpm的errors log里也看不到php的errorlog。

原因是php-fpm的配置文件php-fpm.conf中默认是关闭worker进程的错误输出,直接把他们重定向到/dev/null,所以我们在nginx的error log 和php-fpm的errorlog都看不到php的错误日志。

所以我们要进行如下的设置就能查看到nginx下php-fpm不记录php错误日志的方法:

1,修改php-fpm.conf中的配置,如果没有请增加:

?

001

002

003

004

005

[global]

; Note: the default prefix is /usr/local/php/var

error_log = log/php_error_log

[www]

catch_workers_output = yes

2.修改php.ini中配置,没有则增加

?

001

002

003

log_errors = On

error_log = "/usr/local/php/var/log/error_log"

error_reporting=E_ALL&~E_NOTICE

3.重启php-fpm,
当PHP执行错误时就能看到错误日志在”/usr/local/lnmp/php/var/log/php_error_log”中了

如果出现:

?

001

002

003

004

005

006

[root@localhost etc]# service php-fpm restart

Gracefully shutting down php-fpm . done

Starting php-fpm [17-Apr-2014 18:40:52] ERROR: [/usr/local/php/etc/php-fpm.conf:5] unknown entry 'catch_workers_

[17-Apr-2014 18:40:52] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'

[17-Apr-2014 18:40:52] ERROR: FPM initialization failed

?failed

那请在第一步的时候,认真将配置写入相对应的组中,不然就出现上面的:ERROR: [/usr/local/php/etc/php-fpm.conf:5] unknown entry ‘catch_workers_output’

最后看看效果:

关于NGINX下开启PHP

?

关于NGINX下开启PHP

?

http://www.pooy.net/nginx-open-php-fpm-error-log.html

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor