Home >Backend Development >PHP7 >How to configure php.ini, php-fpm and www.conf in PHP7

How to configure php.ini, php-fpm and www.conf in PHP7

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-05-08 10:31:562116browse

This article will introduce to you the configuration methods of "php.ini", "php-fpm" and "www.conf" in PHP7. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to configure php.ini, php-fpm and www.conf in PHP7

Therefore, this article mainly briefly explains these three PHP configuration files. For the specific configuration process, see the appendix at the end of this article.

1 Configure php.ini

php.ini is the php running core configuration file:

######避免PHP信息暴露在http头中
expose_php = Off

######避免暴露php调用mysql的错误信息
display_errors = Off

######在关闭display_errors后开启PHP错误日志(路径在php-fpm.conf中配置)
log_errors = On

######设置PHP的扩展库路径
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20141001/"

######设置PHP的opcache和mysql动态库
zend_extension=opcache.so
extension=mysqli.so
extension=pdo_mysql.so

######设置PHP的时区
date.timezone = PRC

######开启opcache
[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1

######设置PHP脚本允许访问的目录(需要根据实际情况配置)
;open_basedir = /usr/share/nginx/html;
2 Configure php-fpm.conf

php-fpm.conf is the configuration file of the php-fpm process service:

######设置错误日志的路径
error_log = /var/log/php-fpm/error.log
######引入www.conf文件中的配置
include=/usr/local/php7/etc/php-fpm.d/*.conf
3 Configure www.conf (in the php-fpm.d directory)

www.conf This is the extended configuration file of the php-fpm process service:

######设置用户和用户组
user = nginx
group = nginx

######根据nginx.conf中的配置fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;设置PHP监听
; listen = 127.0.0.1:9000   #####不建议使用
listen = /var/run/php-fpm/php-fpm.sock

######开启慢日志
slowlog = /var/log/php-fpm/$pool-slow.log
request_slowlog_timeout = 10s

######设置php的session目录(所属用户和用户组都是nginx)
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session

Finally, attach a screenshot of the project:

How to configure php.ini, php-fpm and www.conf in PHP7

Recommended learning: php video tutorial

The above is the detailed content of How to configure php.ini, php-fpm and www.conf in PHP7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:TypeCodes. If there is any infringement, please contact admin@php.cn delete