4.54-56-php-fpm配置.md
PHP-FPM配置文件路径:
/usr/local/php-fpm/etc/php-fpm.conf
包含了一个目录 php-fpm.d/*.conf
www.conf 就是其中子配置文件
www.conf配置讲解
pool 名字: [www] 可以自定义,启动后,ps aux |grep php-fpm 看最右侧,就是pool的名字
listen 指定监听的IP:port或者socket地址
这个地址需要和nginx配置文件里面的那个fastcgi_pass所制定的地址一致,否则就会502
如果监听的是socket文件,那么要保证nginx服务用户(nginx)对该socket文件有读写权限,否则502
listen.mode 指定socket文件的权限
pm = dynamic 动态模式
pm.max_children = 5 最大进程数
pm.start_servers = 2 启动几个子进程
pm.min_spare_servers = 1 空闲时,最少不能少于几个子进程
pm.max_spare_servers = 3 空闲时,最多不能多于几个子进程
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[error_reporting] = E_ALL
配置slow 日志
slowlog = /tmp/php.slow
request_slowlog_timeout = 1
配置open_basedir
php_admin_value[open_basedir] = /data/wwwroot/blog.aminglinux.cc:/tmp
配置多个pool
定义多个配置文件,在配置文件中指定不同的listen地址 不同的 [pool_name]
[blog]
user = php-fpm
group = php-fpm
listen = /tmp/blog.socket
listen.mode = 0666
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
slowlog = /tmp/php.slow
request_slowlog_timeout = 1
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[error_reporting] = E_ALL
php_admin_value[open_basedir] = /data/wwwroot/blog.aminglinux.cc:/tmp
[bbs]
user = php-fpm
group = php-fpm
listen = /tmp/bbs.socket
listen.mode = 0666
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
slowlog = /tmp/php.slow
request_slowlog_timeout = 1
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[error_reporting] = E_ALL
php_admin_value[open_basedir] = /data/wwwroot/bbs.aminglinux.cc:/tmp
查看php.ini路径:
1) /usr/local/php-fpm/bin/php -i |head
2)用phpinfo
补充:
curl -k -H “host:bbs.aminglinux.cc” https://127.0.0.1/phpinfo.php
4.56 MariaDB密码重置
如果记得root的密码:
mysqladmin -uroot -paminglinux password “aming-linux”
如果不记得root密码:
1)编辑/etc/my.cnf
增加:skip-grant
重启服务
2)登录进MariaDB,执行
use mysql 切换到mysql库
desc user 查看user表的所有字段
update user set authentication_string=password(“aming-linux”) where user=‘root’;
3)退出MariaDB,删除/etc/my.cnf里面的skip-grant, 重启服务
4)用新密码登录即可
常识:
mysql在5.7.36版本之后把密码字段存到了authentication_string字段里,在之前版本存在password字段里。
update user set password=password(“aming-linux”) where user=‘root’;