php扩展安装、ini配置

Call to a member function F\M() on array 报错处理:

php.ini配置:

zend.exception_ignore_args = off    
忽略异常args = 关闭  php7.4默认开启【用到了类反射机制,必须关闭】
expose_php = Off
隐藏php版本【默认开启】
date.timezone = Asia/Shanghai
upload_max_filesize = 20M
post_max_size = 20M

 

swoole扩展安装:

mkdir /swoole
cd /swoole
wget https://github.com/swoole/swoole-src/archive/v4.8.3.tar.gz
接着使用tar zxvf 命令解压(zip包则用unzip命令解压),接着进入到压缩完的文件夹里面

tar -zxvf v4.8.3.tar.gz
cd swoole-src-4.8.3
进入到文件夹里面,就是官网上说的步骤了

phpize
./configure --enable-openssl --with-php-config=/usr/local/php/bin/php-config
make 
make install

xls扩展安装:

# 下载扩展包
wget https://pecl.php.net/get/xlswriter-1.5.2.tgz
# 解压
tar -zxvf xlswriter-1.5.2.tgz
# 进入解压的文件夹内
cd xlswriter-1.5.2
# 使用 phpize 安装扩展 
/usr/local/php-7.4/bin/phpize
# 指定 php-config 文件路径
./configure --with-php-config=/usr/local/php-7.4/bin/php-config
# 编译
make && make install
# 在 php.ini 配置文件中,添加配置
echo "extension = xlswriter.so" >> /usr/local/php-7.4/etc/php.ini
# 重新加载PHP扩展
systemctl reload php-fpm
# 查看配置
php -m | grep -i xlswriter

Redis扩展安装:

wget http://pecl.php.net/get/redis-5.3.2.tgz
 
tar -zxvf redis-5.3.2.tgz
 
cd redis-5.3.2
 
#phpize   必须要在下载并解压后的文件夹下使用才有效
 
phpize
 
./configure --with-php-config=/usr/local/php/bin/php-config
 
make && make install
 
编辑php.ini 加入扩展
extension = /usr/local/php/lib/php/extensions/debug-non-zts-20131226/redis.so
或者(只要可以加载就行)
extension = redis.so
 
重启php-fpm 测试查看redis扩展是否正常加载

amqp 扩展安装:

##先编译rabbitmq-c
wget https://github.com/alanxz/rabbitmq-c/archive/v0.10.0.tar.gz
tar -zxvf v0.10.0.tar.gz
cd rabbitmq-c-0.10.0/
##准备configure的时候,发现没有configure,0.9开始改成cmake了,靠,安装一下cmake
yum -y install cmake
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/rabbitmq-c-0.10.0 #指定安装目录
make && make install
##再编译amqp-1.10.2
wget https://pecl.php.net/get/amqp-1.10.2.tgz #下载
tar -xvf amqp-1.10.2.tgz #解压
cd amqp-1.10.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq-c-0.10.0
cp -R /usr/local/rabbitmq-c-0.10.0/lib64/ /usr/local/rabbitmq-c-0.10.0/lib
make && make install
加入到php.ini 查看一下!
extension=amqp.so 
#docker 内部,php 加入amqp扩展
docker-php-ext-enable amqp

php-fpm 配置: 

[global]
;pid = /usr/local/php/var/run/php-fpm.pid
error_log = /home/logs/php/php-fpm.log
log_level = warning

[www]
listen = 127.0.0.1:9000
listen.backlog = 8192
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0660
user = www
group = www
pm = dynamic
pm.max_children = 512
pm.start_servers = 64
pm.min_spare_servers = 64
pm.max_spare_servers = 512
pm.max_requests = 2048
pm.process_idle_timeout = 10s
request_terminate_timeout = 60
request_slowlog_timeout = 1
slowlog = /home/logs/php/$pool.log.slow

opcache 配置:

 

[opcache]
zend_extension=opcache.so
; Determines if Zend OPCache is enabled
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1

; The OPcache shared memory storage size.
opcache.memory_consumption=256

; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=32

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
opcache.max_accelerated_files=1000000

; The maximum percentage of "wasted" memory until a restart is scheduled.
;opcache.max_wasted_percentage=5

; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
opcache.use_cwd=1

; When disabled, you must reset the OPcache manually or restart the
; webserver for changes to the filesystem to take effect.
opcache.validate_timestamps=1

; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
opcache.revalidate_freq=3600

  • 8
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小猪@笨笨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值